alternative way of calling Coolprop every sampling time in simulink

7 次查看(过去 30 天)
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!

回答(1 个)

Rasmita
Rasmita 2023-2-16
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!

类别

Help CenterFile Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by