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
  • Index
  • » Users
  • » namcho
  • » Profile

Posts

Posts

Jun-13-19 06:42:21
Can't pass script variable to setParameterValue function's 3rd argument.

I've been using a script file to do my simulation. Currently working with nightly-build version that is 1.14.0-dev.

Code:

loadModel(Modelica); getErrorString();

loadFile("C:/Users/namcho/Documents/Tez_DAB/Simulation/MachineLearningAlgo/DAB_ideal.mo"); getErrorString();
loadFile("C:/Users/namcho/Documents/Tez_DAB/Simulation/MachineLearningAlgo/uControllerDAB.mo"); getErrorString();
checkModel(DAB_ideal);
Kp := 1.2;
Ti := 5e-5;
Td := 0;
typeOf(Kp);

setParameterValue(DAB_ideal, PID_Kp, Kp); getErrorString();
setParameterValue(DAB_ideal, PID_Ti, Ti); getErrorString();
setParameterValue(DAB_ideal, PID_Td, Td); getErrorString();

instantiateModel(DAB_ideal);

In the code above I want to pass Kp's value to my DAB_ideal model. If I try as above, it gives the following error when run with omc.exe

[C:/Users/namcho/Documents/Tez_DAB/Simulation/MachineLearningAlgo/DAB_ideal.mo:3:3-3:20:writable] Error: Variable Kp not found in scope DAB_ideal. Error: Error occurred while flattening model DAB_ideal

If I try setParameterValue(DAB_ideal, PID_Kp, 1.2); it works.

How can I pass that Kp's value to setParameterValue function? I've tried PowerShell $ symbol(and a couple more different symbols) to pass the Kp's value to the function this didn't work either.

My aim is to read those Kp, Ti and Td parameters from a text file and update my model parameters.

  • Index
  • » Users
  • » namcho
  • » Profile
You are here: