Guy on Simulink

Simulink & Model-Based Design

CoolProp to the Rescue

This week, I am happy to welcome guest blogger Tom Egel from MathWorks Consulting Services.

CoolProp to the Rescue

Do you use the Simscape Thermal Liquid domain? If so, then you should know about CoolProp.

Specifying fluid properties is an important part of creating an accurate simulation model. The industry standard REFPROP database from NIST contains many fluid properties. There is a demo on MATLAB Central showing how it can be used to parametrize a Simscape model.

Engine Cooling demo

Obviously, not all fluids in the universe are present in the REFPROP database. One notable omission is common antifreeze, also known as Ethylene Glycol (or the more environmentally friendly Propylene Glycol).

This is where CoolProp comes in...

CoolProp is an open source fluid property database very similar to REFPROP, and it provides wrappers so it can be called from MATLAB.

To get started, go to their sourgeforge project page and download those four files: +CoolProp.7z, CoolPropsetup.m, SwigRef.m, and the wrapper MEX-file for your operating system.

With that on your path, you can obtain properties, for example the density, of a Propylene Glycol (PG) mixture using code like:

Obtaining the density of Propylene Glycol

The main function call CoolProp.PropsSI can only operate on scalar quantities (single temperature and pressure values), so the next step is to wrap the calls to CoolProp.PropsSI in for loops to create the 2D tables needed for the Simscape Thermal Liquid domain.

Obtaining the density of Propylene Glycol

We can then call this function for the range of pressures and temperature of interest, and obtain the different properties needed by the Thermal Liquid domain.

Obtaining the density of Propylene Glycol

And use the output in the Thermal Liquid Settings block:

Thermal Liquid Settings

Now it's your turn

Do you simulate exotic fluids with the Simscape Thermal Liquid domain? How do you get you fluid properties data? Let us know by leaving a comment here

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。