@arun3688 arun3688 @JKRT RT @AnHeuermann AnHeuermann
I am using OpenModelica and I am trying to read the output (i.e., s here). I tried several ways but could not succeed. Any idea to solve that?
using OMJulia
omc= OMJulia.OMCSession()
sendExpression(omc,"loadModel(Modelica)")
true
sendExpression(omc,"model a Real s; equation s=sin(10*time); end a;")
1-element Array{Symbol,1}:
:a
sendExpression(omc,"simulate(a)")
L = sendExpression(omc,"readSimulationResult(a_res.mat)") # does not return anything
L = sendExpression(omc,"readSimulationResult(a_res)") # does not return anything
L = sendExpression(omc,"readSimulationResult(s)") # does not return anything
@Amro, You have to use getErrorString() API after every sendExpression() to see the error messages, And also the readSimulationResult() API requires two argument as input, first result file and second names of the variables as a list, So you should use something like below
The usual way to achieve this in Modelica is by having k be of “parameter” variability. K can then be overridden/set for new simulations without having to recompile.
There is no documentation as far as I know, and the Windows version of OpenModelica doesn’t run on my Windows work computer. Only the WSL version works… Maybe adding $OPENMODELICAHOME/bin is enough. I’m not sure.
You could do it inside of the Julia process or only setting it when calling the simulation executable. Note that you will need to expand OPENMODELICAHOME and it’s probably not set in the global environment unless you have an older installation. You can use Scripting API — OpenModelica User's Guide v1.20.0-dev-270-g1a840876db documentation to query it