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

buildModel simulate ; system -> exe overrideFile

buildModel simulate ; system -> exe overrideFile

Hi,

we have a question. In the attachement you can find 3 files (http://141.24.208.101:88/task/modelica_forum.rar).
we wanna execute runScript("reaction2b.mos"); on the OMShell.

All is working fine in the following order in the file:

loadFile("reaction2.mo");
simulate(reaction2);
system("reaction2.exe -f reaction2_init.xml -overrideFile=reaction2_param.txt");
plot({xA,xB});

BUT
we have to do the simulate everytime before with the wrong parameters to get the system and the plot command work.

we try this
loadFile("reaction2.mo");
buildModel(reaction2);
system("reaction2.exe -f reaction2_init.xml -overrideFile=reaction2_param.txt");
plot({xA,xB});

with buildModel also all files are builded. But with buildModel the system command and the plot command than gives 0 or false.

1. question:
Why we have to use simulate first? buildModel will do the same we think? what is the difference between these two commands?

2. question:
We dont wanna simulate everytime at first with wrong parameters. Because in the system command we use overrideFile to give the new parameters.
Is there a way to use the system command and after that the plot without simulate?

Re: buildModel simulate ; system -> exe overrideFile

1. answer:
Simulate & buildModel are same except that buildModel only compiles the model and generates the simulation executable whereas simulate compiles the model, generates the simulation executable and runs it.

2. answer:
You should use buildModel but note that buildModel doesn't set the default result filename for the environment so you need to specify a resutl filename to plot. Use the following code,

Code:

loadFile("reaction2.mo");

buildModel(reaction2);
system("reaction2.exe -f reaction2_init.xml -overrideFile=reaction2_param.txt");
plot({xA,xB}, fileName="reaction2_res.mat");

Adeel.

Re: buildModel simulate ; system -> exe overrideFile

BIG THX. Very helpful. it work

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