OMJulia simulate command returns error

OK – your Modelica code runs – with a warning – in OpenModelica 1.14.1, which is the one I have on my computer.

[1] 09:02:19 Translation Warning
[RLC: 24:2-24:18]: The following equation is INCONSISTENT due to specified unit information: V_R = i_R ^ 3.0 + 4.0 * i_R


[2] 09:02:19 Translation Warning
The units of following sub-expressions need to be equal:
- sub-expression "i_R ^ 3.0 + 4.0 * i_R" has unit "Gm6.s-9.A-3.g3"
- sub-expression "V_R" has unit "V"

[3] 09:02:19 Scripting Notification
Check of RLC completed successfully.

Result (some variables):

I can now run it from Julia (I have Julia v. 1.6.1 in my laptop; I run it from a Jupyter notebook, which is located in the same directory as the Modelica file):

using OMJulia, Plots

RLC = OMJulia.OMCSession()
ModelicaSystem(RLC,"RLC.mo","RLC")

I can query the simulation settings:

julia> getSimulationOptions(RLC)
Dict{Any, Any} with 5 entries:
  "startTime" => "0"
  "stopTime"  => "1"
  "solver"    => "dassl"
  "stepSize"  => "0.002"
  "tolerance" => "1e-006"

I can check which variables are available:

showQuantities(RLC)

resulting in a data frame:

The above is useful to check the names you can request (“get”) after simulation…

Next, simulating the system and getting results:

simulate(RLC)
tm, v_L, L, v_R, i_C = getSolutions(RLC,["time","V_L", "L", "V_R", "i_C"]);

plot(tm,[v_L,L,v_R,i_C],label=["V_L" "L" "V_R" "i_C"])

leading to:

Can you recheck your code and do what I’ve done above? If your code still doesn’t work, two possible explanations:

  • there is something wrong with your OMJulia installation, or
  • OMJulia has not been updated to the latest versions of OpenModelica

To get you further, you may need to get in touch with the OpenModelica people (I hope I can help you with that; depends on whether the developer is still with the OpenModelica group).