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

Posts

Posts

Hey there,

You could use the hysteresis block from the Modelica Standard Library:

https://doc.modelica.org/Modelica%203.2 … resis.html

You also have the 'on/off controller':

https://doc.modelica.org/Modelica%203.2 … 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):


@ECHO OFF

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:
SET INITFILE_NAME=omedit.ini

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 DO NOT TOUCH ANYTHING HEREAFTER !
REM -----------------------------------------------------

REM Remove existing init file:
DEL %INITFILE_DIR%%INITFILE_NAME%

REM Copy local init file to target folder (INITFILE_DIR):
COPY %THIS_BATCHFILE_DIR%%INITFILE_NAME% %INITFILE_DIR%

REM Open OpenModelica:
%OPENMODELICAHOME%\bin\OMEdit.exe
echo "OMEdit closed"

REM Backup init file (in case it was modified while using OpenModelica):
COPY %INITFILE_DIR%%INITFILE_NAME% .\%INITFILE_NAME%

REM Pause so the user needs to press any key:
PAUSE




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,

Franco


AmmoniaFerrucci.zip

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

Cheers!

omimportNew.m

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!

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 !

Franco

Hi there,

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

https://github.com/ClaRaLibrary/TILMedia

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\TransformerFixedRatioWithBreaker.mo
  \lib\omlibrary\PowerGrids 1.0.0\Electrical\Branches\LineConstantImpedanceWithBreakers.mo

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:

Code:

 

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);
equation
  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:

Code:


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.

Thanks!

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:
Example:
File "OMEdit1.9.7.bat":
set OPENMODELICAHOME=C:\OpenModelica1.9.7
set OPENMODELICALIBRARY=C:\OpenModelica1.9.7\lib\omlibrary
%OPENMODELICAHOME%\bin\OMEdit

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
%OPENMODELICAHOME%\bin\OMEdit

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: