OpenModelica


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

Posts

Posts

Today 18:23:33
'simulate" command creates many build files in working directory
Category: Programming

You can just do:

Code:


mkdir("tmpdir1"); cd("tmpdir1");
simulate(Model);
cd(".."); remove("tmpdir1");

Alternative you can use filename prefix to generate these file with a specific name that you can easily delete later.

Code:


stimulate(Model, filenamePrefix="tmpFile");
system("rm tmpFile*");

How does your Modelica function that calls the C looks like?
Did you give the library name via the external annotation?

You cannot have IF in the component section in a Modelica model (well, except for conditional components). You can only use if inside equations. However, what you want can be done via if expressions:

Code:


parameter Real A;
Real y1(start=if A ==1 then 0.2 else 2.2),
         y2(start=if A ==1 then 3.5 else 1.5),
         y3(start=if A ==1 then 0.5 else 0.3);

Jun-10-20 15:34:57
OMEdit quits upon startup splash screen after "creating widgets" stage

Sorry, my mistake in the email, it should be %TEMP%\OpenModelica\OMEdit\

If you write %TEMP% in Windows Explorer you should get to a directory like: C:\Users\USER_NAME\AppData\Local\Temp
and then navigate to OpenModelica\OMEdit\ and see what files are there. Zip that entire directory and send the zip to us
via email to OpenModelica or directly to me.

You can skip the initialization even now via -iif=initial_file.mat and -iim=none and -iit=initTime (if you need that):
https://www.openmodelica.org/doc/OpenMo … flags.html

It seems that currently, the only way to properly get the initial values is LOG_SOTI.
If you simulate to stopTime=0 *and* you have events at time zero the initial values will change.

I will open a ticket about it to add a new flag, something like "-iof=file.csv" that one can use to dump the initial values instead of relying on LOG_SOTI.

I guess you can simulate with stopTime=0.0 and with format "csv" you will get the initial values.
I'll ask one of our runtime developers if there is another way.

Works fine for me with -overideFile=c:/dev/o.txt
Note that OMEdit is strange and will display in the variable browser the value 2 for b, but click on it and the graph will show 10!
OMEdit takes the value from the Model_init.xml file, which is what is loaded and set before doing the override.

Code:


C:/temp/TestOverride/TestOverride.exe -port=64260 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/temp/TestOverride/TestOverride_res.mat -w -lv=LOG_STATS
-overrideFile=c:/dev/o.txt
-inputPath=C:/temp/TestOverride -outputPath=C:/temp/TestOverride

See:
https://pasteboard.co/Jbqs9zW.png

I think it exits because you need the latest nightly, before the simulation executable didn't run if you used both -override and -overrideFile.

Also, I strongly suggest you use the nightly builds 1.16 as we will do a release from it soon.
Version 1.15 will be discontinued and we will move directly to 1.16.
I just had a look now and it seem we didn't even ported the fix in #5696 to 1.15.

I get it. It should work with simulation flags for the simulation executable.
The problem is that OMEdit is already using -override to override some of the flags, you can see this in simulation window:

Code:


C:/temp/Modelica.Blocks.Examples.PID_Controller/Modelica.Blocks.Examples.PID_Controller.exe
-port=55479 -logFormat=xmltcp
-override=startTime=0,stopTime=4,stepSize=0.008,tolerance=1e-06,solver=dassl,outputFormat=mat,variableFilter=.*
-r=C:/temp/Modelica.Blocks.Examples.PID_Controller/Modelica.Blocks.Examples.PID_Controller_res.mat
-w -lv=LOG_STATS -inputPath=C:/temp/Modelica.Blocks.Examples.PID_Controller
-outputPath=C:/temp/Modelica.Blocks.Examples.PID_Controller

Your problem is that we don't allow several override flags for the executable, just one.
Is on my TODO list to allow it, I will open a ticket about this.

We however do allow both -override and -overrideFile so for now you can use the -overrideFile=c:/path/to/override_file.txt
See: https://trac.openmodelica.org/OpenModelica/ticket/5696


In OMEdit, to resimulate you don't need to do any of that, is done automatically.

After first simulation, in the Plotting perspective, in the Variable Browser on the right hand side change
any of the parameters you want using the edit box, then right click on the top of the tree, the name of the
model and say Resimulate.

Is this command line? Or via OMEdit?

Is not possible yet.
I'm working on getting my support for redeclares in so that you can change those as well.
Hopefully should be available later this week in the nightly builds.

May-31-20 14:36:41
Error when trying to link OSG debug libraries even if installed
Category: Developer

Just edit: OpenModelica\OMEdit\OMEditGUI\OMEditGUI.win.config.pri and change the osg libs to the ones not using "d" at the end:

These:

Code:


LIBS += -llibosgd.dll -llibosgViewerd.dll -llibOpenThreadsd.dll -llibosgDBd.dll -llibosgGAd.dll

to these:

Code:


LIBS += -llibosg.dll -llibosgViewer.dll -llibOpenThreads.dll -llibosgDB.dll -llibosgGA.dll

I guess you don't need to debug the OSG part in OMEdit (3D visualization).

May-26-20 18:56:45
I can't make it work.
Category: Workshops

It might already be fixed in the new MUMPS, what we include in OpenModelica is an older version. You can check if the new one works to build and if it doesn't, then report a bug.

May-26-20 14:26:10
Erreur de Simulation basée sur FMI

From what i could translate using google I think this is your problem:

The new front-end which is the default does not allow to use reinit in algorithms as that is conform with the Modelica specification.
You can select to use the old front-end before you import the FMU: Options->Tools->Simulation->Enable old frontend for code generation.

May-24-20 21:47:25
I can't make it work.
Category: Workshops

According to the gcc 10.1 page:
https://gcc.gnu.org/gcc-10/porting_to.html
it might work if you configure with:

Code:


/configure FC="gfortran --std=legacy" --with-cppruntime

to force gfortran 10 to work as previous versions.

May-24-20 21:32:04
I can't make it work.
Category: Workshops

We are not testing so high version of gfortran / gcc. The highest version we test is gfortran / gcc 9.3.0 on Ubuntu 20.04.
It seem that there are some issues with it.

You could maybe try to configure with an older gfortran via:

Code:


./configure FC=gfortran-9.3.0 --with-cppruntime

if you have an older gfortran available until they fix this in mumps.

May-24-20 11:51:08
I can't make it work.
Category: Workshops

If you search for *** in the trace you will see that it dies trying to compile Mumps for Ipopt. Basically it seems that the fortran compiler has issues:

Code:


Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
MUMPS/src/dmumps_comm_buffer.F:2670:23:

what version of gfortran do you have?
Run the command above to find out.

Code:


> gfortran --version

May-22-20 22:08:20
I can't make it work.
Category: Workshops

I need to see the *entire* build log. Because you are compiling with "make -j8" the build error can be anywhere in the log and seeing only the last commands where make tells it fails it doesn't help.

Edit PKGBUILD and change "make -j8" to "make -j8 > trace.txt 2>&1" run it again and upload the trace file.

It might be the new dependency to libcurl that is the problem (apt-get install libcurl4-gnutls-dev to install it on ubuntu or add it to the PKGBUILD dependencies section) but i have no way of knowing if I don't see the full build log, not just parts of it.

May-21-20 22:45:51
I can't make it work.
Category: Workshops

Seems you did the make command in some other directory where there is no Makefile, or you did git clean and did not autoconf / configure again.

May-21-20 20:58:29
I can't make it work.
Category: Workshops

I need more of the output. Run with:
make -j8 > trace.txt 2>&1 and then upload trace.txt.

May-21-20 20:46:51
I can't make it work.
Category: Workshops

Your network seems to go down during the build when trying to fetch Modelica libraries from github, see:

Code:


error: RPC failed; curl 56 OpenSSL SSL_read: Connection timed out, errno 110
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
fatal: unable to access 'https://github.com/modelica/Modelica.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/modelica/Modelica.git/': Could not resolve host: github.com

Try with make -j4 or lower. How many cores your computer CPU has?
You will also need to install subversion to have svn as some Modelica libraries are checked out from svn repos.

May-16-20 20:57:32
Error while initializing

What OM version are you running?

Can you share the model? If you want to keep it private you can send it to us for debugging via email to OpenModelica@ida.liu.se and we will delete it after we find the issue.

May-14-20 22:25:35
Return a record from an external C funciton cal
Category: Programming

Why do you want to use records if you only have one value?

Anyhow, you might hit this bug:
https://trac.openmodelica.org/OpenModelica/ticket/5774
pointed out by (you also have an example there):
https://www.openmodelica.org/forum/defa … c-function

May-14-20 13:26:45
Error while initializing

Just edit the model text and change to:

Code:


Modelica.Fluid.Sources.FixedBoundary Sink(nPorts = 1, redeclare package Medium = Medium)

May-13-20 10:04:25
Error while initializing

passas wrote:


When simulating your model testje2, I have the scripting error:
Internal error: no tokens left to replace %s with.
Given message was: System.launchParallelTasks: Failed to create thread: %s

How to solve that problem.

Press on "S" to simulate the model and change "Number of Processors" to 1.

What computer do you have? How much RAM? What CPU? What OS: Windows? Linux? Mac?


Learn Modelica please:
https://mbe.modelica.university/

Complex is part of the MSL.
https://github.com/modelica/ModelicaSta … Complex.mo

Code:


Complex c[10];
// c[1] is the complex
// c[1].im is the im part
// c[1].re is the real part

May-07-20 09:01:56
ModelicaML isn't working anymore?

kamali wrote:


Hello every Body
I'm new to modelica. i try to install and use MDT  but i face many problems.
shall we use older version of eclipse?(i use 2019 version)

This is not about ModelicaML, however, I'll answer.
MDT doesn't work so well with Modelica projects (we mostly use it for compiler development with MetaModelica), I would suggest using OMEdit instead. Also we had no time to develop MDT further so there are still bugs and issues with it.

May-03-20 18:58:14
Installation from OM-v1.160-dev316-g3188ef6bb
May-02-20 14:31:35
Installation from OM-v1.160-dev316-g3188ef6bb

Ouch, there are plenty! I'll fix this.

Code:


adrpo33@ida-0030 MINGW64 /e/OMDev/tools/msys/mingw64/bin
$ /c/OMDev/bin/ntldd/mingw64/ntldd.exe -R libcurl-4.dll | grep -v WINDOWS | grep -v "not found"
        LIBEAY32.dll (0x0000000001310000)
        libidn-11.dll (0x00000000006f0000)
         libiconv-2.dll (0x0000000000f50000)
         libintl-8.dll (0x00000000001d0000)
        librtmp-1.dll (0x00000000001d0000)
         libgmp-10.dll (0x0000000000f50000)
         libgnutls-30.dll (0x0000000000f50000)
          libwinpthread-1.dll (0x0000000000020000)
          libp11-kit-0.dll (0x00000000006f0000)
           libffi-6.dll (0x0000000000020000)
          libtasn1-6.dll (0x00000000006f0000)
         libhogweed-4-1.dll (0x00000000006f0000)
         libnettle-6-1.dll (0x0000000001080000)
        libssh2-1.dll (0x00000000006f0000)
        SSLEAY32.dll (0x0000000000f50000)
        zlib1.dll (0x00000000006f0000)

May-01-20 23:51:22
Installation from OM-v1.160-dev316-g3188ef6bb

Yes, it seems we forgot to copy it as is now needed due to new functionality.
Copy libcurl-4.dll to:
C:\Program Files\OpenModelica1.16.0-dev-64bit\bin
until I will fix this properly in a new nightly.

Thanks for reporting this.

You can use Right Click->Duplicate. Sometimes it doesn't work fully, you might need to edit some component types to make it work.

Apr-24-20 19:25:19
Errors when trying to override start values

Did you by any chance have "Evaluate all parameters" checked in OMEdit->Tools->Option->Simulation?

What variability has component "controlValve.C1.P"? Is it parameter, constant or variable?

Apr-23-20 14:04:04
Model includes call to extern C function with dynamic link library which can export to FMU, but...
Category: Developer

The best solution would be to compile *all* the FMU dependencies as static libraries (if possible).
If is not possible, you can ask the people you send the FMU to to install the dependencies.

You should try to get rid of as many dependencies as possible, to get rid of libstdc++ use g++ to link and flags "-static-libstdc++".

As to the fact that platform dynamic does not change  -Wl,-Bstatic part to  -Wl,-Bdynamic this seems to be a bug. I will open a ticket about it.

For now I think you can just:

Code:


export MODELICAUSERCFLAGS=-Wl,-Bdynamic -lnmpc

before running OMEdit or omc to build the FMU (or add it to compiler flags in OMEdit).

You could also, after building the FMU, unzip it, use "ldd -r" on the generated .so file and then copy all the dependencies in the directory where the generated libnpmc.so is, the repack the zip into an FMU again. This way it should work to send it to somebody BUT it highly depends on how the FMI tool loads the FMU and what is the search path for the dependent .so files, some might add the path where the FMU is unpacked to the search others might not. For example see how windows loads dlls if the LOAD_WITH_ALTERED_SEARCH_PATH is given.

Apr-22-20 19:08:57
Model includes call to extern C function with dynamic link library which can export to FMU, but...
Category: Developer

What do you have set in the FMU export setting in OMEdit in Tools->Options->FMI: "Platforms"?
Is it static? Is it dynamic?

Note that if you have an .so which is used in the FMU you will need to copy that one manually inside the generated FMU.
Can you compile this library as a static library .a?

As far as I can see from these paths below it should find the "nmpc" library.

Code:


-Wl,-Bstatic
"-L/usr/bin/../lib/x86_64-linux-gnu/omc" -Wl,-rpath="/usr/bin/../lib/x86_64-linux-gnu/omc" "-L/usr/bin/../lib/"
-Wl,-rpath="/usr/bin/../lib/" "-L/home/johannes/.openmodelica/binaries/MPC" -Wl,-rpath="/home/johannes/.openmodelica/binaries/MPC"
"-L/home/johannes/01_cstr_introduction/models/MPC/Resources/Library/x86_64-linux"
-Wl,-rpath="/home/johannes/01_cstr_introduction/models/MPC/Resources/Library/x86_64-linux"
"-L/home/johannes/01_cstr_introduction/models/MPC/Resources/Library/linux64"
-Wl,-rpath="/home/johannes/01_cstr_introduction/models/MPC/Resources/Library/linux64" "
-L/home/johannes/01_cstr_introduction/models/MPC/Resources/Library"
-Wl,-rpath="/home/johannes/01_cstr_introduction/models/MPC/Resources/Library"
-lnmpc
-Wl,-Bdynamic

Probably it does find it, but because we force a static link for it via -Wl,-Bstatic it doesn't use it.

To fix this i suggest you try to make a static library as otherwise you will nee to copy *ALL* the dependent dlls (.so) inside the generated FMU.
If you don't do that and sen the FMU to somebody they will not be able to use it if they don't have the same .so installed.

Apr-19-20 04:46:04
could not find DLL (built using VS 2015) in modelica

This seems like a bug but I'm not sure.
The Modelica Specification say:
"The Library name and the LibraryDirectory name in the function annotation are mapped to a linkage directive in a compiler-dependent way thereby selecting the object library suited for the respective computer platform."
It doesn't say anything about what to do when running the executable but I guess these paths should be added to the PATH?

For now, to fix this, I guess you need to put in the PATH environment variable the directory where the DLL is.
I will open a bug about this to clarify what to do.

You can use any algorithm section in a function with no issues, including loops.

You cannot have an expression on the left hand side in algorithm sections! Only:

Code:


// component reference on the left hand side is fine
a := some_expression;
// this is not allowed by the grammar:
a + b := c:

In you case in while you have:

Code:


x ^ 2 + y ^ 2 := L ^ 2;

which is not allowed, you can write that as:

Code:


x := sqrt(L ^ 2 -  y ^ 2);

As far as I know, you don't, but that depends on your model. In the MSL they are using "acceptable" values in types and then use these types.

Modelica tools will prioritize start values that are set via modifications close to the top level in the instance hierarchy.
So, if you have issues set the start values via variable modifications in your top model.
Also, most tools can tell you which variables are used as iteration variabels via some flags.

To make matters worse tools use different variables as iteration variables so models working in one tool (because of proper start values) will not initialize in another.

OpenModelica 1.14.1 and up has the new frontend on by default for both OMEdit API and code generation.

To remove the usage of the new frontend for OMEdit API do:
    OMEdit->Tools->Options->Simulation
    unclick: Enable new frontend use the OMC API (faster GUI response)

If you have issues with model compilation, you can use the old frontend for that as well (might work better or not)
    OMEdit->Tools->Options->Simulation
    click: Enable old frontend for code generation

   

This is not possible on Windows. You need Linux with cross compilers installed.
Either use WSL Windows subsystem for Linux or our Vitual Machine.

Mar-24-20 16:12:24
Category: Developer

Do you have file
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Library\win64\libModelicaArduino.lib
after running the cmd commands?

Hm, after looking at your message a bit better it seems you have omlibrary\Arduino\ instead of omlibrary\Arduino 0.1.0?!
Did you downloaded the library yourself? If so, you will need to run the commands in for omlibrary\Arduino\, change:

Code:


cd "lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino"

to

Code:


cd "lib\omlibrary\Arduino\Resources\Source\Arduino"

in the script above.

Also, you need to edit lib\omlibrary\Arduino\Resources\Source\Arduino/build_mingw.bat instead of the one in lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino.

Mar-23-20 16:21:07
Category: Developer

You need to build the library source code into ModelicaArduino.lib using the GCC in the OpenModelica installer. To do that:

It seems the buld_mingw.bat script in directory:
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino
is missing some cpp files. You will need to edit it and make it look like this:

Code:


gcc -c -std=c++11 -I. -I"..\..\Include" -I"..\..\Sketches" -D"ARDUINO=100" PID_v1.cpp Servo.cpp ModelicaArduino.cpp Print.cpp Sketch.cpp SoftArduino.cpp WMath.cpp ModelicaUtilities.cpp
ar rcs ..\..\Library\win64\ModelicaArduino.lib *.o
ar rcs ..\..\Library\win64\libModelicaArduino.lib *.o

Then do Windows Start->cmd.exe and type in:

Code:


cd /D %OPENMODELICAHOME%
REM convert from long path %OPENMODELICAHOME% to short path %OM%
set OM=
for %A in ("%OPENMODELICAHOME%") do SET OM=%~sA
set PATH=%OM%\tools\msys\mingw64\bin\;%PATH%
cd "lib\omlibrary\Arduino 0.1.0\Resources\Source\Arduino"
call build_mingw.bat

This will create libModelicaArduino.lib in this directory:
%OPENMODELICAHOME%lib\omlibrary\Arduino 0.1.0\Resources\Library\win64\

Then try to build your model again.

If "n" is a parameter then it should work fine and this seems like a bug.
We should do loop unroll to generated all the statements but maybe the evaluation of the if condition during that is failing.

As a workaround until we fix this, you can remove the if statement and connect the cell to itself as connect(A, A) is ignored and a warning is given.


I guess that should be:

Code:


for i in 1: N-1 loop
  connect(const[i].y, source_T_cell[i].Temperature); // note that you have i instead of N
end for;

You could also do it via he slice operator and without the for loop:

Code:


connect(const[1:N-1].y, source_T_cell[1:N-1].Temperature);

Not sure if you are saying that you don't know how to instantiate the model or if the total model after edit and save is not loading.
If the file is not loading if OMShell probably you have made a mistake (syntax or semantic). Do you get true from loadFile?
The file will not load in OMEdit as OMEdit wants to just one class per file.

Anyhow, to instantiate the model in OMShell, just type:
instantiateModel(Path.To.Your.Model.Name);

Code:


        if initType == .Modelica.Blocks.Types.Init.SteadyState then
          der(y) = 0;
        elseif initType == .Modelica.Blocks.Types.Init.InitialState or initType == .Modelica.Blocks.Types.Init.InitialOutput then
          y = y_start;
        end if;

I guess it might work to translate it to this:

Code:


        0 = if initType == .Modelica.Blocks.Types.Init.SteadyState then
          der(y)
        elseif initType == .Modelica.Blocks.Types.Init.InitialState or initType == .Modelica.Blocks.Types.Init.InitialOutput then
          y_start - y
        else 0;

What kind of optimization software are you using?

I guess the easiest would be do save the model using save total model in OMEdit.
Then edit the function in the new file to change the if equation to an if expression and then instantiate the model again.

Mar-14-20 14:21:14
ModelicaML isn't working anymore?

You might try with an older eclipse. I have one here, hopefully it will work for you:
https://www.ida.liu.se/~adrpo33/ModelicaML/

If you know Java and Eclipse you can try to update the existing ModelicaML to work with the latest Acceleo.
You can find the source code here:
https://github.com/OpenModelica/MDT

That is because we do not have support for redeclares in the GUI yet.
Is work in progress to be part of 1.15 soon.

Instead of this:

Code:


#!/bin/bash
rm *.o;
rm *.c;
rm *.h;

do:

Code:


system("rm -f *.o *.c *.h");

See here: https://stackoverflow.com/questions/569 … stem-codec
maybe this is your issue.

I wrote OMCallPython.h myself, you can change it as you want to add more functionality if you need to communicate data between python and Modelica,
see 1.3 from: https://docs.python.org/3/extending/embedding.html


I made a small package to call python from OM. See here:
https://github.com/adrpo/OMCallPython/

OpenModelica 1.14.1 has the new front-end on by default in OMEdit. It seems that is the issue.
You can select the old frontend via: Tools->Options->Simulation->Enable old frontend for code generation.

This is the log when running with the new front-end: https://libraries.openmodelica.org/bran … System.err

You shouldn't need to load the FMU dlls (or so) at every step. You could just use the same instance and run different simulations with if you want as they are thread safe. You can fmiReset it if is needed.

There are several targets for the FMU, you can see in OMEdit->Tools->Options->FMI
- static, all stuff is linked in, you can send the FMU to somebody and it will work
- dynamic, mostly no stuff linked in, the person you send the FMU to needs an OpenModelica installation and the libraries from it in the PATH (or LD_LIBRARY_PATH).
Most likely dynamic is smaller but it has the mentioned restrictions.

If your tool supports ME then you could also use the CPP runtime (OMEdit->Tools->Options->Simulation->choose "Cpp"). That would probably make a smaller FMU, but it might not work for all the models for which the C runtime work.

If comma is used as a decimal separator the FMU loading will crash. Set locale to en_US should fix it.

Code:


import locale
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

Jan-14-20 10:55:54
How to use debug flags like bltdump in the openmodelica 1.14 version

Ouch. This seems to be a bug, -d=bltdump doesn't seem to produce output anymore, doesn't matter if is the new or the old front-end. I will check more.
Made a ticket for it: https://trac.openmodelica.org/OpenModelica/ticket/5787

Jan-13-20 18:11:32
How to use debug flags like bltdump in the openmodelica 1.14 version

Can you give more detail as what doesn't work as expected? Also, there is no space after the comma in:

Code:

–d=newInst,bltdump

.

Jan-10-20 10:51:29
How to use debug flags like bltdump in the openmodelica 1.14 version

To activate the new front-end you have:

Code:


-d=newInst

You can add more after it like this:

Code:


-d=newInst,bltdump,execstat

Jan-04-20 15:55:35
how to fix the problem

You need a 64bit computer with much more memory. It depends on how big the model is but I guess OMEdit needs 1-2GB to generate the C code and then we start GCC on several threads (as many cores as your computer has) to build the C code into an executable and this also takes some memory.
You can try to set: Number of Processors: in Simulation Setup to 1 to restrict how many GCCs are launched.

You can use setParameterValue or setComponentModifierValue to change the parameter in a model before building. See an example below.

Code:


loadString("
model M
  parameter Real a = 1;
  parameter Real x[2,2];
  parameter Real y[2,2];
end M;"); getErrorString();

list(M); getErrorString();
// use setParameterValue
setParameterValue(M, x, fill(a, 2, 2)); getErrorString();
list(M); getErrorString();

// use setComponentModifierValue
setComponentModifierValue(M, y, $Code(= fill(a, size(x, 1), size(x, 2)))); getErrorString();
list(M); getErrorString();
setComponentModifierValue(M, y.start, $Code(= fill(a, size(x, 1), size(x, 2)))); getErrorString();
list(M); getErrorString();

instantiateModel(M); getErrorString();

You shouldn't need to download MSL (Modelica Standard Library 3.2.3) from github.
Just install it for OpenModelica:

Code:


sudo apt-get install omlib-modelica-3.2.3

Is actually recommended to use this version as we have our own patches to it compared to the one from gihub.

What version of OpenModelica do you have?

Code:


omc --version

To update OpenModelica just do the usual:

Code:


apt-get update
apt-get upgrade

will update to the new OpenModelica release 1.14 for you if you have added OpenModelica to your apt sources.

See here how:
https://openmodelica.org/download/download-linux

I have remade the VMs. I also tested the 1.14 one and it seems OK.

Ouch, let me see if I can fix it.

Dec-05-19 15:53:03
Print only desired text in command prompt

The script echo.mos:

Code:


echo(false); getErrorString();
print("Some string\n"); getErrorString();
print("Some real:" + String(0.5)+"\n"); getErrorString();
print("Some integer:" + String(5)+"\n"); getErrorString();

The result

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting
$ ~/dev/OpenModelica/build/bin/omc echo.mos
Some string
Some real:0.5
Some integer:5

Dec-05-19 15:47:23
Category: Programming

For that you don't need any weird stuff, you do:

Code:


parameter Integer ni=3;
parameter Integer nj=3;
parameter Integer nk=3;
parameter Real Tc_start=50;
Real Tc[ni,nj,nk](each start=Tc_start);

Dec-05-19 10:59:07
Loop over multiple commands with a for loop in a MOS script

Yeah, that's true, the for loop commands do not output as the top level ones. I think this is a bug and we should fix it.

Dec-05-19 10:40:59
Loop over multiple commands with a for loop in a MOS script

Yes is possible, you would do it as in a Modelica algorithm section.

Code:


for iterator in range loop
  command1;
  command2;
  command3;
end for;

For some examples see:
https://openmodelica.org/forum/default- … r-of-ports
https://openmodelica.org/forum/default- … eter-sweep
For more advanced examples see:
https://github.com/OpenModelica/OpenMod … ateDoc.mos
https://github.com/OpenModelica/OpenMod … ursive.mos
and I guess there are many more examples around.

Nov-28-19 13:01:34
Category: Programming

Yes, these are mostly all OpenModelica specific, i think loadFile is available in Dymola as well.
What I show you was a prof of concept done using OpenModelica scripting, you need to find from Dymola's manual and documentation if this is possible to do and how.

Nov-27-19 22:30:25
Category: Programming

I guess what you want is meta-programming. Write some scripting that builds the model for you.
As far as I know Dymola has a library for this called ModelManangement but I'm not really sure it it can be used to add new connections to classes.

I think the easiest would be to just generate the model file from some other language like python.

You can also do this in OpenModelica with a bit of scripting: buildModel.mos

Code:


// you can also load this via loadFile("File.mo"); if you already have the skeleton
loadString("
model TestConn
  connector C
    Real T;
  end C;
  model M
    C c_1;
    C c_2;
    C c_3;
    C c_4;
  end M;
  M m;
  Real Txn[4,1];
  equation
end TestConn;
"); // load the model skeleton

n := 4;
// build the connect commands as strings
connectStrings := "";
for i in 1:n loop
  connectStrings := connectStrings + "addConnection(m.c_"+String(i)+".T, Txn["+ String(i) + ",1], TestConn); getErrorString();\n";
end for;

// write the connect commands to a new .mos script
writeFile("addConnects.mos", connectStrings); getErrorString();
// run the script with the connect commands to be added to the model
runScript("addConnects.mos"); getErrorString();

str := list(TestConn); getErrorString();
"write the model file";
writeFile("TestConn.mo", str);
"--- read the model file ---";
readFile("TestConn.mo");

output of running this via omc:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/
$ ~/dev/OpenModelica/build/bin/omc buildModel.mos
true
4
""

true
""
"Ok
\"\"
Ok
\"\"
Ok
\"\"
Ok
\"\"
"
""
"model TestConn
  connector C
    Real T;
  end C;

  model M
    C c_1;
    C c_2;
    C c_3;
    C c_4;
  end M;

  M m;
  Real Txn[4, 1];
equation
  connect(m.c_1.T, Txn[1, 1]);
  connect(m.c_2.T, Txn[2, 1]);
  connect(m.c_3.T, Txn[3, 1]);
  connect(m.c_4.T, Txn[4, 1]);
end TestConn;"
""
"write the model file"
true
"--- read the model file ---"
"model TestConn
  connector C
    Real T;
  end C;

  model M
    C c_1;
    C c_2;
    C c_3;
    C c_4;
  end M;

  M m;
  Real Txn[4, 1];
equation
  connect(m.c_1.T, Txn[1, 1]);
  connect(m.c_2.T, Txn[2, 1]);
  connect(m.c_3.T, Txn[3, 1]);
  connect(m.c_4.T, Txn[4, 1]);
end TestConn;"

Nov-25-19 19:04:47
Category: Developer

This is a known bug: https://trac.openmodelica.org/OpenModelica/ticket/5263
and we don't have a fix for it yet. On Windows we compile a static version of ModelicaExternalC, but not on Linux.
So if you have tables in your model, you will have this issue.

You could try to select the C++ runtime, maybe that one can compile a static version of the FMU without any dependencies but it might not work.

This is now in the nightly-builds (from tomorrow) and in the upcoming 1.14.0-dev.beta3 and the final 1.14.0.

I implemented this now, you can use both -override and -overrideFile and you get a warning if the same variable is used again.

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cat override.txt
b=5
c=6

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -override=stopTime=1,b=1 -overrideFile=override.txt -lv=LOG_ALL | grep overrid
LOG_SOLVER        | info    | using -override=stopTime=1,b=1 and -overrideFile=override.txt
LOG_SOLVER        | info    | read override values from file: override.txt
LOG_SOLVER        | info    | -override=stopTime=1,b=1
LOG_SOLVER        | info    | -overrideFile=b=5,c=6
stdout            | warning | You are overriding variable: b=1 again with b=5.
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Thanks for your input, I will implement it as you suggested, it sounds good. I will also put your text in the Trac so we can follow it up there as well.

I think it should be an error if they set the same variable. Then we do not need to think about precedence.

I tested with OMEdit and it doesn't work because OMEdit already uses -override and you cannot combine -override and -overideFile.

Code:


C:/temp/TestOverride/TestOverride.exe -port=51307 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/temp/TestOverride/TestOverride_res.mat -w -lv=LOG_SOLVER,LOG_STATS -overrideFile=c:/home/adrpo33/dev/override.txt -inputPath=C:/temp/TestOverride -outputPath=C:/temp/TestOverride

This is a bug, I think we should solve it by allowing -overrideFile even if -override is already present.
I opened a ticket about it: https://trac.openmodelica.org/OpenModelica/ticket/5696



The model:

Code:


model TestOverride
  parameter Real a = 1;
  parameter Real b = 2;
  parameter Real c = 3;
  parameter Real d = 3;
  Real x(start=a, fixed=true);
equation
  der(x) = b*c*d*x;
end TestOverride;

The script to build the model:

Code:


loadFile("TestOverride.mo"); getErrorString();
buildModel(TestOverride); getErrorString();

Building the model:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ~/dev/OpenModelica/build/bin/omc -d=initialization t.mos
true
""
{"C:/home/adrpo33/dev/OMTesting/override/TestOverride","TestOverride_init.xml"}
""

Running some override tests using command line -override or -overrideFile
from the mingw64 terminal:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -override=b=5 -lv=LOG_ALL | grep override
LOG_SOLVER        | info    | read override values: b=5
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override done!

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cat > override.txt
b=5
c=6

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -overrideFile=override.txt -lv=LOG_ALL | grep override
LOG_SOLVER        | info    | read override values from file: override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Trying from some other directory:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ cp override.txt ../../.

adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/override
$ ./TestOverride.exe -lv=LOG_ALL -overrideFile=C:/home/adrpo33/dev/override.txt  | grep override
LOG_SOLVER        | info    | read override values from file: C:/home/adrpo33/dev/override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!

Trying from Windows Command Line: cmd.exe

Code:


C:\home\adrpo33\dev\OMTesting\override>.\TestOverride.exe -lv=LOG_ALL -overrideFile=C:/home/adrpo33/dev/override.txt | more
LOG_SOLVER        | info    | read override values from file: C:/home/adrpo33/dev/override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!
LOG_SIMULATION    | info    | read all the DefaultExperiment values:
|                 | |       | | startTime = 0
|                 | |       | | stopTime = 1
|                 | |       | | stepSize = 0.002
|                 | |       | | tolerance = 1e-006
|                 | |       | | solver method: dassl
|                 | |       | | output format: mat
|                 | |       | | variable filter: .*
|                 | |       | | OPENMODELICAHOME: c:/home/adrpo33/dev/OpenModelica/build
LOG_DEBUG         | info    | read xml file for real states
|                 | |       | | Real x(start=0, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real state derivatives
|                 | |       | | Real der(x)(start=0, fixed=false, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real algebraics
LOG_DEBUG         | info    | read xml file for integer variables
LOG_DEBUG         | info    | read xml file for boolean variables
LOG_DEBUG         | info    | read xml file for string variables
LOG_DEBUG         | info    | read xml file for real parameters
|                 | |       | | Real a(start=1, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real b(start=5, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real c(start=6, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real d(start=3, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for integer parameters
LOG_DEBUG         | info    | read xml file for boolean parameters
LOG_DEBUG         | info    | read xml file for string parameters
LOG_DEBUG         | info    | read xml file for real alias vars
LOG_DEBUG         | info    | read xml file for integer alias vars
LOG_DEBUG         | info    | read xml file for boolean alias vars
-- More  --

Trying with backwards slashes:

Code:


C:\home\adrpo33\dev\OMTesting\override>.\TestOverride.exe -lv=LOG_ALL -overrideFile=C:\home\adrpo33\dev\override.txt | more
LOG_SOLVER        | info    | read override values from file: C:\home\adrpo33\dev\override.txt
LOG_SOLVER        | info    | read override values: b=5,c=6
LOG_SOLVER        | info    | override b = 5
LOG_SOLVER        | info    | override c = 6
LOG_SOLVER        | info    | override done!
LOG_SIMULATION    | info    | read all the DefaultExperiment values:
|                 | |       | | startTime = 0
|                 | |       | | stopTime = 1
|                 | |       | | stepSize = 0.002
|                 | |       | | tolerance = 1e-006
|                 | |       | | solver method: dassl
|                 | |       | | output format: mat
|                 | |       | | variable filter: .*
|                 | |       | | OPENMODELICAHOME: c:/home/adrpo33/dev/OpenModelica/build
LOG_DEBUG         | info    | read xml file for real states
|                 | |       | | Real x(start=0, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real state derivatives
|                 | |       | | Real der(x)(start=0, fixed=false, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for real algebraics
LOG_DEBUG         | info    | read xml file for integer variables
LOG_DEBUG         | info    | read xml file for boolean variables
LOG_DEBUG         | info    | read xml file for string variables
LOG_DEBUG         | info    | read xml file for real parameters
|                 | |       | | Real a(start=1, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real b(start=5, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real c(start=6, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
|                 | |       | | Real d(start=3, fixed=true, {nominal=1}, min=-1.79769e+308, max=1.79769e+308)
LOG_DEBUG         | info    | read xml file for integer parameters
LOG_DEBUG         | info    | read xml file for boolean parameters
LOG_DEBUG         | info    | read xml file for string parameters
LOG_DEBUG         | info    | read xml file for real alias vars
LOG_DEBUG         | info    | read xml file for integer alias vars
LOG_DEBUG         | info    | read xml file for boolean alias vars
-- More  --

All seems to work for me, but I haven't tried yet from OMEdit, I will do that later today.

It should just work with "/" alternatively with "\\" for the path separator and with or without quotes for the whole path.

The syntax of inside of the file is just:
variable_name1=variable_value1
variable_name2=variable_value2


You could run with -lv=LOG_ALL to see what error are you getting.

Note that there are structural parameters evaluated during compilation time and you cannot override those. In this case you should get a warning.

I will give it a try myself and see if i can find any issues. I implemented this, and last time i checked it it worked fine.

Nov-13-19 09:21:27
Using OMPython ModelicaSystem to generate an outfile that avoids double entries at the same time...

I had a quick look at the python code and we don't support this yet.

I guess one could add a new constructor for simulate that supports named argument "simflags" and all the other options we have in the OMC simulate command:
https://build.openmodelica.org/Document … ulate.html

I will see if Arun has time to fix this.

Nov-13-19 08:34:31
please help why I see this command line error

The problem is that you're trying to load .txt models using loadFile. Command loadFile should only be used for .mo files.
Also, the System class doesn't seem to be in the Modelica file you loaded.

Oct-15-19 11:10:47
Category: Developer

This means Tm is a parameter and T4 or T5 are variables.
Depending on what you want to model you can make T4 and T5 parameters or Tm a variable.

I think the logs are send to /dev/null by default. You can specify a log file in the system command:
https://build.openmodelica.org/Document … ystem.html

Code:


system("ShoreBasedTestSystem.exe -nls=hybrid -lv=LOG_EVENTS,LOG_NLS_JAC", "LogFile.log");

Also, is strange that backward slash works (without the need to double it \\), please use forward slash instead for directories:
C:\Users\jcrabtree\Desktop\ShoreBasedDemonstratorTraining\High Fidelity\Run ->
C:/Users/jcrabtree/Desktop/ShoreBasedDemonstratorTraining/High Fidelity/Run

You can also just run build model once and then use -r to generate result files with new names.




This is most likely a bug. I made a ticket for it and we will fix it: https://trac.openmodelica.org/OpenModelica/ticket/5616

You can fix this by using:

Code:


A:=A+sum(test[i].Tc);

in Test22.

This is a  known bug (https://trac.openmodelica.org/OpenModelica/ticket/2858) that was fixed in the new front-end. Please use the latest nightly-build:
https://build.openmodelica.org/omc/buil … ly-builds/

Code:


// t.mos
loadFile("Structure.mo"); getErrorString();
simulate(Structure.Test1); getErrorString();
val(A, 1);
simulate(Structure.Test2); getErrorString();
val(A, 1);
simulate(Structure.Test3); getErrorString();
val(A, 1);

With current front-end:

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/iteration
$ ~/dev/OpenModelica/build/bin/omc t.mos
true
""
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test1_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test1', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0288302,
    timeBackend = 0.0440066,
    timeSimCode = 0.0084861,
    timeTemplates = 0.0655039,
    timeCompile = 12.860871,
    timeSimulation = 0.53805,
    timeTotal = 13.548594
end SimulationResult;
""
15.0
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test2_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test2', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0099308,
    timeBackend = 0.0031456,
    timeSimCode = 0.0007796,
    timeTemplates = 0.0563182,
    timeCompile = 12.5935838,
    timeSimulation = 0.4877127,
    timeTotal = 13.1526335
end SimulationResult;
""
10.0
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test3_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test3', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0203584,
    timeBackend = 0.0046265,
    timeSimCode = 0.0013041,
    timeTemplates = 0.0546605,
    timeCompile = 13.1451636,
    timeSimulation = 0.5539768000000001,
    timeTotal = 13.7813722
end SimulationResult;
""
10.0

With new front-end: -d=newInst

Code:


adrpo33@ida-0030 MINGW64 /c/home/adrpo33/dev/OMTesting/iteration
$ time ~/dev/OpenModelica/build/bin/omc -d=newInst t.mos
true
""
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test1_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test1', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0131841,
    timeBackend = 0.0043454,
    timeSimCode = 0.0012549,
    timeTemplates = 0.0418104,
    timeCompile = 10.5543462,
    timeSimulation = 0.5015408,
    timeTotal = 11.1178179
end SimulationResult;
""
15.0
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test2_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test2', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0012632,
    timeBackend = 0.0126055,
    timeSimCode = 0.0008018,
    timeTemplates = 0.0412061,
    timeCompile = 10.63316,
    timeSimulation = 0.5010813,
    timeTotal = 11.1909594
end SimulationResult;
""
15.0
record SimulationResult
    resultFile = "C:/home/adrpo33/dev/OMTesting/iteration/Structure.Test3_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'Structure.Test3', optio                                                ns = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
    messages = "LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.
",
    timeFrontend = 0.0043822,
    timeBackend = 0.0066643,
    timeSimCode = 0.0017293,
    timeTemplates = 0.0877218,
    timeCompile = 10.6279343,
    timeSimulation = 0.5973836,
    timeTotal = 11.326688
end SimulationResult;
""
15.0

Yes, we are only building new nightly builds if there are changes in the github repository.

Jul-18-19 14:41:35
Error when I try to simulate the model wih the standard values.

This model seems to work fine with 1.13:
https://libraries.openmodelica.org/bran … ysPro.html
and 1.14:
https://libraries.openmodelica.org/bran … ysPro.html

Do you have some special flags in OMEdit?
Do you have your own model that fails?

You could try the nightly builds:
https://build.openmodelica.org/omc/buil … ly-builds/

Cheers,
Adrian Pop//

Jul-02-19 10:27:50
I'm trying to allocate two large arrays that will be used as parameters within a model. The...
Category: Programming

This is most likely a bug. I opened a ticket about it:
https://trac.openmodelica.org/OpenModelica/ticket/5559

I suggest you use the latest nighlty-build and activate the new front-end:
https://build.openmodelica.org/omc/buil … ly-builds/

Buildings.Fluid.Boilers.Examples.BoilerPolynomial works with the new front-end but doesn't work with the current one:
The coverage of buildings with the new front-end is here:
https://libraries.openmodelica.org/bran … atest.html
The coverage of buildings with the current front-end is here:
https://libraries.openmodelica.org/bran … atest.html

To activate the new front-end you go in OMEdit->Tools->Options->Simulation->Additional Translation Flags: and add newInst to the existing flags or if none there just say: -d=newInst

Hi,

We tried to fix a bug (https://trac.openmodelica.org/OpenModelica/ticket/4504)
that did not allowed OpenModelica to be installed in C:\Program Files\OpenModelica
but it seems is only partially fixed.

Until we completely fix this issue, you need to uninstall OpenModelica and install it in a directory without a space, such as:
C:\OpenModelica\

Then it should work fine to build and simulate models.

Cheers,
Adrian Pop/

May-19-19 11:22:28
passing 'void *' to parameter of incompatible type 'modelica_real'

This is an issue with the current front-end. I suggest you use the latest nightly-build:
https://build.openmodelica.org/omc/buil … ly-builds/
and switch on the new front-end: Tools->Options->Simulation->Additional Translation flags: -d=initialization,newInst

You also need to restart OMEdit after setting the flags!

Hm, i will need to check if we put the entire library in the resource folder if is loaded into OMEdit, it might be that we do, but that seems like an overkill and we should change it.

If you use in Modelica URIs such as modelica://path/to/file.txt then the generated FMU will include the file.txt in the resource directory.

If you use the direct path to file then the FMU will not have that file included in the resource directory and it will read it from that local path. Note that in this case, if you send the FMU to somebody else, they will not have access to file.txt.

You can also include the table directly in the Modelica code but that might slow down the compilation (depending on how big the table is) and make the FMU bigger.

The solution above is fine but you can also drag and drop in your top model Modelica.Blocks.Interfaces.RealInput for input and Modelica.Blocks.Interfaces.RealOutput for output, then connect them to what you want in your model.

Thank you for your kind words. We're really sorry you got forced to use our tool. We'll go right ahead and remove it from the internet.

Feb-20-19 10:58:36
Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!

Follow:
https://trac.openmodelica.org/OpenModelica/ticket/5349
Please don't open both a bug ticket and a forum post. One of them is enough.

This is a bug. We will continue the discussions on the ticket you opened:
https://trac.openmodelica.org/OpenModelica/ticket/5340

Feb-06-19 07:40:18
Is it possible to open Dymola-encrypted models or commercial libraries with OpenModelica ?

Hi,

The answer to this is a bit complicated.
By default we cannot open any encrypted commercial libraries.

However, we do have a version of OpenModelica with encryption (for OSMC members) and library or model developers can use it to encrypt their models or libraries.
So, if library providers want to distribute a version of their encrypted libraries that can be used with OpenModelica, that is possible, but is not something we can push for.

Cheers,
Adrian Pop/


This modification is wrong:

Code:


MyMedium = Modelica.Media.Air.SimpleAir

It says that a variable MyMedium should be set to variable Modelica.Media.Air.SimpleAir.
Modelica.Media.Air.SimpleAir exists, but as a class, not a variable.
You cannot set replaceable classes or components like that.
Also note that MyMedium does not exist in Compressor. You should redeclare Medium.

If you want a redeclare of a class, then you need to use this syntax:

Code:


redeclare package Medium = Modelica.Media.Air.SimpleAir

Show me the entire model again.

I guess something like this will work:

Code:


ThermoPower.Gas.Compressor compressor1(redeclare package Medium = Modelica.Media.Air.SimpleAir, Ndesign = 150, Table = ThermoPower.Choices.TurboMachinery.TableTypes.matrix, Tdes_in = 300, allowFlowReversal = false, pout(start = 100));

There is a small client library here that you can inspire from:
https://github.com/OpenModelica/OMCompi … pp/omcCAPI

Can you post your full model? Otherwise is hard to guess what is wrong.
If the model is not public, you can send it to us at OpenModelica @ ida.liu.se and we will delete it after finding the issue.

You need to use \\ or / instead of \.

Yes. Sometimes it does happen. We are working on making it more robust and any bug reporting helps.

When is crashing it should ask you to send the logs to us. If it doesn't, you can just zip all files:
%TEMP%/OpenModelica/OMEdit/omedit*log (this is on Windows, on Linux they are in /tmp/username/OpenModelica/OMEdit).
and send them to openmodelica @ ida.liu.se.
Alternatively you can open a ticket on https://trac.openmodelica.org/OpenModelica (NewTicket) and attach the logs there.

You can report bugs here:
https://trac.openmodelica.org/OpenModelica/
click on New Ticket

The new front-end is work in progress to replace the current one. The front-end handles instantiation of models (removal of structure, applications of modifiers, inheritance, etc until you get to a flat DAE system). We also use the front-end to do query operations on the Modelica code such as getting information about annotations, etc. You can find some information here:
https://trac.openmodelica.org/OpenModelica/ticket/4138

In the case of your annotation, because you use constants declared in the model, an instantiation of the model is needed to evaluate the annotation. It seems that the current front-end somehow misses the modification in the extends and then you end up with the one declared in the model.

This should work, is a bug. It should be fixed when we start using the new front-end.

Oct-26-18 11:46:15
Pyfmi can't decode FMU

Yes. I installed PyFMI via conda and tested with an OM FMU.
I get crashes in the sundials solver on both Windows and Linux and could not find out why yet.
The FMUs work fine in fmiChecker but they crash in python.
I suspect it might have something to do with stack alignment.
I even ran this in valgrind in Linux but got no clear idea what the problem is.
I will continue debugging this.

As far as I can see from the OpenModelica v1.12 coverage here:
https://libraries.openmodelica.org/bran … 3.2.2.html
the PumpingSystem and HeatingSystem are failing.
I'm not sure if these models actually worked 1.12 or if they got broken by a library change.

You could use the nightly builds where these models are working:
For windows you can get them here:
https://build.openmodelica.org/omc/buil … ly-builds/

What OpenModelica version do you have? What Modelica Standard Library version do you use?
As far as I can see from our coverage testing:
https://libraries.openmodelica.org/bran … 3.2.2.html
This particular model works at least in versioni 3.2.2
Have you tried a restart of your computer?
Do you have some special flags in OMEdit?

Oct-17-18 15:16:04
Pyfmi can't decode FMU

Thanks for the info. I'll give it a try on my system, see how it goes.

Oct-17-18 13:53:58
Pyfmi can't decode FMU

Ok. The problem might be in PyFMI while loading the FMU.
More questions:
What system do you have? 32bit? 64bit?
How did you installed PyFMI and FMIL?

Oct-17-18 10:45:26
Pyfmi can't decode FMU

Is this on Windows or Linux? What do you mean by decoding the FMU?

Oct-16-18 20:46:07
How it works, how integrate in a infinite loop? FMU2.0

As far as I know you can simulate forever, for FMI CS, just call doStep with currentTime+stepSize. I guess the boundary is DBL_MAX (the max for double).

Oct-16-18 19:52:22
How it works, how integrate in a infinite loop? FMU2.0

You can have a look at fmuChecker:
https://github.com/modelica-tools/FMUCo … r/src/FMI2
which uses (as far as I know) FMIL library to load/simulate/check an FMU.

It seems you cannot write the executable in the %TEMP% folder, so it looks like an antivirus issue.
See if you can add some exception to your antivirus to let you write executable files to:
%TEMP%/OpenModelica/OMEdit

You could also try to change the working directory in OMEdit to c:\temp or other directory so that is not using the system %TEMP%.

Aug-24-18 11:43:58
After sucessful autoconf does make lead to the below error message
Category: Developer

The error is not here, we need the entire log just do:
make > trace.txt 2>&1
in the OpenModelica root directory and put the log here or send it via email to: OpenModelica @ ida.liu.se

I wouldn't say so. Not yet. While we are working on supporting requirements and automatic testing via simulation of these requirements is not so advanced yet.

Yes, depending on the library some models might open very slowly or even crash OMEdit.
In general models with a lot of redeclares have that issue.

We are working on a new front-end that should fix (some of) these issues, hopefully should be available in a couple of months.
You could already try it on your model from command line using -d=newInst, it might work better on your model (or not).

Jul-07-18 00:00:39
Directional derivatives error (FMU for model exchange)

Tool->Options->Simulation->OMC Flags. Add it to the flags there.

Jun-22-18 14:26:37
Performance regression in FMU's generated in OM 1.13
Category: Developer

We had not looked at the performance
difference with FMI between OM versions.
We have tests that check FMI export here:
https://libraries.openmodelica.org/bran … w-fmi.html
and at least we support much more models than before.

Would be good to have access to your Modelica code
so we can debug the performance issues. It might be
a corner case.

Jun-15-18 06:50:31
Set timeout from the GUI

Ah, you mean simulation flags. Then yes, you use -alarm=time or -alarm time.

See here: https://www.openmodelica.org/doc/OpenMo … flags.html

Jun-14-18 10:08:20
Set timeout from the GUI

Alarm should not work via OMEdit, it would mean killing the OMEdit process. It should only works via omc command line.

May-22-18 20:10:25
Is the openmodelica plugin for Eclipse still actively maintained ?

You can use it for text editing, should work fine but if you want graphical composition of models and simulation you should use OMEdit.

May-22-18 15:37:15
Is the openmodelica plugin for Eclipse still actively maintained ?

Eclipse MDT is kept working but not actively developed any more.
After you add the update site, you need to un-select "Group items by category" to show the latest version. See here:
https://trac.openmodelica.org/documents … ingMDT.pdf

You can also duplicate a class that is read only into one that you can edit and save.

Mar-10-18 08:07:48
e.g. parameter SI.HeatFlowRate Q_ST=5 "Heat transfer rate"...
Category: Programming

You know that Modelica supports quoted variables, maybe you can use those. Of course, this would make the model not so pretty to look at so a solution like you propose would work better but it needs to be implemented.

Code:


parameter SI.HeatFlowRate 'Q\textsubscript{ST}' = 5 "Heat transfer rate";

I changed now in the settings so that the system does not send the password via email again.

It should work to compile with GCC, it might even be possible to import it and run it in Simulink.
Yes, unfortunately for MSVC we only compile the 32bit dependencies and the FMU.
We should add support for 64bit MSVC. I opened a ticket about it:
https://trac.openmodelica.org/OpenModelica/ticket/4738
and we will try to fix this as soon as possible.

You can't install the 64bit OpenModelica? That would produce a 64bit FMU.

Jan-15-18 14:29:50
Category: Developer

You can find out if is a serial / parallel connection by analyzing the connections you have in a model.
So basically this is parallel:
connect(resistor1.n, a);
connect(resistor2.n, a);
connect(resistor1.p, b);
connect(resistor2.p, b);

But I guess you need to build a graph of the connections and analyze that.

See eclipse.ini where eclipse.exe is, i think you can change the path in there.
Have a look here: https://wiki.eclipse.org/Eclipse.ini#-v … ws_Example

Oct-17-17 15:19:44
Compressor model: want to inverse the model.
Category: Programming

Unfortunately not so many modelers read this forum and the compiler developers do not know the answers, so I suggest you post your question here:
https://stackoverflow.com/questions/tagged/modelica
to reach more modelers.

Sep-19-17 20:55:39
Errors in my code
Category: Programming

Should work, but you can put it inside: if noEvent(extrapointSurface_1==8 or extraPointSurface_2==8).
Note however that is not good to test Real for equality. You should test for an interval with an epsilon, see:
https://github.com/modelica/Modelica-Co … ce/Util.mo

Sep-19-17 20:38:07
Errors in my code
Category: Programming

This is an equation  (extraPointSurface_1=8) or a binding, not a relation!
It should be  (extraPointSurface_1==8)

We don't support this functionality yet. Is planned to support encryption and information hiding later this year.

Jul-24-17 23:06:19
OpenModelica: Translation Warning In component in relation on Real numbers is only allowed inside...
Category: Programming

Modelica Specification says that comparing 2 real numbers for equality is not a good idea as they will seldom be really equal (that's why you get a warning if you don't use it inside functions).
You can introduce an epsilon in the comparison to make it more robust and use =< >= instead of ==.
See for example this:
https://github.com/modelica/Modelica-Co … ce/Util.mo

Update your OMDev from SVN.

You could do:

Code:


buildModel(Model, outputFormat="csv"); getErrorString();

to output csv files.

Code:


Model.exe -override var1=val1 -r File1.csv
Model.exe -override var1=val2 -r File2.csv

It might work, I haven't tried it myself.

Hi,

We don't have Project Build in the sense that JDT or CDT has. The project build does nothing (there is just a builder that checks the syntax of the Modelica files).
The actual build is done by the OMC compiler when you call the simulate(Model) command.

Cheers,
Adrian Pop/

The code for the post above is this one:

Code:


model RevoluteCrash
  import SI = Modelica.SIunits;
  parameter SI.RotationalDampingConstant d(final min=0, start=1.5)
    "Damping constant";
   
  inner Modelica.Mechanics.MultiBody.World world(n = {0, 0, -1}) annotation(Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0, 1, 0}, phi(displayUnit = "rad"), useAxisFlange = true) annotation(Placement(visible = true, transformation(origin = {-34, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.Body body1(m = 0.5, r_CM = {0, 0, -1}) annotation(Placement(visible = true, transformation(origin = {6, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(revolute1.frame_b, body1.frame_a) annotation(
    Line(points = {{-24, 70}, {-4, 70}}, color = {95, 95, 95}));
  connect(world.frame_b, revolute1.frame_a) annotation(
    Line(points = {{-60, 70}, {-44, 70}, {-44, 70}, {-44, 70}}, color = {95, 95, 95}));
end RevoluteCrash;

Nasrou wrote:


hello,

I'm new to  OM, and i have maybe a stupid question.

I want to control a simulation of my model by doing several simulations. and I want to know how can I control that. I know, that with a mos script we can do such things, but i don't know how to create a .mos script.

My question is : how can I create mos file ?

thank you.

Hi,

A .mos script is just a file you can make with any editor that has the extension ".mos". You can create a "script.txt" with Notepad and then rename it to "script.mos".
You can see in this post how to do multiple simulations with different parameters:
https://openmodelica.org/forum/default- … eter-sweep

Cheers,
Adrian Pop/

As a workaround, you could manually add it to the fmu binaries/platform using 7zip or some other zip software for now.

Yeah, this is a feature we don't support yet.
We should collect all library dependencies and add them to the fmu.

Apr-17-17 23:02:21
Category: Programming

Hi,

Note that the scalable test suite needs special flags for DAE mode for some models.
You can find them here:
https://test.openmodelica.org/libraries … rsive.html

What OM do you have and which OS do you run it on?
If you have Windows then ScalableTestSuite should be part of the OM installation.

Just make a file script.mos containing:

Code:


// --- start --- script.mos
// load the Modelica library
loadModel(Modelica); getErrorString();
// load the ScalableTestSuite library
loadModel(ScalableTestSuite); getErrorString();
// or if you don't have ScalableTestSuite in the OM installation you need to load it via loadFile:
// uncomment this and comment the loadModel above
// loadFile("path/to/ScalableTestSuite/package.mo"); getErrorString();
// set special flags
setCommandLineOptions("--daeMode=dynamic"); getErrorString();
// build the model into an executable
buildModel(ScalableTestSuite.Mechanical.Strings.ScaledExperiments.StringModelica_N_64); getErrorString();
// run the executable with special flags
system("ScalableTestSuite.Mechanical.Strings.ScaledExperiments.StringModelica_N_64 -mei=4000 -daeMode -s=ida -idaLS=klu"); getErrorString();
// --- end --- script.mos

Then you run it via omc (i suggest you put script.mos in a separate directory as a lot of files will be generated when running the script):

Code:


path/to/omc script.mos

Apr-07-17 20:22:28
Could not load shared library to import a FMU into Simulink

cbertsch wrote:


adrpo wrote:

We are in the process of fixing this in several ways:
1. produce just one DLL
2. make the main dll load the dependencies
You can also send us your code, if you want (Adrian Pop: http://www.ida.liu.se/~adrpo33/ or to OpenModelica@ida.liu.se)
to see if we are on the right track.

We are also working on providing more FMUs for FMI Cross Check and we will check them with other tools as well.
By default we are checking them with the fmuChecker but that works fine.

This sounds good! I have sent you the example FMU calling an external DLL.
When you run the compliance checker on your FMUs: Do you do this on a PC without OpenModelica being installed?

Yes. No OM installed, and even if is installed we do not put anything in the path.
I think that the FMIL library loads the DLL with altered search path, that's why it works fine.

Apr-07-17 19:12:41
Could not load shared library to import a FMU into Simulink

cbertsch wrote:


In my opinion this is neither a problem of Simulink nor of the FMI-Kit, but of the exported FMU from OpenModelica.
I have an example of an FMU with a dependency on an additicional dll that can be simulated with FMIkit in Simulink and many other tools. On request I can provide it to the OpenModelica developers with source code as an example how to implement this.

I would recomment that OpenModelica participates at the FMI Cross Check (https://www.fmi-standard.org/tools) by submitting FMUs, then such porblems would be detected. What I see there currenty: only OpenModelica reports successful simulation of FMUs exported by OpenModelica (FMI 1.0)

We are in the process of fixing this in several ways:
1. produce just one DLL
2. make the main dll load the dependencies
You can also send us your code, if you want (Adrian Pop: http://www.ida.liu.se/~adrpo33/ or to OpenModelica@ida.liu.se)
to see if we are on the right track.

We are also working on providing more FMUs for FMI Cross Check and we will check them with other tools as well.
By default we are checking them with the fmuChecker but that works fine.

Apr-07-17 08:43:31
Could not load shared library to import a FMU into Simulink

I'm glad it worked.

I wouldn't say the problem is solved because if you need to change the PATH and you need OM to be able to run the FMUs you cannot send the FMUs to other people that do not have OM installed (and your path settings).

Maybe you can report this to Simulink to tell them to load the dll with the flag given above as the FMU should not need anything from the running process directory but is arguable that more needed dlls are where the FMU is unpacked.

Apr-06-17 16:44:40
Could not load shared library to import a FMU into Simulink

Hm, it should work but it might be that Simulink does not load the FMU main dll in such a way that the extra dlls that we have in the FMU are found (see below).
You could try to add to PATH these paths (at the end): %OPENMODELICAHOME%/bin/;%OPENMODELICAHOME%/tools/msys/mingw64/bin; before starting Simulink.

The OM FMUs dll needs to be loaded with altered search path:
https://msdn.microsoft.com/en-us/librar … s.85).aspx
Alternate Search Order for Windows Store apps
If a module changes the standard search order by calling the LoadLibraryEx function with LOAD_WITH_ALTERED_SEARCH_PATH, the system searches the directory the specified module was loaded from instead of the directory of the calling process.

Apr-05-17 16:04:25
Could not load shared library to import a FMU into Simulink

What Simulink do you have, the 32 bit or 64 bit?
What version of OpenModelica do you have?
Note that the 64 bit makes a 64 bit FMU the 32 bit makes a 32 bit FMU.

Feb-23-17 16:04:07
Questions about using the scripting API via OMPython

Note that  1.11.0 32bit OMC has issues when building models.
The bug was fixed recently in 12.0-dev:
https://trac.openmodelica.org/OpenModelica/ticket/3894
We should port these fixes to 1.11.1 or so but it will take a while.

There are two alternatives for you:
1. use 64 bit 1.11.0
2. upgrade to 1.12.0-dev 32bit nigthly-builds:
    https://build.openmodelica.org/omc/buil … lds/32bit/

Feb-22-17 08:21:10
OMC is attempting to use dladdr but that call is not available on Windows

I also fixed it properly in the nightly builds:
https://build.openmodelica.org/omc/buil … lds/32bit/

You need to load the Modelica library also

Code:


omc -s ../ModelExample.mo Modelica

alternative with a script.mos containing;

Code:


loadModel(Modelica); getErrorString();
loadFile("../ModelExample.mo"); getErrorString();
translateModel(ModelExample); getErrorString();

then execute it via;

Code:


omc script.mos

Feb-18-17 02:18:30
OMC is attempting to use dladdr but that call is not available on Windows

It seems we're having issues generating C code in parallel. I'll need to debug more.

For now, to make it work you can add -n=1 to omc command:

Code:


omc -n=1 -s path/to/MyModel.mo

Feb-17-17 23:45:20
OMC is attempting to use dladdr but that call is not available on Windows

I will do some debugging of my own to fix this. I had no time to look too deep into this as I'm the one fixing Windows issues, but thanks for your investigation.
What I find really strange is that mingw64 works fine but mingw32 does not.

Your questions:
1) MINGW32 is defined in both mingw64 and mingw32
2) In general we try to keep the same Linux based interface and write small Windows layers to implement missing functions, but somehow this one escaped me.

Feb-17-17 17:15:17
OMC is attempting to use dladdr but that call is not available on Windows

This seems to be an error in 32bit OM. It works fine with the 64bit OM. Do you specifically need the 32bit one?

Feb-14-17 20:36:02
Simulation Process Failed, suspect Modelica_Synchronous

As far as i can see the simulation crashes with some assertion. Without the model is hard to debug.
If the model is not public you could send it to us at OpenModelica@ida.liu.se and we will delete it after debugging with it.
If the model is public open a ticket at:
https://trac.openmodelica.org/OpenModelica/
Click on New Ticket and then attach the model to the ticket.

Any reason for using version 1.9.7? Have you tried using 1.11.0?

Feb-10-17 13:02:41
Questions about using the scripting API via OMPython

I opened a ticket about this:
https://trac.openmodelica.org/OpenModelica/ticket/4262
and we should fix it.

Feb-10-17 12:59:57
Questions about using the scripting API via OMPython

Yeah, we should return the filename, not that message.
Basically it should be my_model.fmu in the current directory (you can get that with cd() command).

You can also have the model in the .mos:

script.mos:

Code:


// load the model as string, just make sure you escape " with \" inside the string.
loadString("
model HelloWorld \"A simple equation\"
  Real x(start=1);
  parameter Real a = -1;
equation
  der(x)= a*x;
end HelloWorld;"); getErrorString();

simulate(HelloWorld, stopTime = 2); getErrorString();
plot(x); getErrorString();

Then run omc from command line:

Code:


> omc +d=showStatement script.mos

See here, session example 3:
https://openmodelica.org/doc/OpenModeli … mmand-line

You can just make a script.mos containing:

Code:


loadModel(Modelica); getErrorString(); // load Modelica if you need it
loadFile("Model.mo"); getErrorString(); // load Model.mo that you edit
simulate(Model); getErrorString(); // simulate the model
plot({x, y}); getErrorString(); // plot any variables you need

then run omc from command line:

Code:


> omc script.mos

Hi,

Please send this question to OpenModelica@ida.liu.se.

Cheers,
Adrian Pop/

Feb-08-17 09:30:14
Category: Programming

foadsf, can you send us your model so we can debug what's the problem with it?
If is not public you can send it via email to OpenModelica@ida.liu.se and we'll delete it after debugging the issue.
If is public, just go to:
https://trac.openmodelica.org/OpenModelica/
click on New Ticket, create the ticket and attach your model to it.

You should not use Modelica_Noise library as is a bit outdated and we don't support it very well.
The Noise library was already included in the Modelica Standard Library (MSL) 3.2.2.
Just go to Modelica.Blocks.Noise or Modelica.Blocks.Examples.NoiseExamples to use those. To see what we support from the Noise library included in MSL go here:
https://test.openmodelica.org/libraries … rsive.html
and search for Noise. It seems all the example models are working.





It seems we have some issues with function inlining which generates undefined variables in the C code.
I opened a ticket about it and we'll have a look:
https://trac.openmodelica.org/OpenModelica/ticket/4239

For examples look into the Modelica Standard Libraries (MSL).

Have a look in Modelica.Mecanics.Translational.
Look inside:
- Modelica.Mecanics.Translational.Interfaces for connectors
- Modelica.Mecanics.Components for components (have a look how they extend the Interfaces)
- Modelica.Mecanics.Examples.Damper on how for example Mass and Spring are are connected together

You can read a bit more about Modelica, for example:
http://book.xogeny.com/



You can see some examples here:
http://spoken-tutorial.org/tutorial-sea … ge=English (also linked from our first www.openmodelica.org) page.

There are no API commands for substitution, is done automatically to evaluate expressions involving parameters or constants, basically to optimize the systems when calling buildModel or simulate.

In the front-end we only do this kind of things for structural parameters (array dimensions, etc), in the back-end depending on the the given flags there are more optimizations going on. I'm affraid we don't have too much documentation about the back-end so you'll have to look in the code:
https://github.com/OpenModelica/OMCompi … er/BackEnd
For a bit of outdated overview of the back-end you can look here:
https://openmodelica.org/svn/OpenModeli … r/BackEnd/
Some information about what the back-end does is here but is quite old too:
https://www.openmodelica.org/images/doc … ackend.pdf
I'll ask one of the back-end developers if there is anything newer and get back to you.


The code for the function evaluation interpreter is here:
https://github.com/OpenModelica/OMCompi … unction.mo
It basically goes over each function algorithm statement and interprets it in an environment with variables.

The compiler code is not that easy to understand, is written in MetaMoldelica (out own functional language).
You can find more about it here:
https://openmodelica.org/developersresources/courses
https://openmodelica.org/developersreso … umentation

An interpreter for Modelica language is surely possible and we have it partially as part of the OpenModelica compiler (for function interpretation).

However, I don't think any of the Modelica tools are following this path as you need access to numerical solver libraries (which are mostly in C or Fortran) and you need to link with them.

OpenModelica also does extensive symbolic manipulation and can solve some systems using substitutions but it highly depends on the system complexity.

Jan-13-17 17:32:08
Category: Programming

Only via modification on variable declaration:

Code:


MainClass001.SubClass001 subClass0011(phi(start = initial_condition));

Dec-27-16 21:26:21
The fmu export dont generate any file in he path

Ok. Let's try something else. Start your terminal and go someplace where you can write files like your home:

Code:


> cd ~
# create a testing directory
> mkdir testfmus
# change directory to the testing directory
> cd testfmus

Using any editor you want in the tesfmus directory we created, create a file called script.mos containing:

Code:


loadModel(Modelica); getErrorString();
translateModelFMU(Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_withLosses);  getErrorString();

now back in the terminal:

Code:


> omc script.mos

See what files are generated in the ~/testfmus directory, especially .log files, also look into any directories inside.
If you can, zip ~/testfmus directory and attach it here. If you cannot attach them here just go to our Trac:
https://trac.openmodelica.org/OpenModelica
click on New Ticket and create a new ticket with your issue, then attach the zip file to the ticket.

Dec-27-16 21:10:55
the model pass the check but simulation has non graphic results

This seems to be a modeling error.
Your tank1 has height = 12, level_start = 12 which means that the tank1.level starts already at maximmum and if it goes beyond that an assertion in the Modelica code for the Tank is triggering and the simulation is failing. Are you sure you want to start the level at 12? If I change the tank1.level = 6 for example then the simulation works fine.

"What do you mean by we need components not record in Database.
Component is enumeration. enumeration cannot contain parameters and their values.
I have more parameters also which are not given in code. Some of them are array."

I was talking about "Comp". I mean that you need declare components which you can then assign in the functions, you tried to assign directly records to components and that does't work like that, it only works via a record constructor Record x = Record(var1=val1, var2=val2, etc).

In Modelica you can no longer modify only an array element, you can only modify the entire array that's why you cannot have a dialog for each array element.


Dec-27-16 12:17:47
The fmu export dont generate any file in he path

The warning is fixed in the latest revision.

There is no space missing. We generate a Model.fmutmp directory in which we put sources, binaries and so on which we then zip into Model.fmu.
Are you by any chance missing the "zip" utility? Write zip in a terminal to see if you have it.

Note that you need components not records in package Database. See below:

Code:


package Test1
  type Component = enumeration(Air, Argon, Bromine, Carbontetrachloride, Carbonmonoxide);

  package Database
    extends Modelica.Icons.VariantsPackage;
    record General_Properties
      Integer SN;
      String name;
      Real Tc;
      Real Pc;
      Real Vc;
      Real Cc;
      Real Tb;
      Real Tm;
      Real TT;
      Real TP;
      Real MW;
    end General_Properties;

    constant General_Properties Air(SN = 1, name = "Air", Tc = 132.45, Pc = 3774000, Vc = 0.09147, Cc = 0.313, Tb = 78.67, Tm = 59.15, TT = 59.15, TP = 5642.15, MW = 28.96);

    constant General_Properties Argon(SN = 2, name = "Argon", Tc = 150.86, Pc = 4898000, Vc = 0.07457, Cc = 0.291, Tb = 87.27, Tm = 83.8039, TT = 83.8, TP = 68906.1, MW = 39.948);

    constant General_Properties Bromine(SN = 3, name = "Bromine", Tc = 584.15, Pc = 1.03E+07, Vc = 0.135, Cc = 0.286, Tb = 331.9, Tm = 265.9, TT = 265.85, TP = 5853.37, MW = 10 /* adrpo: MW was missing, fix it! */);

    constant General_Properties Carbontetrachloride(SN = 4, name = "Carbontetrachloride", Tc = 556.3, Pc = 4557000, Vc = 0.276, Cc = 0.271, Tb = 349.79, Tm = 250.33, TT = 250.33, TP = 1122.46, MW = 153.822);

    constant General_Properties Carbonmonoxide(SN = 5, name = "Carbonmonoxide", Tc = 132.85, Pc = 3494000, Vc = 0.0931, Cc = 0.292, Tb = 81.66, Tm = 68.15, TT = 68.15, TP = 15400, MW = 28.01);
   
  end Database;

  function get_comp
    extends Modelica.Icons.Function;
    output Database.General_Properties Comp;
    input Component component;
  algorithm
    if component == Component.Air then
      Comp := Database.Air;
    elseif component == Component.Argon then
      Comp := Database.Argon;
    elseif component == Component.Bromine then
      Comp := Database.Bromine;
    elseif component == Component.Carbontetrachloride then
      Comp := Database.Carbontetrachloride;
    elseif component == component.Carbonmonoxide then
      Comp := Database.Carbonmonoxide;
    end if;
  end get_comp;

model MS
  extends Modelica.Icons.SourcesPackage;
  parameter Component component;
  Database.General_Properties comp;
 
equation
  comp = get_comp(component);
end MS;

  model Test
    MS mS1(component = Test1.Component.Argon)  annotation(Placement(visible = true, transformation(origin = {-2, 48}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  end Test;
end Test1;

We should support annotation choices for drop down list choices this but we don't yet. We're working on it.
You could also use replaceable and redeclares.

Dec-27-16 09:44:18
The fmu export dont generate any file in he path

Do you have any .log files in that directory? If so, it should tell you what went wrong.
Does the normal simulation works fine?

Dec-21-16 09:06:15
any model thate i have give the same error: component tank1 contains the definition of a partial...

You can read about redeclares in the Modelica Specification 3.x.

In your case you need to go into the Modelica source code for your model and for component tank1 just add:
redeclare Medium=Modelica.Media.Water.StandardWater to your components.

Code:


tank1(redeclare package Medium=Modelica.Media.Water.StandardWater);

You will need to add it for all the components that need it.

Dec-21-16 08:45:10
any model thate i have give the same error: component tank1 contains the definition of a partial...

What do you mean? If you're asking for the Modelica Language specification is here: https://www.modelica.org/documents/

Dec-21-16 08:28:48
any model thate i have give the same error: component tank1 contains the definition of a partial...

Unfortunately we don't yet support redeclares in the OMEdit dialogs  so you will have to write them it directly in the code.
I'm working on a solution which should be available soon. See:
https://trac.openmodelica.org/OpenModelica/ticket/2079

You cannot do that directly. You can call Modelica.Utilities.Streams.print to print internal function values to a file or stdout or stderr.
Alternatively you can run the model in algorithmic debug mode and put a breakpoint inside the function where you want to see the values.

We tried to make the installer smaller and we removed that library from the installer. I now fixed the issue.

Please re-download it and re-install it:
https://build.openmodelica.org/omc/buil … ta1/64bit/


Nov-23-16 17:42:56
Category: Developer

You need to run
OMDev\SETUP_OMDEV.bat
and
OMDev\SETUP_OMDEV_Qt5.bat
before you can compile qt clients.

Oct-11-16 19:15:42
it doesen't appear

We do not have yet support for choicesAllMatching and replaceable classes. Some work is under way to fix this in the near future.
See: https://trac.openmodelica.org/OpenModelica/ticket/2079

Oct-10-16 20:39:20
I need to run my model with a variety of input sets to get a variety of input cases

You could do something like:
https://openmodelica.org/forum/default- … eter-sweep

Another way is to create another model in which you have the current model several times as components with different inputs, that you can simulate once.

Oct-06-16 09:45:41
FMU export problems

What OpenModelica version are you using? If is 1.9.6 then is only 32 bit and can generate only 32 bit FMUs.
You need the 64bit nightly build to make a 64bit FMU:
https://build.openmodelica.org/omc/buil … lds/64bit/

You need to activate OMC Flags: +std=3.3 in OMEdit via Tools->Options->Simulation as these things are only available in Modelica Specification 3.3.

Aug-18-16 22:14:32
Deriving user class inheriting properties of base class

Should work like this:

Code:


model ReluctanceLinear
  extends Modelica.Magnetic.FluxTubes.Shapes.FixedShape.Cuboid(mu_rConst=5000);
end ReluctanceLinear;

Hm, I haven't run into these issues before, maybe see here:
http://stackoverflow.com/questions/3778 … repository


You might neeed to configure git or reinstall it. I use git from here:
https://git-scm.com/download/win

The path you have in Windows is not used in msys2 or eclipse.

For msys2 you need to give: ming64_shell.bat -use-full-path to use it. See OMDev\INSTALL.txt
You can also use:

Code:


> export PATH=$PATH:/c/path/to/git:/c/Program\ Files/Java/jre1.8.0_102/bin
> make ....

In eclipse, you need to edit the OMDev builder and set the PATH in the Environment tab.

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