alternative way of calling Coolprop every sampling time in simulink

8 visualizaciones (últimos 30 días)
Seungho Rhee
Seungho Rhee el 3 de Feb. de 2023
Respondida: Rasmita el 16 de Feb. de 2023
Hello all,
I am using Coolprop for humid air properties in Simulink with Matlab function block. It is working well without any error, but it's too slow. I guess it is calling Coolprop from python library every sampling time, and it makes simulation slow. Here is how I use the Coolprop on my code below.
function y = matlabfunc(input1, input2, input3)
coder.extrinsic('py.CoolProp.CoolProp.HAPropsSI');
y = py.CoolProp.CoolProp.HAPropsSI('Vha','Hha',input1,'P',input2,'RH',input3);
end
Is there any alternative way to use Coolprop with faster speed? For example, calling Coolprop only one time before simulation starts, load it into workspace or somewhere, and use it.
Thanks!

Respuestas (1)

Rasmita
Rasmita el 16 de Feb. de 2023
Hi Seungho,
It is my understanding that, you want to run above mentioned function only one time before simulation.
For this, you can add this function content in 'startFcn' callback of the model.
For this, go to Model Properties -> Callback Tab -> startFcn.
It will be called once before the simulation starts.
For more information on model callbacks, refer to this documentation page: model_callbacks.
Hope this helps!

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by