Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to run a Modelica script in Dymola, but I got an error when defining a variable in the script, as shown below:

     Modelica.SIunits.Distance testData=2;
     Boolean success;
     success := clearlog();
     Modelica.Utilities.Streams.print("Simulation result was:");
     Modelica.Utilities.Streams.print("Distance = " + String(testData) + " m");

enter image description here

My question is:
Could I define new variables in the Modelica script?
I didn't find any regulation or chapter about the Modelica script file in the Modelica Specification 3.4, is there any reference material for Modelica script file specification?

question from:https://stackoverflow.com/questions/65861610/could-i-define-new-variables-in-the-modelica-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
333 views
Welcome To Ask or Share your Answers For Others

1 Answer

Dymola just declares new variables based on assignments to the entire variable.

It should work for Real, Integer, Boolean, String, arrays and records.

However, it must be an assignment to the entire variable - so v[1]:=2; doesn't generate a vector.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...