- Index
- » Users
- » sjoelund.se
- » Profile
Posts
Hassani22 wrote:
I wanted to install openmodelica on raspberry so that I could generate the fmu. but the problem that I can't install openmodelica on raspberry.
the error message I got:"Could not find package openlmodelica."
so I would like to know is there a possibility to install openmodelica on raspberry PI3.
If yes, how i do this.
thank you.
Did you follow the instructions to add the repository to apt so it could be found? If so, make sure to not make the typo above: openlmodelica = openmodelica
For Linux, I would often run something like:
Code:
docker run -it --rm -e "HOME=$HOME" -e "DISPLAY=$DISPLAY" --network=host --user "$UID" -v "$HOME:$HOME" -v "$PWD:$PWD" -w "$PWD" openmodelica/openmodelica:v1.18.0-gui
So the home directory is not filled with root-owned files.
What architecture FMU did you try to import? What's the error message?
Which version of omc was this? And what does
Code:
ls ~/.openmodelica/libraries
contain?
It might also be that packages such as omlib-modelicareference need to be uninstalled in order for that to work.
We have started using our own package manager instead. You can install 1.16 with the --nodeps flag. I would also suggest installing the nightly and using the package manager from that to install the Modelica packages you need (either through command-line or OMEdit).
I will remove the omlib-all dependency from the spec-file since only Fedora has it as a suggests dependency and it's a hard dependency in RHEL.
TULU wrote:
The exe remains there but I do not know how to call it without building the model again.
How would this be done?
I tried with FMUs but they are much slower...
In Linux, you just call the executable. For Windows... You're better off running it through WSL than trying to figure out how to modify the PATH (although I guess someone will tell you how)
278067605 wrote:
sjoelund.se wrote:
278067605 wrote:
i want to use dlls to use it ,it will be a part of my projectIf you want to use it as a DLL, your whole project needs to become GPL-licensed though. You can see how OMEdit uses the OMC DLL if you want an example of how to use it in that way.
hi,if i want to use omc via ZMQ or Corba what should i do?
thanks!
For ZMQ/CORBA it depends on what language you are using. If it's a Python application, using OMPython is very simple. Otherwise, it's just starting the omc.exe with some flags:
Code:
$ omc --interactive=zmq --locale=C -z=myrandomstring
Created ZeroMQ Server.
Dumped server port in file: /tmp/openmodelica.martin.port.myrandomstring
and then reading that file for the settings to use in your ZMQ library to connect to the running server.
278067605 wrote:
i want to use dlls to use it ,it will be a part of my project
If you want to use it as a DLL, your whole project needs to become GPL-licensed though. You can see how OMEdit uses the OMC DLL if you want an example of how to use it in that way.
You can use "Equation System Initialization File" and Initialization Method "none" to restart simulation with some values from a result-file to chain simulations.
But if you use an external state (external functions, external objects), delay functions, spatialDistribution or perhaps if you use a lot of events and need to preserve pre-values/etc, you might get some unexpected results.
You should have the license text somewhere in the documentation. I'm not sure it fits in the Python code itself. If it was me, I would put it in a COPYING or LICENSE.md file (and mark which files fall under that license).
You are probably interested in the FMI export from OMEdit. See also: fmi-standard.org
If you cannot apt install clang, something is very broken indeed. Maybe you need to apt autoremove openmodelica followed by apt dist-upgrade or maybe you need to apt install --fix-broken first.
You need to apt install omc or something in this list to see why apt fails. It doesn't always produce very good error-messages
Are you using OMEdit? Tools -> Options -> Libraries can select MSL version (or removing it and loading the version expected by whatever library you want to open).
mahge wrote:
> I think the weird part is looking in /omc/ffi. The ffi directory doesn't exist for me. What OMC version was this on Linux?
What version of omc do you have? If it is not a nightly build from a few days back the omc/ffi directory should not be there. Otherwise it should.
If it is missing for Youth then it is probably the package not including everything in /lib/x86_64-linux-gnu/omc/. Maybe it is including only /lib/x86_64-linux-gnu/*.a and /lib/x86_64-linux-gnu/*.so?
I did upgrade today, but maybe I forgot to use /usr/bin/omc. If you change any file installed, you need to update the installer or you will break everyone's Linux install... https://github.com/OpenModelica/OpenMod … ter/debian
I think the weird part is looking in /omc/ffi. The ffi directory doesn't exist for me. What OMC version was this on Linux?
You could also run a conversion script from TransiEnt 1.3.0 to 2.0.0: https://github.com/ClaRaLibrary/TransiE … _2.0.0.mos
No, that won't work because the flat code is not valid Modelica and only top-level inputs are inputs to the system. Any blocks with inputs must be used or connected.
You can override top-level inputs as well. If you want to connect them, they need to not be parameters. If you want them to be parameters, don't make them connectors (just Real, and write an equation instead of the connection).
If you check the flat code it should be easy to see the error:
Code:
class sumDummy
parameter input Real var1;
parameter input Real var2;
output Real y;
Real add.u1 "Connector of Real input signal 1";
Real add.u2 "Connector of Real input signal 2";
Real add.y "Connector of Real output signal";
parameter Real add.k1 = 1.0 "Gain of input signal 1";
parameter Real add.k2 = 1.0 "Gain of input signal 2";
equation
assert(abs(var1 - add.u1) <= 0.0, "Connected constants/parameters must be equal");
assert(abs(var2 - add.u2) <= 0.0, "Connected constants/parameters must be equal");
add.y = y;
add.y = add.k1 * add.u1 + add.k2 * add.u2;
end sumDummy;
Because var1 and var2 are parameters, connecting them adds assertions instead of alias equations. Remove the parameter keyword from them and the model works.
You can use docker to force an older Linux distribution to be used for compiling the source-code. If you are using the nightly builds, OMEdit should have improved options for selecting a docker image.
I think most people press the upgrade button so the system will be up to date, but it takes some time before a new install is upgraded. New installs should have the newer ca-certificates package unless you have an older focal USB-stick, etc.
I would run it with "docker run -it ..." and then start OMEdit from inside. Then there's a chance to look at logs, etc
It looks like the models are included in the appendix. Seems like a bad way to distribute libraries and I couldn't find a copy of the actual code online...
You need to update the ca-certificates package
Yes, we don't run the testsuite when building our packages. So flex is not listed as a dependency.
On WSL, I can do this since the xserver knows the IP:
Code:
docker run -v /home:/home -it --rm --user 1000 -e DISPLAY=$DISPLAY -e HOME=$HOME -w "$PWD" openmodelica/openmodelica:v1.18.0-gui OMEdit
You can also add --network=host to avoid some xauth problems. It's much easier when everything is local.
This question appears quite often. Debian Testing is not a suitable target for packages since it allows major changes (including libc) for more than 1 more year. Once it gets closer to the soft freeze (2023), building packages makes more sense as they have a chance of working.
Docker works quite well though.
Arinomo23 wrote:
thanks @sjoelund, i'm not aware of this change,so my reply was based on V1.18.
On the side note: How does this effect user w/o an internet connection? I assume, it was down to make it easier for user to mange package based on its version on github etc?
It's possible to copy a cache folder (of zip-files) and the index.json file to a local computer and install through that (or copying .openmodelica/libraries/ from one computer to another). But yes, you will need an internet connection to download packages in the first place. It doesn't make sense to wait 40 minutes for the slow Windows filesystem to install several gigabytes of packages that you don't need and didn't change since the last OM install. And it doesn't make much sense for OpenModelica to package everyone's libraries when the package manager can be used to download directly from the source.
Edit: And it's now possible to install different versions of a package (like the latest master of a package if you need that, or an older release of a package if you need that).
Note that the latest OM nightly comes with a package manager instead of a fixed set of pre-installed libraries. In OMEdit, File -> Install Library
https://libraries.openmodelica.org/bran … rview.html
https://github.com/OpenModelica/OpenMod … aryTesting
You need to run this on Linux. You can use reference result files to verify that the simulation generates expected trajectories
You need to make the input not be a constant or OMC evaluates the function at compile-time. If you pass x*time to square, the results are printed.
Did you sudo apt install omsimulator?
(I will add it to the openmodelica meta-package for 1.19.0, but for 1.18.0 it's not included)
If these are parameters, passing them is easy: just list all scalar variables and the corresponding values in an overrideFile:
https://www.openmodelica.org/doc/OpenMo … erridefile
Use unit="1"
https://specification.modelica.org/mast … xpressions
nimoror wrote:
Maybe it would be possible to store the packages and models in individual code files to give a better overview?
AnHeuermann wrote:
So for developing your own library you can save libraries in multiple files (In OMEdit: File->New->New Modelica Class; a dialog opens where you choose package and uncheck "Save contents in one file"), have packages in packages and with that getting a well structured system of .mo-files you can work with.
Also, look at the structure of the Buildings library: https://github.com/lbl-srg/modelica-bui … /Buildings
Over 3000 files to store the package.
It uses OPENMODELICALIBRARY, which by default will be nothing and then we grab libraries from the installation directory + your home directory. In the Modelica specification, MODELICAPATH is used as a concept, but in order to avoid clashes with other tools we don't use that as env.var.
Tools -> Options -> Libraries you can set libraries to launch on startup.
Otherwise you could load a model with uses-annotations on each of the libraries, which would load them all automatically provided they are on the MODELICAPATH or the model is in the same directory as all of the libraries.
The simulations don't use exit codes other than 0, 1, -1. Any other exit code comes from the OS itself.
rasc5 wrote:
What if the reinit is inside an Algorithm part?
OMPython is not allowing me to load a Model I built from scratch having this struct. I can run it perfectly in OpenModelica but not from Python (3.8).
Any ideas why?
Thank you in advance
reinit is only allowed in equations: https://specification.modelica.org/mast … tml#reinit
The Mac we had for the builds died. It should still be possible to compile OpenModelica.
We used to run an older OSX version and MacOS/XCode versions don't have good backwards and forwards compatibility, so you might need to create some patches though.
(Judging by how well MacOS is designed, I'm surprised NIST allows it on machines at all. The M1 is very good hardware though. For what it's worth, future Windows versions of OpenModelica might run on WSL since it runs a lot faster than native Windows versions.)
Did you git clone --recursive or did you forget to update git submodules?
If you have it built, the symlink or just launching OMEdit directly from the directory should work. If there is a problem, you need to use ldd to figure out what is going wrong. Perhaps
Code:
find build -name "*.so*"
would be helpful, too.
That trace suggested everything worked fine, right? Was the exit-status not 0?
So with no changes to Modelica.Fluid.Examples.Tanks.TanksWithOverflow ?
We won't be able to tell if it's going to work or not without an example model. OM 1.16.5 allowed a lot of invalid code that has now been resolved in the newer OM versions. In newer versions you can still change to the old frontend for old behaviour, but this will probably disappear in the future.
If it says skipping incompatible it probably means the dll is a 32-bit dll and you need a 64-bit version (or installing 32-bit OpenModelica instead).
You'd still need to find a 64-bit DLL, right?
That error is because ModelicaADS only comes with that library for 32-bit Windows: https://github.com/TechnicalBuildingSys … rary/win32
I think you'd be better off with a solver that converges quicker. Runge-Kutta isn't very complicated. Reducing the communication could help, but then try to profile it so you know that this is the case before you implement the change.
Well, you could use the command setCommandLineOptions("-d=-newInst") through OMPython. But a better solution would be to fix the code since it is not legal Modelica code.
The FMU itself doesn't have a timestep. The importing tool decides the time step to take. If that is successful or not is reported by the FMU.
Hmm.... All of our source entries seem to be empty. I wonder when that happened. Probably when the OS was upgraded a month or so ago.
The control file is here: https://github.com/OpenModelica/OpenMod … an/control
And you can create a package for the dependencies: https://stackoverflow.com/questions/174 … ntrol-file
I'm not sure when we would have time to fix this.
Which deb-src lines does your system use?
Tools -> OMC CLI for accessing in the GUI
Or look for logs in your tmp-directory (on Linux: /tmp/OpenModelica_$USER/OMEdit/)
You can look into OMEdit's logs to see which commands it uses. Some of these commands work out of the box in OMPython, some need to be called with parsed=False as far as I remember.
_omcQ_24cse2 would be a variable called $cse2 (which is introduced by OpenModelica). So most likely a tool bug: https://github.com/OpenModelica/OpenModelica/issues
adrpo wrote:
What you want seems to be like starting the same model with different T0 in a for loop. If this is what you want let us know and we'll give you some solutions for that.
Having an array instead would probably be the easiest way of doing that.
Code:
algorithm
for ... loop
T := ...;
The closest match would be adding a solver for a discrete (clocked) system: https://specification.modelica.org/main … er-methods
https://mbe.modelica.university/behavio … unc_annos/
Regarding the derivative, dassl will probably want the derivative of der(y) to create its polynomials.
For inlining, OpenModelica will not inline complicated functions even if you add the annotation.
If you have a function call like that, I assume you don't have a derivative or inline annotation. If that's the case, a numerical Jacobian will be calculated instead of a symbolic one. This will be somewhat slower as you experience.
As far as I remember if you are using dassl, it internally has some polynomial expression for what the derivative is estimated to be at each point. You won't be able to reconstruct the actual values from the derivatives alone.
If you change solver to Euler you should have better luck.
As far as I remember if you are using dassl, it internally has some polynomial expression for what the derivative is estimated to be at each point. You won't be able to reconstruct the actual values from the derivatives alone.
If you change solver to Euler you should have better luck.
I would put the annotation at the end of the class. Other places in a class were removed in the Modelica 3 grammar many years ago.
I thought this was enabled by default in our 2.0 FMUs. Do you have some example that it doesn't work for?
Start looking here: https://github.com/OpenModelica/OpenMod … ure.ac#L70
You can also look in OMEdit/config.log to see what is happening there.
You need to use the element-wise operators .^ .- and ./ instead of ^ - and /.
You always get a new session (you can see each omc process in your OS process list). This is the case also if you use the same Python session for OMCSessionZMQ.
Try using a more recent version of OpenModelica. 1.17.0 (to be released soon, I think contains the fixes for that) or the nightly builds should resolve that particular issue.
Edit: 1.17.0 (Windows) was uploaded yesterday: https://build.openmodelica.org/omc/buil … nal/64bit/ . Linux builds are still being compiled.
You can only have the vector on the left side of a multiplication (x*A1 is OK, A1*x is not). https://specification.modelica.org/main … ric-arrays
The following should work (I made y a vector)
Code:
model TestRead
"Demonstrate usage of function Streams.readRealMatrix"
import Modelica.Utilities.Streams.print;
extends Modelica.Icons.Example;
final parameter String file1 = Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat") "File name of check matrix 1";
final parameter String matrixName1 = "Matrix_A" "Names of check matrices";
final parameter Integer dim1[2] = Modelica.Utilities.Streams.readMatrixSize(file1,matrixName1) "Dimension of check matrix 1";
final parameter Real A1[:,:] = Modelica.Utilities.Streams.readRealMatrix(file1,matrixName1,dim1[1],dim1[2]) "Data of check matrix 1";
Real x[dim1[1]] (each fixed = false) "Dummy state" ;
Real y[dim1[2]];
initial equation
x = fill(1.,dim1[1]) ;
equation
y = -x*A1;
end TestRead;
Did you skip step 1? https://github.com/OpenModelica/OpenMod … v-MINGW.md
OMDev is where you installed it. Clone https://openmodelica.org/git/OMDev.git into C:\OMDev and set the OMDev environment variable to that location and you should get further.
The easiest way would be something like:
Code:
$ docker run --network=host -it openmodelica/openmodelica:v1.16.2-minimal
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2290fa2e1fa6 openmodelica/openmodelica:v1.16.2-minimal "/bin/bash" 8 seconds ago Up 6 seconds eager_easley
$ python3
>>> import OMPython
>>> omc=OMPython.OMCSessionZMQ(dockerContainer="2290fa2e1fa6")
>>> omc.sendExpression("getVersion()")
'OpenModelica 1.16.2'
gela wrote:
Oh, that's what you meant.
I think you have misunderstood my request with the Arduino Uno a little bit or I have expressed myself there probably inaccurately: My goal is to run the Arduino model with different scripts (as one can do that on the real Arduino too). In Dymola I can select the script I want to run on the Arduino in its block parameters.
Soon I have no access to Dymola anymore so I need the same functionality in OpenModelica with the Arduino model there. I had mentioned the "Blink" only as an example, so that I can test the function.
Unfortunately I can't upload a screenshot of my model with the Arduino right now, because an error happens when uploading the image in my post. I hope you can see it here.
In my modelica model I run a script which I created with the Arduino Uno block. For this, the Arduino needs the different analog inputs and digital outputs. Because of this I tried it with the model from Github, since it had worked with this in Dymola everything.
Is there really no chance to simulate a working model in OpenModelica with the library from Github?
In Modelica_DeviceDrivers you can choose which AVR chip to target (but only a few different AVR microcontrollers are available). The Modelica model is what you compile for the Arduino.
As for the CATIA library, it might work. You just need to run some commands manually (look at all the Dymola-specific annotations in the model). Read the documentation and run everything special it is doing manually. For example: When a model that contains the ArduinoUno block is translated the external object is automatically re-built through the preInstantiate=Arduino.Internal.buildSketch(...) directive in its annotation.
Modelica_DeviceDrivers.EmbeddedTargets.AVR.Examples.Arduino.UNO.Blink
You'll need to look into that library to see which commands are being run to compile that library automatically in Dymola. If you compile it, I think it might work.
Otherwise, try the Modelica_DeviceDrivers library. It has worked in OpenModelica in the past at least.
OpenModelica can export FMUs as C or C++ (with C bindings, not C++). OMSimulator is written in C++ and can import and simulate FMUs.
Where did you put the file? The only location that is searched is Teste26-02/Resources/Include
Default just means the latest installed version. It's the same for all libraries; no special case for the standard library.
1. You can't. You need to rewrite the code (or use the demo version of some Modelica tool that supports the conversion scripts, which will give you an updated model using MSL 4.0.0)
2. Go to Options | Libraries (I think) and change the version of Modelica you want to load by default (or don't load Modelica by default)
3. I'm unsure about this as I don't actually use tables myself
The plot would still say seconds, but you would know it is in hours. I'd recommend scaling it for proper models though
As for time steps, the unit in the specification is time as seconds. In OMEdit, you can change the displayed unit to be days. And you could create conversion variables
Code:
Real timeInDays(unit="d") = time / 86400;
and use those in your code if necessary.
You could also pretend the unit is in hours instead of seconds, but then your model might not work correctly with other tools.
If it's the stopTime you are concerned with, I am sure that could be added to the GUI as an enhancement in the future.
The instructions are for Windows (using OMShell or OMEdit to access the command line). Otherwise, the libraries are here: https://github.com/OpenModelica/OpenMod … /OM/master
ModelicaTest has a lot of examples for tables if you want to see example code
The documentation is part of the library (you can browse it in OMEdit). You will need the latest OM nightly and also use the package manager to install the master version of the standard library:
Code:
installPackage(Complex, "4.0.0-master");
installPackage(ModelicaServices, "4.0.0-master");
installPackage(Modelica, "4.0.0-master");
Code:
>>> loadModel(Modelica, {"4.0.0-master"})
true
>>> getSourceFile(Modelica)
"/home/martin/.openmodelica/libraries/Modelica 4.0.0-master/package.mo"
>>> getSourceFile(ModelicaServices)
"/home/martin/.openmodelica/libraries/ModelicaServices 4.0.0-master/package.mo"
>>> getSourceFile(Complex)
"/home/martin/.openmodelica/libraries/Complex 4.0.0-master/package.mo"
If you are using a CSV-file, you need a version of MSL from the master branch as it has been very recently added: https://github.com/modelica/ModelicaSta … 9b5d317e35
Otherwise, you need to convert your txt-file into one of the supported formats (read the documentation).
People do. I just don't understand it.
You mentioned Medium in the title, so I won't even bother reading the body text
Give gen1.Syn1.Sn a start-value different from 0? Or an equation that can be satisfied?
The Modelica standard library does not do things like collision detection, and will only use a 3D model for visualization. So you would need to manually (or create some software) create all those constraints from the CAD model.
You need to compile all the dependencies first (including omc). The linked image suggests you didn't do that. make -f Makefile.omdev.mingw in the top-level directory and you should have build/bin/OMEdit.exe
a) Yes, but I'm not at liberty to discuss that particular implementation. You can read https://github.com/modelica/ModelicaSta … ssues/1153 as well...
b) You need to write your own C library most likely, or maybe you can use /opt/dymola-2021x-x86_64/source/matrixop.c, but I have never looked at that. The readMatrix function is a builtin function of Dymola and doesn't work in standard Modelica tools. But why not spend time to extend the standard library to have ND-tables instead? (You know, that ticket above)
You could perhaps chown /usr/bin/omc to a non-root user and then chmod 4755 /usr/bin/omc
But still, running omc as the root user is a bad idea.
Yes, if I copy-paste what you put in the forums or on the download page, it starts installing. It seems you didn't put a pipe, but rather quoted something causing you to search for some string that contains | cut -d" " -f1 instead of piping the output of apt-cache search into the cut command...
Do you have the apt repository and did you call "apt update" ? I'm on focal and this is my output:
Code:
[martin@mega ~]$ apt-cache search "omlib-.*"
omlib-advancednoise-1.0.1 - AdvancedNoise 1.0.1 is a Modelica library
omlib-aixlib-0.4.0 - AixLib 0.4.0 is a Modelica library
omlib-aixlib-0.9.1 - AixLib 0.9.1 is a Modelica library
...
If it's missing the header, you didn't compile it or it failed halfway through and you need to restart.
You need to have bootstrapped omc, too. I guess the make target you were looking for is "all" (or "omc" before qt clients)
I would suggest using
Code:
docker run -d -p 127.0.0.1:25901:5901 -p 127.0.0.1:26901:6901 dersh/om-desktop-nightly
To not let outside machines connect to the exposed VNC port.
This is quite cool. You could have made them in the same repository sand different tags though. At least this avoids the need of an X server or virtual machine.
Although I didn't test the images myself, it seems like it would listen to external connections. It would be safer to not expose the port and instead just connect to the container directly. But MacOS and Windows have some limitations in that regard...
Keep in mind that docker is a pretty big security risk.
OMShell is a Qt application. OMShell-terminal is a shell application.
It seems I forgot to activate the libraries (should be added during the night). If you want the libraries sooner, you could try to install the libraries locally. Create a file installLib.mos with contents:
installPackage(Modelica, "3.2.3");getErrorString();
installPackage(ModelicaReference);getErrorString();
And then run omc installLib.mos
You need a JRE in order to run ANTLR. The JDK should be optional though.
Call getErrorString() to get messages
Yes, until the builds succeed. It's not just updating which OS distributions to compile for. We need to fix bugs in third-party source code when gcc versions change
No, you would install openmodelica-1.14, I believe. The exec older versions don't compile on newer Fedora
I suppose we should add a build for fc33. There is no repository for Fedora 33 yet. Which one did you copy?
model M Real r = "s"; end M;
SudhakarK wrote:
Now, I wish to modify the code such that x generates a random value at each instant. Accordingly, I will read those values from the client end and change the values of x that will ultimately affect the value of y. Could you please provide some insights on this?
That's not possible. Impure functions may only be called at event instants. So you need to use when sample(...) or something similar.
That's just a warning, right? We won't compile new packages just for Ulyana when the packages are the same as focal
I'll try updating these to the last 3 releases (30-32). The problem for us, none of us use Fedora so we don't remember to update the list of Fedora OSes we build for.
You could just use the corresponding Ubuntu name (focal) and that will usually work. I have now symlinked it on the webserver so it should update using the existing files.
http://dx.doi.org/10.3384/ecp140961285 but I can't remember what happened to it
I'm guessing somewhere in all that C-code there's the assumption that if it's an ARM system, pointers are 32-bit. You could run gdb on the executable so see where it crashes but the actual line of code that needs changing might be nowhere near that line of code...
There are two ways to load a package:
* It is stored in the MODELICAPATH and you use it as a system library. Then we load it read-only and it cannot be modified.
* You load a .mo-file by opening it. OMEdit then assumes you want to be able to edit it.
If you have access to the paid version, encrypted models cannot be modified either.
I am using Ubuntu 18.04, kernel 4.15.0-112-generic, docker 18.03.1-ce
The attached dockerfile, mo and mos-files produce an FMU for me without any crashes. You could try to install gdb in the docker image and run that on omc. Or maybe running memtest86+ to rule out problems from that.
What Linux kernel is running the image? Maybe bionic is too recent for the running kernel?
Mota wrote:
Or are there any problems/disadvantages I havn´t thought about?
You need to install an X server to use docker.
In a mos-script, lets say script.mos:
Code:
loadFile("MyModel.mo");getErrorString();
translateModelFMU(MyModel);getErrorString();
You may also need to loadModel(Modelica), etc. But it shouldn't take much more than that. Run the script using "omc script.mos"
Take a simple model like the following for example:
Code:
model M
Real x = sin(5*time);
Real y = if x >= 0 then x else -x;
end M;
It will cross from positive to negative at around time=0.6238. At this time, y may be negative despite that if-condition guarding against negative numbers. Why? Because the zero-crossing function is not exact and there will be a time event at a time that is not exactly when the condition triggers.
On the other hand, the following will generate a trajectory where y is always >= 0. But there is no event triggered at the time of the zero-crossing, so some other values might be affected if you actually need some calculation to update at this point.
Code:
model M
Real x = sin(5*time);
Real y = if noEvent(x >= 0) then x else -x;
end M;
There is no such output at the moment, and you won't ever be able to get a pure ODE system out of it since Modelica contains hybrid parts, the clocked system, and non-linear systems, dynamic state selection, etc. But for some models you might be able to get an ODE system out of OpenModelica. If you write an exporter for it or perhaps parse the info.json file to get the equations you want (for even more limited models).
OMEdit Result.mat will not open the result file in the plotting perspective. But File -> Open result file (or whatever it was called)... should work. Of course, you can't script that.
Call getErrorString and you should see why. I guess that's Dymola syntax for a mos-script and the functions you try to call don't exist either. We don't have simulateExtendedModel
Try to resample the mat-file using:
https://openmodelica.org/doc/OpenModeli … ionresults
Maybe a table lookup?
https://build.openmodelica.org/Document … le1Ds.html
See for example:
https://mbe.modelica.university/behavio … e-and-hold
https://mbe.modelica.university/behavio … /sampling/
Basically, inside a when-statement is the only time you really know in what state the solver is (because it needs to reset after discrete events)
No, there is no way to know this because the solver may not even solve the model time step by time step (Modelica makes very few assumptions on the solver that is used).
The only way to know what mode you are in is to use a sampled system and call your external function at these points (because then you know you are at a time or state event).
It says missing "each", right?
Code:
model M
Real r[3](start = 3.0) = {1,2,3};
end M;
vs. valid model:
Code:
model M
Real r[3](each start = 3.0) = {1,2,3};
end M;
There is no step size in a variable-step solver. Modelica intentionally does not allow you to query this information because you don't even know if the simulation will rely on the concept of time (e.g. using QSS).
If you must know step sizes, export as FMI for Model Exchange and implement the solver yourself.
If you don't want to be portable, write an external C-function and #include the necessary headers from the OpenModelica simulation runtime and start querying the internal state for information. You'll need to implement this differently for each numerical solver you want to access the internals for since most of this information is not used by OpenModelica. You won't know the "current" step size until it's done though; you can probably access the previous step at best since external functions must always give the same output regardless of input (except during discrete events, but at discrete events there is no step size since time does not progress).
So your issue is that code such as the following should work, but does not - right?
Code:
model M
record R
Real x,y;
end R;
function sample_model
input R r;
output R res;
external "C" sample_solver(r, res);
end sample_model;
R r = sample_model(R(time,time));
end M;
If so it should be possible to fix it.
Never mind, I'm stupid. It says further down if it's lhs, it is passed by value instead of reference...
https://specification.modelica.org/mast … ml#records
You cannot pass a record by value.
The .mat-file should always be exported with double precision unless you explicitly passed it
Code:
-single
. Open it in Matlab/Scilab/Octave and you should see the full precision.
There is a simulation flag (https://openmodelica.org/doc/OpenModeli … lags.html) for that:
Code:
$ ./M -lv LOG_STATS
LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_STATS | info | ### STATISTICS ###
| | | | | timer
| | | | | | 0.000294868s reading init.xml
| | | | | | 4.1369e-05s reading info.xml
| | | | | | 0.000147484s [ 3.6%] pre-initialization
| | | | | | 7.5327e-05s [ 1.8%] initialization
| | | | | | 5.107e-06s [ 0.1%] steps
| | | | | | 2.627e-05s [ 0.6%] solver (excl. callbacks)
| | | | | | 0.000536842s [ 13.1%] creating output-file
| | | | | | 0s [ 0.0%] event-handling
| | | | | | 0.000217657s [ 5.3%] overhead
| | | | | | 0.00303205s [ 73.8%] simulation
| | | | | | 0.00417501s [100.0%] total
| | | | | events
| | | | | | 0 state events
| | | | | | 0 time events
| | | | | solver: euler
| | | | | | 500 steps taken
| | | | | | 500 calls of functionODE
| | | | | | 0 evaluations of jacobian
| | | | | | 0 error test failures
| | | | | | 0 convergence test failures
| | | | | | 0s time of jacobian evaluation
LOG_SUCCESS | info | The simulation finished successfully.
Gabri wrote:
basically what I want to implement in my code is the following logic:
when a variable reaches a determined value, then stop the simulation.
In the case in the example is when F=20 then stop the simulation.
Code:
model M
Real F = ...;
equation
when F < 20 then
terminate("F successfully reached <20");
end when;
end M;
https://build.openmodelica.org/Documentation/ModelicaReference.Operators.%27terminate()%27.html
If you want to see slightly better error-messages, call
Code:
OpenModelica.Scripting.loadModel("xxx"); getErrorString()
Code:
[model.mos:1:1-1:39:writable] Error: Failed to elaborate "xxx" as a code expression of type OpenModelica.Code.TypeName.
You don't seem to have the lsb_release command installed. Install the lsb-release package first - it's usually installed in any desktop or server version, but not in minimal versions.
Many of us have no experience in modeling as we are in computer science. A minimal model showing the problem is very important to get good help. Also, it seems this error message does not come from OpenModelica, so it would be even harder to help you...
If you have a variable x that has start-value 0 and is part of a non-linear system, we need to know if x is expected to be a very large or very small value in order for the non-linear system solver to scale better. These are files in the simulation runtime using the attribute:
Code:
$ grep -RI nominal OMCompiler/SimulationRuntime/c | cut -d: -f1 | uniq
OMCompiler/SimulationRuntime/c/optimization/DataManagement/MoveData.c
OMCompiler/SimulationRuntime/c/linearization/linearize.cpp
OMCompiler/SimulationRuntime/c/util/simulation_options.c
OMCompiler/SimulationRuntime/c/simulation_data.h
OMCompiler/SimulationRuntime/c/simulation/simulation_input_xml.c
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSolverNewton.c
OMCompiler/SimulationRuntime/c/simulation/solver/linearSolverTotalPivot.c
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSystem.c
OMCompiler/SimulationRuntime/c/simulation/solver/dassl.c
OMCompiler/SimulationRuntime/c/simulation/solver/perform_simulation.c.inc
OMCompiler/SimulationRuntime/c/simulation/solver/kinsolSolver.c
OMCompiler/SimulationRuntime/c/simulation/solver/radau.c
OMCompiler/SimulationRuntime/c/simulation/solver/linearSystem.c
OMCompiler/SimulationRuntime/c/simulation/solver/dae_mode.c
OMCompiler/SimulationRuntime/c/simulation/solver/ida_solver.c
OMCompiler/SimulationRuntime/c/simulation/solver/initialization/initialization.c
OMCompiler/SimulationRuntime/c/simulation/solver/perform_qss_simulation.c.inc
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSolverHybrd.c
OMCompiler/SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c
OMCompiler/SimulationRuntime/c/openmodelica_func.h
https://trac.openmodelica.org/OpenModelica/ticket/5856
The workaround is to input it using radians instead (Modelica.Constants.pi / 2 for example), until there is a new nightly build (where I output full precision scientific format). I'll let Adeel (the OMEdit maintainer) fix this properly when he is back.
There is no GasConvection class in the standard library; what library are you using?
OMEdit uses command-line options to set the output log format to xmltcp and then uses a TCP client to read the messages, including status information. I believe they include the progress information.
I believe you can also send the SIGUSR1 signal and the simulation prints out some status message.
Call /bin/rm to remove some files?
"default" means the latest released version of the library which might change next time you open OMEdit.
You are not limited to the MODELICAPATH. Either modify the env.variable OPENMODELICALIBRARY to append to MODELICAPATH.
Or add it to the "User libraries" part of the same settings page to add any library's package.mo (or a top-level *.mo file) to add any library you prefer.
You indeed input 3.2.3 if you want version 3.2.3. Just remember to restart OMEdit for the changes to apply.
Env.variable OPENMODELICALIBRARY can be used
I believe this is a bug in OpenModelica. You probably want to open a ticket. Since it works if the record has more than 1 member, it is working in most useful cases and the compiler probably has some odd edge case for records with only 1 element ...
The OpenModelica simulation runtime system already has a different license from the rest of OpenModelica: the code provided by us is BSD-licensed as an option (https://openmodelica.org/osmc-pl/osmc-p … time.txt). Some third-party code in it is LGPL-licensed though.
I can't remember what year the runtime license was introduced, but I suspect this thread is older
If you get an error from your standard library, that stdlib.h does not exist I suggest creating a bug with gcc
I also would not compile OMOptim - we don't as it's not maintained.
git checkout maintenance/v1.14 for a branch with few changes coming to it. master has more development, new features, support for newer OSes, etc. The master branch is usually quite stable (as in: it often works, especially on Linux).
Xwang1976 wrote:
I would like to now:
1) is it necessary or useful to have a working --with-cppruntime option?
2) are those filed test something I have to worry about?
3) analysing the resulting arch linux package with namcap (https://pastebin.com/YvguK07W), I see that there are a lot of "Unused shared library" messages. Should I worry about it and in case is there any compilation option I can use to reduce/avoid them?
1. Not needed
2. The failed tests usually happen because you don't use the same numerical solvers as the test system (an Ubuntu 18.04 docker image)
3. There are also many libraries not found, etc. It's probably because the tool does not know about our rpath settings (used so we don't conflict with OS versions of the same libraries)
You could also use a Python script or whatever to generate this file. Then open it in Dymola.
There are docker images of OpenModelica. They work just fine even with GUIs according to my testing
As far as I remember, AppImage is only 1 application - OpenModelica is many different applications and depends on having things like entire development toolchains installed.
Seems your OpenBLAS does not support these lapack routines. I wonder if it's related to:
https://trac.openmodelica.org/OpenModel … enModelica
Well, you could look in the result file: If there is a der(x), x is a state variable.
You could also look in the _init.xml file:
Code:
<ScalarVariable
name = "x"
valueReference = "1000"
variability = "continuous" isDiscrete = "false"
causality = "internal" isValueChangeable = "true"
alias = "noAlias"
classIndex = "0" classType = "rSta"
isProtected = "false" hideResult = "false"
fileName = "/home/marsj/tmp/a.mo" startLine = "2" startColumn = "3" endLine = "2" endColumn = "9" fileWritable = "true">
<Real fixed="false" useNominal="false" />
</ScalarVariable>
classType = "rSta" is a state variable.
https://specification.modelica.org/v3.4 … xperiments basically stores default simulation settings.
Follow the guidelines given above. The error message tells you that your system is switching very fast between two states. This forces the integrator (dassl, etc) to restart frequently, killing performance.
Using some hysteresis is probably best. And sometimes noEvent() can help you in if-statements.
It's not necessarily going to be (much) longer. You simply declare the variable in the partial model and modify it in the extends clause.
That is because you have
Code:
package Enu=EnumerationBase1(option=Options.B);
. Options is not available in the scope of ModelicaTests2.EnumerationTest2. It works if you have it as option=EnumerationBase1.Options.B
That's easy to answer: because the CentOS8 docker image was not released last I checked (24 September) and the RH free images don't have access to most useful packages. I'll see if it can be enabled.
Choose csv as the output format when you simulate:
Code:
marsj@marsj-Precision-5510:~/tmp$ ./wurf -override outputFormat=csv
LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
LOG_SUCCESS | info | The simulation finished successfully.
marsj@marsj-Precision-5510:~/tmp$ head -2 wurf_res.csv
"time","geschwindigkeitX","geschwindigkeitY","wegX","wegY","der(geschwindigkeitX)","der(geschwindigkeitY)","der(wegX)","der(wegY)","beschleunigungX"
0,0.8661580944054629,0.4997701026431026,0,1,0,-10,0.8661580944054629,0.4997701026431026,0
It's in the stdout - it's output in the console when you run the executable.
Of course OpenModelica will not output a dslog.txt (Dassault Systemes log dot txt)... We produce the log on stdout like normal Unix tools
Does
Code:
if (abs(relVel) < eps)
solve it?
As far as I can tell it simply uses the communicationStepSize sent to it by the master algorithm. It will not try to take smaller steps than that.
You would need to create one input file for each run . Of course you could have it as a matrix in a mos-script and create the 140 input files. Then use -overrideFile fileNameXXX where the file contains one line for each parameter on the form PARAMETER=VALUE. It is also possible with -override=p1=1,p2=2,p3=3,...,p20=20
Simply use command-line git from the operating system. It is really simple to use. No git integration only means you need to remember to add new or moved files, etc.
Use git
The only integration method you can set for co-simulation FMUs is Euler. Dassl is not supported.
I am guessing you are sampling something every 1000s so you have event points at these steps. Use the simulation flag -noEventEmit
to not store those in the file.
That's made with a script called BuildModelRecursive.mos (which is included in your OpenModelica installation).
We have a newer version used at: https://libraries.openmodelica.org/branches/
That is generated by a script in https://github.com/OpenModelica/OpenMod … aryTesting
You will need to run getErrorString() afterwards to see what the error is.
The way the official builds compile OpenModelica, we rm -rf OMOptim before the ./configure command to skip compiling it
1) Yes, they are. In the latest nightly we also set the SourceFiles parts in the XML so the importer knows which files to compile. You still need to set predefined values using -DXXX if you need to tweak something for the target (usually done by a configure script).
Check only does a quick check that things might work, but it will not detect things like:
Code:
model M
Real x,y;
equation
y = 1.0;
3.0 = 2.0;
end M;
In some cases at least the latest OpenModelica will give a hint that things are a bit off. But in many cases no analysis of the possible cause of the error is given.
So you mean that you want to save io11 for each iteration of the array? That you could do also with a for equation and using an array for each iteration index:
Code:
Real io11[np];
equation
io11[1] = 0;
for i in 2:np loop
io11[i] = io11[i-1] + 1;
end for;
You will want to use an algorithm section instead of an equation: a loop such as:
Code:
for i in 1:2 loop
i = i + 1;
end for;
Is expanded into:
Code:
1 = 1 + 1;
2 = 2 + 1;
In an algorithm section the values are kept during the loop (note that I and Iph also need to be part of the same algorithm section or you will have double assignments):
Code:
for i in 1:2 loop
i := i + 1;
end for;
Yeah, that path looks a bit messed up and needs a ticket for one of our windows developers to have a look.
I tested using Linux and OMSimulator and added some debug print to see that it's doing what it should:
Code:
path to load: /home/marsj/tmp/tmp2/KS_Tables/LookUp/myTable.txt
Resources dir: /home/marsj/tmp/tmp2/model-ca9vdzfd/temp/fmu/resources
Result: /home/marsj/tmp/tmp2/model-ca9vdzfd/temp/fmu/resources/home/marsj/tmp/tmp2/KS_Tables/LookUp/myTable.txt
With Linux and fmuCheck.linux64:
Code:
path to load: /home/marsj/tmp/tmp2/KS_Tables/LookUp/myTable.txt
Resources dir: /tmp/fmucktmp1H9wDU/resources
Result: /tmp/fmucktmp1H9wDU/resources/home/marsj/tmp/tmp2/KS_Tables/LookUp/myTable.txt
So it should work fine... I suppose if you use Windows, the long paths aren't particularly helpful though
Yes, the OSMC-PL 1.2 runtime license applies to the runtime system we use. Note that third-party code (such as uthash.h) might also exist in there.
Yes, might be good to open a ticket. I not only want to fix the problem, but give a diagnostic message when we fallback to copying all the files into the FMU...
I should note that it's a very old library and probably won't work very well in OpenModelica as many things were not standardized at this time.
We do that if we have a call to uriToFileName(xxx) where xxx is not a constant string that we can resolve at compile-time. And for the MSL, it seems that the loadResource function is not marked with Inline=true.
I think the best fix would be for us to change ModelicaServices.ExternalReferences.loadResource to be marked Inline=true.
Yes, you can strip out the source code from a generated FMU and redistribute only the binary provided that you add a text to the FMU documentation regarding the license: "[...] Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. [...]" (along with the licenses of any Modelica libraries you used to generate the binary, given their licensing terms).
Of course it's possible. I recommend doing it by hand.
It's just that the default loaded MSL is 3.2.3 and the model you load has a uses-annotation for MSL 3.2.2. It is possible to change the default MSL in OMEdit if you want to use the old library (Tools->Options->Libraries.
I have never seen any Linux distribution enable auto-run since it's a huge security risk. The image will automatically mount the CD-ROM and it will open up the directory where the installer exists. Just right-click and open a terminal to run the shell-script (which is not marked executable, so you can't double-click it and expect it to run). Just type: "sh autorun.sh" and it installs fine.
The base disk image was created in VirtualBox (manually). OpenModelica is then installed using chroot and vdi-image is created from this; for this reason grub is not updated during the installation. We could include the virtualbox additions in the image, but I think this is not a great idea due to different virtualbox versions out there.
That's up to the FMU importer to implement. OMSimulator had some experimental real-time synchronization before its API changed
Arinomo23 wrote:
why was it not
Code:
#include "include/fmi2/fmu2_model_interface.h"
Because we have multiple ways of compiling the FMU; you can compile against the library and include files in the OpenModelica directory directly in some cases.
I would strongly suggest using the provided configure script and makefiles inside the FMU. The Makefile will contain things like:
Code:
override CPPFLAGS += -Iinclude/ -Iinclude/fmi2 -I. -DOMC_MODEL_PREFIX=M -DOMC_NUM_MIXED_SYSTEMS=0 -DOMC_NUM_LINEAR_SYSTEMS=0 -DOMC_NUM_NONLINEAR_SYSTEMS=0 -DOMC_NDELAY_EXPRESSIONS=0 -DOMC_NVAR_STRING=0
Which is different for different generated models. Note that the makefiles listed above says the prefix is KS_TA_HiL_Internal_SignalScaling, but the linking error has a different expected name...
Also note that you have -Wl,--output-def=KS_TA_HiL_Internal_SignalScaling.def in CPPFLAGS, which are preprocessor flags. It is a linker flag and might not be present when linking since it's not in LDFLAGS.
You FMU importer decides how to deal with time. If you want real-time synchronization you implement this in the master. If you want the simulation time to be different in different connected FMUs, you can implement this as well. The FMU itself has very little knowledge about this.
Both the library developer and you need access to the OpenModelica encryption/decryption tool. It should not matter if the library was developed in Dymola, but you will not be able to access encrypted libraries targeting Dymola's private encryption keys and the library develop will not be able to enforce license restrictions (anyone with the encrypted library can use it; but with access annotations won't be able to see everything).
https://www.openmodelica.org/doc/OpenMo … ption.html
As for the membership level, if the library developer is a level 2 member, they could distribute the encryption/decryption tool to you as far as I know. If both of the companies have a level 1 membership, you can both have access to the encryption/decryption tool.
Note that the encryption/decryption support is still quite recent work and being tested by some OSMC members and library developers. It might be that decryption support becomes free in the future when license restrictions are supported. But I don't know our plans.
Yes, the VM is generated by vagrant because it was convenient to script using it. But it seems the image has changed such that only serialport communication is used. When I get a little more time I will setup new VM builds. Until then, just take any Ubuntu image and follow the Linux installation instructions
You could look at https://github.com/modelica/ElectricalEnergyStorage
I haven't tried it myself, but it has some basic battery functionality
In OMEdit, basically any image format supported by Qt should work as far as I know. For other Modelica tools, it might not work. SVG support is staged to be part of a future Modelica specification version: https://github.com/modelica/ModelicaSpe … issues/174
gcc works fine as well (but only some versions of gcc; especially some recent gcc versions broke backwards compatibility)
It might be if you specify the platform as:
"x86_64-apple-darwin15 docker run docker.openmodelica.org/osxcross-omsimulator:v2.0"
You would need docker installed, Hyper-V enabled and virtualization in the BIOS. You probably need to run a mos-script or modify your omedit.ini:
[FMIExport]
FMUName=
Platforms=none, x86_64-apple-darwin15 docker run docker.openmodelica.org/osxcross-omsimulator:v2.0
Type=me_cs
Version=2
Note that this has not been tested on Windows and has no nice GUI in OMEdit.
A complete copy of Sundials is included in OpenModelica; the OS-provided version should not be used. If it somehow is used, please provide a pull request fixing linking order.
My guess would be that the OS version you use and the OS version omc was compiled on do not match, because it crashes during initialization of ZeroMQ. It could also be that you are using an older version of OMC before the ZeroMQ fixes.
- Index
- » Users
- » sjoelund.se
- » Profile