Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)

Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Ferrucci
  • » Profile



Hey there,

You could use the hysteresis block from the Modelica Standard Library: … resis.html

You also have the 'on/off controller': … oller.html

Hi there,

I'm running different versions of OMEdit (1.9.7, 1.17.0, 1.18.0) and I've made a batch script to replace the "omedit.ini" file before launching OMEdit, so each version of the program has the correct ini file. In that batch script I also set the corresponding environmental variables.

This works well, but I doesn't allow me to launch two version of OMEdit at the same time.

Here is the batch file for OMEdit 1.8.0 (OMEdit1.18.0.bat):


REM Set OpenModelica environmental variables:
set OPENMODELICAHOME=C:\OpenModelica1.18.0-64bit
set OPENMODELICALIBRARY=C:\OpenModelica1.18.0-64bit\lib\omlibrary

REM Name of OpenModelica init file:

REM Folder where OpenModelica init file is located:
SET INITFILE_DIR=%HOMEDRIVE%%HOMEPATH%\AppData\Roaming\openmodelica\

REM Folder of this batch script (need this to avoid problems when calling this batch file from a Shortcut file):
SET THIS_BATCHFILE_DIR=c:\Users\ferrucci\OneDrive\workspace\modelica\launch_openmodelica_multiple_versions\1.18.0\

REM -----------------------------------------------------
REM -----------------------------------------------------

REM Remove existing init file:

REM Copy local init file to target folder (INITFILE_DIR):

REM Open OpenModelica:
echo "OMEdit closed"

REM Backup init file (in case it was modified while using OpenModelica):

REM Pause so the user needs to press any key:

Hope this helps to someone !!!

Oh my god, thank you so much current/wink

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,


Hi everyone !

I made a function to import the MAT file generated by OpenModelica to Matlab (see file attached).

The function is based on the 'omimport' function by Christian Schaad, with the following enhancements:
a. all the variables are returned in a single 'struct' variable. This is advantageous when importing several results in the same workspace and we don't want to mix the variables.
b. the user can choose to import or not the time derivative of the variables.
c. the user can set a 'black list' of variables (or components) to exclude from the import process.

I hope this helps! current/wink



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:

It would be necessary to transform this file into something similar to this:

Have anyone done this before in order to extend the fluid coverage of HelmholtzMedia library ?

Thank you!

Gracias Carlos ! current/wink

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 !


Hi there,

While we all wait for the update of ExternalMedia (winky face to Francesco current/wink), I found this library:

Does anyone have experience of using this library with OpenModelica ?

Thank you !

Hi everyone,

I was trying to run the examples from the PowerGrid 1.0.0 library under OM 1.16.1 and I found that they didn't pass the check, so they couldn't be compiled and run.

The error was: "Following variable is discrete, but does not appear on the LHS of a when-statement ..."

I could get the model to pass the check (and to simulate) by commenting out the "discrete" identifier of three variables from the following two files:
  \lib\omlibrary\PowerGrids 1.0.0\Electrical\Branches\
  \lib\omlibrary\PowerGrids 1.0.0\Electrical\Branches\

These are the actual lines:
   discrete Types.ComplexAdmittance Y_actual "Actual series admittance";
   discrete Types.ComplexAdmittance YA_actual "Actual shunt admittance at port A";
   discrete Types.ComplexAdmittance YB_actual "Actual shunt admittance at port B";

After commenting them:
  /* discrete */ Types.ComplexAdmittance Y_actual "Actual series admittance";
  /* discrete */ Types.ComplexAdmittance YA_actual "Actual shunt admittance at port A";
  /* discrete */ Types.ComplexAdmittance YB_actual "Actual shunt admittance at port B";

Hope this helps to someone current/wink

Given the following simple model:



model Test "Model based on built-in, ideal-gas model from Modelica.Media"
  package Medium = Modelica.Media.IdealGases.SingleGases.NH3 "Medium model";
  parameter Medium.AbsolutePressure p = 0.1e5;
  parameter Medium.Temperature T0 = 300;
  parameter Real dTdt (unit = "K/s") = 100;
  Medium.BaseProperties medium;
  Medium.Temperature T = medium.T;
  Medium.SpecificEnthalpy h = medium.h;
  Medium.SpecificInternalEnergy u = medium.u;
  Medium.SpecificEntropy s = Medium.specificEntropy(medium.state);
  medium.p = p;
  T = T0 + dTdt * time;
  annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 0.0001, Interval = 0.0002));
end Test;

I would like to change the reference enthalpy and reference entropy of the medium. From what I could understand, the reference enthalpy is fixed in package Modelica.Media.IdealGases.Common.Functions:


constant Boolean excludeEnthalpyOfFormation=true;
constant Modelica.Media.Interfaces.Choices.ReferenceEnthalpy referenceChoice=Modelica.Media.Interfaces.Choices.ReferenceEnthalpy.ZeroAt0K;
constant Modelica.Media.Interfaces.Types.SpecificEnthalpy h_offset=0.0;

But I don't understand how to override these constants in my model.

For the reference entropy, I couldn't find where it is fixed in the code.


Hi there,

No need to install a virtual machine to use openModelica 1.9.7 and ExternalMedia.

I have Windows 10, with two versions of openModelica installed. I use version 1.9.7 to use ExternalMedia and 1.16.2 for the rest of the stuff.
I followed the following steps to have the two versions installed:
a) Install version 1.16.2 (64 bits)
b) Remove the environment variables (not sure if absolutely necessary). To do this:
     i. Open Windows Powershell: right click on window start button -> Windows PowerShell
     ii. Type: rundll32.exe sysdm.cpl,EditEnvironmentVariables
     iii. Find OPENMODELICAHOME and OPENMODELICALIBRARY and remove them.
c) Temporally rename the folder of the openModelica installation folder. This is necessary otherwise the installer of the 1.9.7 version will complain and try to uninstall 1.16.2. You can add an underscore at the end of the folder's name, like this: c:\Program Files\OpenModelica1.16.2-64bit_
d) Install version 1.9.7.
e) Remove the new environment variables created by this last installation
f) Create two BAT files to launch the programs. This is necessary since we need to create the environment variables:
File "OMEdit1.9.7.bat":
set OPENMODELICAHOME=C:\OpenModelica1.9.7
set OPENMODELICALIBRARY=C:\OpenModelica1.9.7\lib\omlibrary

File "OMEdit1.16.2.bat":
set OPENMODELICAHOME=C:\Program Files\OpenModelica1.16.2-64bit
set OPENMODELICALIBRARY=C:\Program Files\OpenModelica1.16.2-64bit\lib\omlibrary

If you want a nice OpenModelica icon over these BAT files, just create a shortcut to them and, in the properties of these shortcuts, change the icon to c:\OpenModelica1.9.7\bin\OMEdit.exe or C:\Program Files\OpenModelica1.16.2-64bit\bin\OMEdit.exe

  • Index
  • » Users
  • » Ferrucci
  • » Profile
You are here: