Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProcessFailedException when using ModelicaSystem #82

Closed
bc0n opened this issue Aug 15, 2023 · 6 comments
Closed

ProcessFailedException when using ModelicaSystem #82

bc0n opened this issue Aug 15, 2023 · 6 comments

Comments

@bc0n
Copy link

bc0n commented Aug 15, 2023

If I directly use loadFile(), loadModel(), buildModel(), and simulate() via sendExpression, I can simulate this model without problem, but using ModelicaSystem()/buildModel/simulate leads to a ProcessFailed exception:
caught error[ProcessFailedException(Base.Process[Process(`'C:/Users/BENCON~1/AppData/Local/Temp/jl_nFAMOr/FallingModel.exe'`, ProcessExited(3221225785))])]

where I've wrapped the simulate() in a try/catch:

modelText = """model FallingModel
  inner Modelica.Mechanics.MultiBody.World world;
  Modelica.Mechanics.MultiBody.Joints.FreeMotion freeMotion(animation = false,r_rel_a(start = {1, 0, 0}), w_rel_a_fixed = true, w_rel_a_start = {1, 2, 3});
  Modelica.Mechanics.MultiBody.Parts.Body body(animation = true,m = 1, r_0(start = {1, 0, 0}));
equation
  connect(world.frame_b, freeMotion.frame_a);
  connect(freeMotion.frame_b, body.frame_a);
  annotation( uses(Modelica(version = "4.0.0")));
end FallingModel;
"""
modelPath = "./FallingModel.mo"
modelName = "FallingModel"

write("FallingModel.mo", modelText)

omc = OMJulia.OMCSession()
try
  OMJulia.ModelicaSystem(omc, modelPath, modelName)
  OMJulia.buildModel(omc) 
  OMJulia.simulate(omc)
catch e
  println("\ncaught error[$e]\n")
  ges = OMJulia.sendExpression(omc, "getErrorString()") 
  println("getErrorString()=$ges")
  dump(omc)
finally
  OMJulia.sendExpression(omc, "quit()", parsed=false)
end

see attached console output.

I suspect the problem is in an argument added to omc by ModelicaSystem/later, but nothing is jumping out at me. I will note that the self-assembled omc is about half of the size as the one made by ModelicaSystem.

Thanks

@arun3688
Copy link
Contributor

@bc0n there is no need to build the model again using buildModel() API as the constructor ModelicaSystem you should use buildModel to rebuild the model with new settings. So it should be

  omc = OMJulia.OMCSession()
  OMJulia.ModelicaSystem(omc, modelPath, modelName)
  OMJulia.simulate(omc)

@bc0n
Copy link
Author

bc0n commented Aug 15, 2023

Ok @arun3688, though I receive the same error...
I'm on Win10 x64, [0f4fe800] OMJulia v0.2.1, julia v1.8.1

@bc0n
Copy link
Author

bc0n commented Aug 15, 2023

And fyi I do not receive the error under wsl/ubuntu.

@arun3688
Copy link
Contributor

@bc0n I tried to simulate the example provide by you and it is working for me, see the output below

julia> using OMJulia
julia> omc = OMJulia.OMCSession()
julia> ModelicaSystem(omc,"failing.mo", "FallingModel")
julia> simulate(omc)
LOG_SUCCESS       | info    | The initialization finished successfully without homotopy method.
LOG_SUCCESS       | info    | The simulation finished successfully.

and i am using Julia-1.9.2

@arun3688
Copy link
Contributor

@bc0n I just looked into you error log C:/Users/BENCON~1/AppData/Local/Temp/jl_4Bl1JD/FallingModel.exe, It might be a problem with temp directory, Could you please make sure the temp directory has admin rights or start the julia repl as administrator and test it

@bc0n
Copy link
Author

bc0n commented Aug 17, 2023

Thanks for the suggestion @arun3688, I'm not finding the cause. I see the error in v1.8.1 and it's gone in 1.9.2, so closing this.

For what it's worth, I added two simulate() tests in my fork since there weren't any. https://github.com/mechanomy/OMJulia.jl/actions/runs/5885873274/job/15962905920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants