- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to use a configuration file to...
How to use a configuration file to initialize parameters
How to use a configuration file to initialize parameters
Hi,
in order to run some simulations with different parameters, I would like to read a configuration file which initializes the parameters for my models.
I'm using dymola so to start a model form a shell after compiling it with dymola I simply type in
./dymosim dsin.txt. /dev/null
the dymosim is the binary file compiled by dymola/modelica dsin.txt is a configuration file created by dymola with the information of start and stop Time variable names etc., where the /dev/null is the 'place' where dymosim should put the result.mat file. Since my simulation file exceeds the space of 2GB I can't plot it in dymola, so I'm using a printer written in C to create the result file with just the informations of interest which of course makes the file small (to view the results I'm using QT octave).
Anyway, I would like to have one parameter more like
./dymosim dsin.txt. /dev/null myconfigfile.txt
where I can put the initial parameters. Or add the informations to the dsin.txt .
At the moment I have about 15 exactly same looking models with just some different parameters to do the simulation.
In order to simulate I have to compile the particular model and than run it in the shell (on an another PC which is faster).
So after changing some things I always have to compile it 15 times also the parameters of one particular model of these 15 models never change.
So my idea is to just compile it ones and than read the configuration at execution time, maybe with a nice shell-skript, so that I can invoke it in the evening and watch the results in the morning.
Has anybody any nice solution or idea to this problem ?
Thank you so fare
lrohr
Re: How to use a configuration file to initialize parameters
Hi,
That should be easy, you just need to:
1. generate your .exe for the model, say via buidlModel(Modelica)
2. rewrite the Model_init.txt file with new parameter values.
3. call the Model.exe then go to step 2.
Mohsen (http://www.ida.liu.se/~mohto/) has written a Python based framework
for doing the above thing and he has a paper about it. I sent him an email and
maybe he can help you out more.
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: How to use a configuration file to initialize parameters
Hi again,
Well, i might have misunderstand you and you are asking on how to do this in Dymola, which I don't really know.
I answered your question thinking you want to do this in OpenModelica, which is a Modelica tool developed by us.
Please let us know what you're actually referring to, OpenModelica or Dymola?
Cheers,
Adrian Pop/
- adrpo
- 885 Posts
Re: How to use a configuration file to initialize parameters
Hallo and thank you for your answer.
Actually I don't care which compiler to use, as long as the code can be compiled and maintenanced in dymola.
So if it is an easier way to do it with openmodelica I'm going to use it. But for some reason, this project have to work in dymola. But it works, it's just (as I explained) not comfortable to run all the simulations.
Do I need to get root access to install the openmodelica compiler ? Which I wouldn't get, I know said thing working on linux without admin rights :-(
Re: How to use a configuration file to initialize parameters
It is possible to install OpenModelica without root access. I wouldn't recommend trying to build it from source yourself unless you already have all dependencies installed though (there are a lot of dependencies; I'd recommend not compiling with Qt for example).
You could take the required .deb-files from http://build.openmodelica.org/apt/pool/contrib/, unpack them into some directory and set some environment variables to get everything going. (Setting your own PATH variable to include the bin directory, setting OPENMODELICAHOME to the directory and OPENMODELICALIBRARY to $OPENMODELICAHOME/share/omlibrary/modelicalib/). If your Linux installation contains the runtime dependencies, you are fine.
- sjoelund.se
- 1700 Posts
Re: How to use a configuration file to initialize parameters
Hi,
(this is just a paranthesis since we are not representing Dymola, however I believe that Dymola have similar script language to OpenModleica and it should be possible to change the initial file containing information about the parameter values that you are looking for. If you are using Matlab for re-simulating your(exported) Modelica model then this is done quite easy with the dymosim script in Matlab
% [p,x0,pnames,x0names,inputnames,outputnames] = loaddsin('dsin.txt');
% [s,n] = dymosim([0,T_sim,0,dT_nr,1e-9,8],x0,p,'quiet'); % Calling dymosim with new values and paramters
the p is the vector containing the paramter values and in the above call 0 is the starting time and T_sim is end time.)
In the http://openmodelica.org/dmdocuments/SIM … -final.pdf the interoperability of OpenModelcia is disscussed with the aim of re-running simulations with new parameter values. I've upploaded a sample code for this interface under Home-> Applications->script->MonteCarlo. Look at the package and it contains Python scripts calling OpenModelica
Best Regards
Mohsen
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » How to use a configuration file to...