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

Passing multiple values with .mos script

Passing multiple values with .mos script

package HePackage

package Systems

model Syslam_Q5
  HePackage.Components.Hlam hlam(
    UCfile=
        "C:/Users/Pikachu/Docs/i_v2/H50.txt",
         A_HS_mod1 =0.0786
         CSize_flag=false,
         A_HS_mod2 = {0.0914,3.01,3.01,3.01,1.38,1.38,1.62,1.62,1.62}
         A_HS_mod3 = {0.0223,3.01,3.01,3.01,1.38,1.38,1.62,1.62,1.62}
         A_HS_mod4 = {0.0245,3.01,3.01,3.01,1.38,1.38,1.62,1.62,1.62});
end Syslam_Q5;

end Systems;

package Components
model Hlam
   parameter String UCfile = "";
   parameter Real A_HS_mod1 = 1.0
   parameter Real A_HS_mod2 = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0}
   parameter Real A_HS_mod3 = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0}
   parameter Real A_HS_mod4 = {0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}
   parameter Boolean CSize_flag = false;
end Hlam;
end Components;

end HePackage;


while creating .mos file for this modelica model with python i'm able to do it for single value.
but when I do it for multiple values i'm getting error as "failed to build model package".
File : modifiers.mos

loadFile("HePackage.mo"); getErrorString();
list(HePackage.Systems.Syslam_Q5); getErrorString();

setElementModifierValue(HePackage.Systems.Syslam_Q5, hlam.A_HS_mod1, $Code(=1.0)); getErrorString();
setElementModifierValue(HePackage.Systems.Syslam_Q5, hlam.CSize_flag, $Code(=true)); getErrorString();
setElementModifierValue(HePackage.Systems.Syslam_Q5, hlam.A_HS_mod2, $Code(={2.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0})); getErrorString(); #This cause failure during model building
setElementModifierValue(HePackage.Systems.Syslam_Q5, hlam.A_HS_mod3, $Code(={3.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0})); getErrorString(); #This cause failure during model building
setElementModifierValue(HePackage.Systems.Syslam_Q5, hlam.A_HS_mod4, $Code(={4.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0})); getErrorString(); #This cause failure during model building
list(HePackage.Systems.Syslam_Q5); getErrorString();

How to create a .mos file which takes input multiple values for sngle variable ?

Edited by: Thamizh - Feb-09-22 08:08:09
There are 0 guests and 0 other users also viewing this topic
You are here: