简体   繁体   中英

Usage for ExternalMedia in Dymola

I am a student who is researching about HVAC. I'm modelling a heat pump system and I got some problem.

As I was going to get the fluid property by ExternalMedia, I got some error.

The source code is below:

model Pentane_hs
package wf
  extends ExternalMedia.Media.CoolPropMedium(
    mediumName = "Pentane",
    substanceNames = {"n-Pentane"},
    inputChoice=ExternalMedia.Common.InputChoice.hs);
end wf;
  wf.BaseProperties fluid "Properties of the two-phase fluid";
  Modelica.SIunits.SpecificEnthalpy h;
  Modelica.SIunits.Pressure p;
  Modelica.SIunits.SpecificEntropy s;
  Modelica.SIunits.DerDensityByEnthalpy drdh
    "Derivative of average density by enthalpy";
  Modelica.SIunits.DerDensityByPressure drdp
    "Derivative of average density by pressure";
equation 
  //p = 1E5;
  h = 0 + time*1E6;
  s = 1500;  //600 + time*2000;
  fluid.p = p;
  fluid.s = s;
  fluid.h = h;
  drdp = wf.density_derp_h(fluid.state);
  drdh = wf.density_derh_p(fluid.state);
end Pentane_hs;

This is the error I get:

在此处输入图像描述

I'm using Dymola 2023x.

I tried to import the library but it failed.

I want to get the property by pressure and temperature.

From the error messages in your screenshot we see that Dymola can not resolve the paths starting with Modelica.Units.SI . They are correct in older Modelica library versions, but not in the current release 4.0.0.

The ExternalMedia library requires Modelica 3.2.3, but recent Dymola versions have Modelica 4.0.0 installed as default.

You have to install Modelica 3.2.3 as described in the appendix of the Dymola User Manual Volume 1 , section Installing earlier Modelica versions including compatible libraries .

  1. Get the zip file CompatibilityLibraries MSL 3.2.3.zip located in the extras directory of the Dymola installer

  2. Extract the zip to the library folder of your Dymola installation, typically C:\Program Files\Dymola 2023x\Modelica\Library , but before you do that, read the next point.

  3. This is not noted in the user manual, but the file Complex.mo and the folder ModelicaReference will be overwritten. I suggest to make a backup first, so you can easily revert.

  4. Start Dymola and change the default Modelica library version under File > Options > Version . Dymola 中 MSL 版本选项的屏幕截图

  5. The user manual also suggests to tick Force upgrade of models to this version , but I am not sure if it makes a difference in your case.

  6. Restart Dymola, then load your libraries.

The solution of Marco works, but it limits you to use libraries that are also using MSL 3.2.3 instead of MSL 4.0.0. You can convert the ExternalMedia to MSL 4.0.0. Dymola should ask you if you want to do that when you load the ExternalMedia library. With the inbuilt conversion scripts most of the library is converted automatically and you should be able to test your model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM