- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » TIL Media on OpenModelica
TIL Media on OpenModelica
TIL Media on OpenModelica
Hi there,
While we all wait for the update of ExternalMedia (winky face to Francesco ), I found this library:
https://github.com/ClaRaLibrary/TILMedia
Does anyone have experience of using this library with OpenModelica ?
Thank you !
- Ferrucci
- 10 Posts
Re: TIL Media on OpenModelica
I knew about it, but I thought it was a comercial library. I will try to make it work, in the first test it didn't find the dll library, that is inside the Resources folder. As I have no experience in linking OpenModelica with dlls I will need some time.
You can check also the media libraries I have written at GitHub. The TMedia one is written completely in Modelica, it is very fast and the main limitation is that it works only below the critical temperature. The ExternalMedia uses external objets and functions in C, and implements cubic, PCSAFT and multiparameter EOS. Both of them support liquid, gas and biphasic states, although transport properties are only calculated for monophasic ones.
Re: TIL Media on OpenModelica
Gracias Carlos !
I will look into it ! In the meantime, I have a some questions:
a. Does it include Ammonia (gas/liquid/gas-liquid)?
b. With which version of OpenModelica have you tested it ?
c. Are the DLL compiled for Windows 64bits ?
Thank you again !
Franco
- Ferrucci
- 10 Posts
Re: TIL Media on OpenModelica
Hi Franco,
Yes, it includes ammonia. In fact there is a Windows program and a database in the Resources folder, with the program you can export data from the database in the format needed in Modelica. In the database there are 500 substances, and you can add what you need. My Idea has been maintain the data in the database and export the substances when needed.
I am working now with the version 1.16.5 of OpenModelica, using the MSL 3.2.3. For using MSL 4.0.0 it is necessary to make some very small changes, that I have already tested, but I am waiting for the version 1.18 of OpenModelica to make the change.
In my program (ExternalMedia library only, because the others library are stright Modelica code) there is no dll, there is C code, that is compiled by OpenModelica at the same time that it does the global compilation.
Regards
Carlos
Re: TIL Media on OpenModelica
Hi Franco,
Unfortunately you may not be able to use my library. I use always the functional interface, with no problem, but when running the Modelica.Media test I see that the interface using BaseProperties gives compatibility problems, probably due to some defect in the definition of the model. I will try to find the cause and fix it, but this is the current situation.
In the meantime I have rechecked HelmholtzMedia, which is a great library, but it was not working, at least in OpenModelica. I see that it currently works. You don't have ammonia in the fluids list, but it doesn't seem too difficult to add it from the CoolProp data files, using for example a Python program. I'll try to do it.
Regards
Carlos
Re: TIL Media on OpenModelica
Thank you Carlos,
I look forward receiving news from you then...
Today I looked into CoolProp source code and I saw that the information about ammonia is inside a "json" file:
\dev\fluids\Ammonia.json
It would be necessary to transform this file into something similar to this:
lib\omlibrary\HelmholtzMedia\HelmholtzFluids\R134a\package.mo
Have anyone done this before in order to extend the fluid coverage of HelmholtzMedia library ?
Thank you!
- Ferrucci
- 10 Posts
Re: TIL Media on OpenModelica
Well, I started today. I think that the soft is very good and it is a pity to have so few substances filled. I am working now with butane, in order to validate the results I will obtain from the CoolProp file against the results from the HelmholtzMedia file. It is not difficult and I expect to finish in two days if I can spend some hours in this. I will inform you.
Regards
Re: TIL Media on OpenModelica
Hi Franco,
It begins to work. I can export automaticaly from CoolProp to HelmholtzMedia the EOS (ideal and residual parts), the ancillary equations and the surface tension. For viscosity and thermal conductivity I need some more time to clarify the equivalence.
There are some points to polish: for example CoolProp doesn't give the minimum and maximum enthalpy, or density. I do not know if putting here an approximate number is enough. One possibility is to put an approximate value, run the EOS between minimum and maximum temperatures and pressures and re-enter the obtained values.
I have seen that HelmholtzMedia doesn't have some terms needed for the most recent EOS. It lacks Gao, and association, terms, For this reason I have used the Tillner Roth equation for Ammonia instead of the 2020 Gao equation.
I attach the folder and files to put in the HelmholtzFluids folder. You will see that I have suppressed the entries for viscosty and thermal conductivity, so do not use them for now. Can you check if it works for you?
Ammonia.zip
Re: TIL Media on OpenModelica
Oh my god, thank you so much
I spent the whole day yesterday doing exactly the same, doing reverse engineering from RefProp library (AMMONIA.FLD file).
I send you attached my version. I will compare them tomorrow.
Muchas gracias again,
Franco
AmmoniaFerrucci.zip
- Ferrucci
- 10 Posts
Re: TIL Media on OpenModelica
Congratulations Marco! !
It works perfectly. I have compared the results with my own library and the only difference is at high temperature due to the different ideal gas heat capacity approach. In fact you spent more time than me in polishing, I let there some values from Butane. I did it with CoolProp and Python, using the json parser, because it seemed me easier to automatize than from a text file, and for more substances the work is already done.
There are some points to care about. One is the reference state to use, from CoolProp it seems that the default is IIR and, if not, they add a translation coefficients. For me the more important point now is that of viscosity and thermal conductivity: I gave a look at what HelmholtzFluid is doing, because I want to be sure that it covers all substances for which multiparameter EOS are available, before to work in the mapping between CoolProp and HelmhotzMedia.
In the meanwhile I found and solved the problems of my Media libraries with the BaseProp model. Now the Modelica.Media tests run fine, and also the Modelica.Fluid examples I have tested. I am now checking and polishing and I will update them in a few days.
Best Regards
Carlos
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » TIL Media on OpenModelica