Search code examples
modelicadymola

How to use functions in the command window of Dymola?


I am working with Dymola, and try to use the functions provided by Modelica standard library in the command window, but it seems that I can't use them, and I couldn't claim a variable of a specific type either. I am wondering if there is some kind of limit of the command I could use in the command window of Dymola. Where should I find all the allowable commands?

enter image description here

I try to use some functions from Modelica.Media, it seems the input variables are out of range, but I tried a lot of times and different units system. I find that I can't declare a variable of pressure type in the command window, but Modelica.Media.Water.IF97_Utilities.h_pT() requires that I need to provide the variable as pressure and enthalpy type, is this the reason I can't use this function in the command window?

Modelica.Media.Water.IF97_Utilities.h_pT(1e6,800,1)
Failed to expand Modelica.Media.Water.IF97_Utilities.h_props_pT(
  1000000.0, 
  800, 
  Modelica.Media.Common.IF97BaseTwoPhase(
    phase = 1, 
    region = 1, 
    p = 1000000.0, 
    T = 800.0, 
    h = 9.577648835649013E+20, 
    R = 461.526, 
    cp = 1.8074392528071426E+20, 
    cv = -3.7247229288028774E+18, 
    rho = 5.195917767496603E-13, 
    s = 1.2052984524009106E+18, 
    pt = 645518.9415389205, 
    pd = 6.693617079374418E+18, 
    vt = 357209983199.2206, 
    vp = -553368.7088215105, 
    x = 0.0, 
    dpT = 645518.9415389205
  )).
Failed to expand Modelica.Media.Water.IF97_Utilities.h_pT(1000000.0, 800, 1).

enter image description here

enter image description here


Solution

  • Assuming the inputs are valid there seems to be an issue specifically related to evaluating some media-functions interactively in Dymola (since they shouldn't be evaluated in models). It will be corrected in Dymola 2022x.

    A temporary work-around is to first set the flag Advanced.SemiLinear = false; and then:

    Modelica.Media.Water.IF97_Utilities.h_pT(1e6,800,1)
     = 9.577648835649013E+20
    

    (I'm not sure how valid the formulation is in that region.)

    But please remember to set Advanced.SemiLinear = true; before translating and simulating any models - in particular models using media-functions.