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

setParameterValue() in a loop

setParameterValue() in a loop

Hello all,

i´m new in this forum and i hope someone of you can help me with my little problem.

Like i already wrote in the description above, i would like to use the command setParameterValue() in combination with a loop (e.g. a for-loop). The aim of my interest is to change a parameter automatically at each iteration. When i use an Integer, e.g setParameterValue(Widerstand,R1,100), everything works fine, but if i want to use the command like that:
i:=10;
setParameterValue(Widerstand,R1,i);
OmShell does not transfer the value 10 but the character i.


I created a small example, using an ohmic Resistance, which is attached (File: Resistance.mo).

This is my small skript in which i want to change the resistance value to i=10 (the loop is disregarded knowingly):

clear();
loadModel(Modelica);
loadFile("./Resistance.mo");
i:=10;
setParameterValue(Resistance,R1,i);
simulate(Resistance, startTime=0, stopTime=25, outputFormat="csv");
plot(resistor1.R_actual);

I already tried different possibilities like: setParameterValue(Resistance,R1,Value(i)); or something like that, but nothing worked.

Best Regards

odyssey




Resistance.mo

Edited by: odyssey - Oct-08-14 09:40:07
Attachments:
There are 0 guests and 0 other users also viewing this topic
You are here: