Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

dymola - Could I define new variables in the Modelica script?

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...