Problems with coolprop in simulink function

613 views
Skip to first unread message

jose manuel nuñez

unread,
Oct 28, 2021, 10:13:09 PM10/28/21
to coolprop-users
Hi, i am stuck in this problem
stuck.PNG

I don't know how to solve this. The same function works in a .m file, but in simulink function
doesn't work.
Thanks for answer

Ian Bell

unread,
Oct 28, 2021, 10:20:30 PM10/28/21
to coolpro...@googlegroups.com
I think you can't use CoolProp with simulink.  At least I don't know of anyone that has so far.  Maybe if you can call shared libraries you can.  But calling shared libraries in MATLAB is not so easy.

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coolprop-users/8faf8b65-064b-4cc0-bdbb-562afe99c023n%40googlegroups.com.
Message has been deleted

Nicola Foletti

unread,
Nov 5, 2021, 4:55:45 AM11/5/21
to coolprop-users
Hi,
during last week with my colleague we manage this problem in the following way. As shown in the picture in the attachement we utilize coder.extrinsic, the meaning is explained at the following link: https://it.mathworks.com/help/simulink/slref/coder.extrinsic.html .
In particular it is neccessary to initialize the variable, before recall PropsSI.
I hope this helps.
code_simulink_function.png

Nikolaj Maack Bielefeld

unread,
Nov 5, 2021, 11:48:28 AM11/5/21
to coolprop-users
Thanks for this information, that can become usefull. :-) I have to try this out.

Ian Bell

unread,
Nov 5, 2021, 1:05:29 PM11/5/21
to coolpro...@googlegroups.com
This is very useful information, as many people have asked about simulink + CoolProp (and also + REFPROP) before.  Can you add some docs to the MATLAB information?

Nikolaj Maack Bielefeld

unread,
Nov 5, 2021, 10:19:02 PM11/5/21
to coolprop-users
I just tested the function and I can confirm that it works also for REFPROP, and it is very simple to setup, as shown below! Great news :-)

SimulinkREFPROP_test.PNG

Nikolaj Maack Bielefeld

unread,
Nov 6, 2021, 12:40:57 PM11/6/21
to coolprop-users
The above method will be the most accurate, however, it should also be quite slow, due to Simulink calling Matlab and Matlab calling CoolProp/REFPROP at each timestep for each block using this. This might be an issue for large Simulink models?

There is also another way of using CoolProp/REFPROP properties in Simulink, and that is by using interpolation in lookup tables:

The documentation does not mention an upper limit for rows and columns in the generated lookup table, so it should be possible to achieve ok accuracy here too? And the solver speed will not be slowed down like above.
There is an example in Simulink called "ssc_refrigeration" that demonstrates the use of such a generated lookup block for two phase fluid properties.
Reply all
Reply to author
Forward
0 new messages