- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Using -overrideFile and -override
Using -overrideFile and -override
Using -overrideFile and -override
Can anyone tell me how to use the -override and the -overrideFile tag?
I am trying with a simple example posted by adrpo but I don't know where I go wrong.
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;
After compiling and simulating I want to simulate again with modified initial values. Therefore I thought that I need to set the simulation flag:
Code:
-override=b=100
If I do so nothing happens. No error message and no simulation.
Does anybody know what I am doing wrong? I did not set the flag Evaluate all parameters.
I am having the same problem with -overrideFile
I am using OpenModelica v1.15.0.
Re: Using -overrideFile and -override
Is this command line? Or via OMEdit?
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
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.
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
Thanks for your reply.
The thing is that I want to change initial values using the -overrideFile flag.
I am building a bigger system and (fast) initialization is an issue. Therefore I am creating smaller sub-systems and use the values found for the initialization in the bigger system. So I am trying to export the final solutions of the initialization from the smaller sub-systems and use them in the bigger models.
I do not want to type them by hand.
How do I do this using OMEdit?
Re: Using -overrideFile and -override
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
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
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.
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
Thank you very much!
Code:
-overrideFile=c:/path/to/override_file.txt
Is exactly what I do not get to run.
I get:
Code:
Simulation process failed. Exited with code -1.
My txt contains only:
Code:
b=10.0
Thaks for the hint with the update!
I am downloading the nightly build at the moment...
Re: Using -overrideFile and -override
I think it exits because you need the latest nightly, before the simulation executable didn't run if you used both -override and -overrideFile.
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
I have installed the latest nightly build but it still does not work.
Could tell me if I am doing it the wright way?
In the Simulation Setup under Simulation flags, additional Simulation Flags (Optional) I type:
-overrideFile=Ca.txt
the file then contains nothing but:
b=10
It compiles and simulates but the value of b is not set to 10. I also tried with a backslash instead.
What also does not work is:
-override=b=10
Re: Using -overrideFile and -override
Well it does work but only if I don't set any value for b in the first place:
Code:
model TestOverride
parameter Real a=1;
parameter Real b;
parameter Real c = 3;
parameter Real d = 3;
Real x(start=a, fixed=true);
equation
der(x) = b*c*d*x;
end TestOverride;
Is that the functionality of the overrideFile flag?
I could try and use that but it is not really practical I think.
Re: Using -overrideFile and -override
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
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
Thank you very much!
You are wright!
I trusted the numbers in OMEdit.
Could you also tell me a good way to export only the initial values?
As of now I am using the LOG_SOTI flag but I still have to apply quite some changes by hand. There has to be a better way of doing this.
Re: Using -overrideFile and -override
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.
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
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.
- adrpo
- 885 Posts
Re: Using -overrideFile and -override
Thank you very much!
That flag would be very useful!
Just one more thing I think would come in handy would be the option to re-simulate using the solution of the initial values of the previous simulation as a flag.
I am starting in steady state and after a few seconds I am running different scenarios. Solving the initialization problem every time again is a little frustrating since it takes quite some time, or is there already a way to avoid that?
I am guessing that what I am doing is done by numerous other users as well.
Re: Using -overrideFile and -override
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
- adrpo
- 885 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Using -overrideFile and -override