Two-Phase Modelica Media example

╄→尐↘猪︶ㄣ 提交于 2019-11-30 23:25:56

Generally, your medium model can be written in Modelica or you can reuse an existing external library. Writing good medium models is a lot of work, so reusing existing libraries is usually a good idea. This is the approach taken by ExternalMedia (open source) or TILMedia (commercial). If you are interested in an open-source workflow, ExternalMedia in combination with Coolprop is a reasonable decision. All three projects OpenModelica, ExternalMedia and CoolProp accept contributions from the community, so maybe you should help improving these instead of writing your own library. There is a lot of work going on already, I am unsure of the current status. Writing qualified bug reports (including steps to reproduce the problem) is also a very welcome way to contribute.

For some applications, it might be good to have the Medium model directly in Modelica. This is the approach taken by Modelica.Media (obviously), HelmholtzMedia and the commercial media libraries from XRG or Modelon (not 100% sure about that). There are some more implementations, but these are neither open source nor commercial, only information are e.g. conference papers. The examples you can look at include the R134a medium from the MSL or the code from the HelmholtzMedia library. Also, looking at the ExternalMedia implementation might help.
For fluids that cannot change phase, there are some good examples in the Annex60 library.

As you have a pure substance that can change phase, your new medium should extend from PartialTwoPhaseMedium. PartialTwoPhaseMedium is partial, defining only what functions are there, but (mostly) not the algorithms of the functions. You will have to write an algorithm for each and every function that is available in the interface and does not have an algorithm in order to be fully compatible. For a start, you should implement at least one of the setState funtions, e.g. the setState_ph function. Then later, implement at least one setSat function and the BaseProperties.

If you implement your own medium, you also have the choice of how to model it: Using the full multiparameter Helmholtz energy equation of state, a simpler equation of state like Peng-Robinson or other cubic EoS, some polynomials or splines, table-based methods like TTSE or SBTL and probably many more options.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!