Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

how to create a .mos script ?

how to create a .mos script ?

hello everyone,

i'm new at OpenModelica, and i would like to know how can i create a .mos script that can allow me to control the simulation of my model.

Thank you

Re: how to create a .mos script ?

Do you want to create script file that execute a simulation?
If so you can read here
OMShell and OMNotebook introduction and exercises
Page.3

And I write down small overview.

1.
Simulation execution script is written by some text editor and save as .mos file.
Code example is following

Code:


loadModel(Modelica);
cd("directory address);
loadFile("File name");
simulate(model name,startTime=0,stopTime=1 ...  );

2.
Go to the directory of .mos file using cd() command in OMSell.

3.

Code:


runScript("mos file")

Then the script start.

If you want to control parameter value according to a result, I don't know how to creat.

Regards,

Edited by: Ueda - May-22-17 19:11:38

Re: how to create a .mos script ?

Thank you Ueda for your response.

I have another question, can we use FOR loops in a .mos script ?

Nasrou

Re: how to create a .mos script ?

You are welcome Nasrou.

Maybe for loop can not be used.
Beause there is no loop command in this list
https://build.openmodelica.org/Document … pting.html

If you want to make many similar commands,
you have to make another program by another language.

If you find how to use for loop,
please teach me.

Add to
I will fix the above reply.
I found for loop example from your forum.
https://openmodelica.org/doc/OpenModeli … eter-sweep
Good luck

Ueda

Edited by: Ueda - May-24-17 02:42:40

Re: how to create a .mos script ?

Yes, Thanks to Adeel.

Apparently, we can do FOR loops in a .mos script, it's a good thing because we can run several simulations with just a for loop.

Nasrou

There are 0 guests and 0 other users also viewing this topic
You are here: