The medium is designed for pure or pseudo-pure substances in liquid, gas, or two phases. The thermodynamic calculations are performed using different equations of state(EOS), implemented in C language, that are called using external functions. The C code and the substances data are in the Resources folder.

For each substance there is the possibility of choosing between three EOS types: multiparameter, PCSAFT, or cubic. The  substance data is contained in a C structure, that is exported from the database using the FreeFluids GUI software.

The quality of the results is very high when multiparameter (Seltzmann and Wagner, SW) EOS are available. If not, PCSAFT or different flavours of cubic EOS can be used.

The transport properties are normally computed from temperature dependent correlations, with pressure correction. Nevertheless, for viscosity, the system will perform phase independent viscosity calculation (from temperature and density) for selected substances, using dedicated calculation or extended correspondent states with NIST correction polynomia, when available. In order to use the phase independent viscosity calculation the thermoModel parameter must be 3 (multiparameter EOS), as it is the only way to be sure that the supplied density is reliable. For thermal conductivity the same type of calculations are used.

The medium implements all the requirements of Modelica.Media.PartialTwoPhaseMedium. It is compatible with the new frontend of OpenModelica. 

 The main limitation of the medium, when using SW or PCSAFT EOS, is in the vecinity of the critical point, as no special technique, as for example splines, is used. The medium is much slower than the TMedia one, but is the price for the better precision and wider application.

The C code

The C code is placed in the Resources folder.

The FFbasic.h file contains the basic definition of structures and enumerations used in the code. 

The FFmodelicaMedium.c file contains the interface between Modelica and C. The FFeosPure.c and FFphysprop.c files contain the code that will perform the calculations in C.

Transport properties by dedicated calculation or ECS

The calculation of the substance viscosity is managed by the FF_Viscosity function in the FFphysprop.c file. If you have selected to work with the multiparameter EOS (thermoModel=3), that grants a good density calculation, it will check if there is a dedicated calculation from temperature and density (available only for few substances). If not, it will check if the correlation defined for gas viscosity calculation is the 112 (NIST coefficients for viscosity calculation using ECS) and that the data charged for the reference substance correspond to the needed one. If this is OK the ECS calculation will be applied for viscosity, otherwise temperature dependent correlations, with pressure correction, will be used.

If the EOS is of the cubic or PCSAFT type, correlations will be used if available. If not, the Lucas approximation will be used for gas. For liquid phase, if there is no correlation defined, the calculation will be done using ECS from the reference liquid defined.

For thermal conductivity a similar method is used.

The definition of the reference liquid is done at medium package level, giving value to the const String refName, which default value is 'Propane'.

Extra properties

Some property functions not defined in the Modelica.Media.Interfaces.PartialTwoPhaseMedium are also implemented. Four of them are for the calculation of liquid and gas dynamic viscosity and thermal conductivity. These functions will make the calculation using mainly correlations, without using dedicated calculation or Nist coefficients.

Ten more functions are added in order to match the requirements of the medium used in compressors, in the Buildings library. 

Medium definition

We need to define the mediums to be used. The already made definitions are inside the Fluids subpackage. Each definition is very short, just with the minimum information necessary. The most important of it is the mediumName, as this name is the name of the file (with extension .sd) placed in the Resources/Fluids folder that will be used for charging the data to the C structure.

For each medium you need both a medium definition in Modelica, and a binary file with the data in the Resources/Fluids folder. For adding new media both can be made using the program FreeFluidsGui.exe that has been also placed in the Resources/Extra folder. It will access the data base, allow you to select the substance, with the EOS and correlations to be used, and later export it to a binary file, with the data as C structure, and to a text file. The data file (.sd extension) must be placed into the FreeFluids.ExternalPure.Fluids folder. The medium definition package in Modelica can be placed at your choice, but is recomended to be placed inside the ExternalPure/Fluids package.

It is important to understand that the Vp, liquid saturated density, and gas saturated density, to use are not the best one, but the ones that match the calculation of the EOS. For example, if you have a PCSAFT EOS you must first construct correlations that match this EOS, and export them along with the EOS as a C binary structure. In the package extension in Modelica you should make the 'ancillaries' Integer constant equal to 0,2 or 3 in order to: no use ancillaries, use with SAFT type EOS, or use with SW type EOS. Transport properties correlations should be the best availables.

The program allows also the exportation of the correlations in the format used by the TMedia package.

Medium configuration

When extending the medium, the following configuration must be done:

The thermoModel Integer constant must be made equal to 1 for using the cubic EOS, 2 for the PCSAFT, or 3 for the SW.

The ancillaries Integer constant must be made equal to 3 for using ancillary functions (for saturated pressure and densities) with SW EOS, in order to obtain faster calculation. If made equal to 2 they will be used with the SAFT EOS. If made equal to 0, the calculations are made using only the EOS. It is slower, but can be necessary if the ancillary functions do not match the EOS with enough precision. 

The referenceState Integer constant must be made equal to 1 for using ASHRAE reference state, to 2 for using IIR, to 3 for using NBP, to 4 for using user reference_T and reference_p. Any other number will produce an unreferenced calculation for enthalpy and entropy.

If you are going to use the BaseProperties model, you must make the inputChoice constant String equal to 'ph', 'pT' or 'dT', as needed. When instantiating the model, you can still change the selection just for the object, specifying the value for the localInputChoice constant.

How it compares with the ExternalMedia library

ExternalPure is not a reference library as can be RefProp or CoolProp. It has a lot of multiparameter EOS, but some times are not the newest ones. The calculation of derivatives is in many times numerical and not symbolical. And only pure or pseudo pure substances are covered, although I think that this is also the case for ExternalMedia. Nevertheless the results are still of high quality and enough for the normal practical work.

It has also some advantages over ExternalMedia:

- The speed is higher if for any reason TTSE can't be used (if TTSE can be used ExternalMedia/CoolProp is faster)

- The calculation of transport properties is much more flexible.

- The addition of new substances by the user is much easier.



Generated at 2024-04-15T18:15:56Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos