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

Simulation aborts unstable solution #171

Open
AnHeuermann opened this issue Feb 27, 2023 · 6 comments
Open

Simulation aborts unstable solution #171

AnHeuermann opened this issue Feb 27, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@AnHeuermann
Copy link

AnHeuermann commented Feb 27, 2023

I have a model as a 2.0 ME FMU that I can't share here, but I could provide it via mail.

When simulating it with FMI.jl I'm getting an error from SciMLBase:

julia> simData = fmiSimulate(fmu, (0.0, 10.0); recordValues=recordValues)
┌ Warning: dt(4.440892098500626e-16) <= dtmin(1.7763568394002505e-15) at t=2.0. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ SciMLBase ~/.julia/packages/SciMLBase/QqtZA/src/integrator_interface.jl:518

and the simulation is aborted, but without throwing an error / warning in FMI.jl.

In the previous version v0.10.2 of FMI.jl this example never finishes (at least I don't have enough patience to wait any longer). Probably the underlying issue just didn't throw an error in the older version of SciMLBase.

OMSimulator can handle this FMU.

Versions 'n stuff

  • Tested FMI.jl @v0.11.2
  • OS: Ubuntu Focal
  • Julia: v1.8.1
  • FMU Exporting tool: OpenModelica v1.21.0-dev-288-g01b6764df5-cmake
@AnHeuermann AnHeuermann changed the title Simulation aborts unsable solution Simulation aborts unstable solution Feb 27, 2023
@ThummeTo
Copy link
Owner

ThummeTo commented Mar 2, 2023

What solver is used? If you don't provide a specific solver, DifferentialEquations is using one based on a heuristic. Can you please check the simulation with a robust solver like e.g. CVODE_BDF from Sundials package? Question is if this is a bug in FMI.jl or if the (automatically determined) solver is not sufficient for the ODE inside the ME FMU.

@AnHeuermann
Copy link
Author

That's a good idea.

I changed the solver to CVODE:

using FMI
using DifferentialEquations
using Sundials
fmu = fmiLoad("ScalableTranslationStatistics.Examples.ScaledNLEquations.NLEquations_5.fmu")
simData = fmiSimulate(fmu, (0.0, 10.0); solver=CVODE_BDF, recordValues=["outputs[1]"])

Now the solver seems to be stuck. Even interrupting the Julia process (Ctrl+C) doesn't stop it 😆
I had to kill the process and shell.

I tried explicit Euler as well, but it got stuck as well. I can't see where the program is stuck.

When using OMSimulator the ME FMU simulates in around 15 seconds. It uses CVODE as well.

$ time OMSimulator ScalableTranslationStatistics.Examples.ScaledNLEquations.NLEquations_5.fmu --stopTime=10
info:    maximum step size for 'model.root': 0.001000
info:    Result file: model_res.mat (bufferSize=10)
info:    Final Statistics for 'model.root':
         NumSteps = 1 NumRhsEvals  = 2 NumLinSolvSetups = 1
         NumNonlinSolvIters = 1 NumNonlinSolvConvFails = 0 NumErrTestFails = 0

real    0m15.567s
user    0m15.435s
sys     0m0.121s

@ThummeTo I can send you the Linux FMU if you want to investigate more.

@ThummeTo
Copy link
Owner

ThummeTo commented Mar 3, 2023

you can try showProgress=true (to show a progress bar to see where the solver stucks) and try the max_iters keyword to give a maximum number of solver steps before termination. Using the progress bar you further should be able to kill the solution process, because the background process checks for interrupts every time the progress bar is updated (this is not the default for the Julia REPL, thats why it sometimes freezes during long computations without periodic GUI interrupts).

of course you can also send me the FMU for debugging purpose.

@AnHeuermann
Copy link
Author

Well, that did something, but I'll send you the FMU via mail.

julia> simData = fmiSimulate(fmu, (0.0, 10.0); showProgress=true, recordValues=["outputs[1]"])
ERROR: StackOverflowError:
Stacktrace:
 [1] fmi2Simulate(::FMU2, ::Nothing, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:showProgress, :recordValues), Tuple{Bool, Vector{String}}}}) (repeats 4799 times)
   @ FMI ~/.julia/packages/FMI/C5VcZ/src/FMI2_comp_wraps.jl:17
 [2] #fmiSimulate#158
   @ ~/.julia/packages/FMI/C5VcZ/src/FMI.jl:527 [inlined]
 [3] top-level scope
   @ REPL[4]:1

@ThummeTo ThummeTo added the bug Something isn't working label Mar 8, 2023
@adribrune
Copy link
Contributor

i will approach the issue

@ThummeTo
Copy link
Owner

ThummeTo commented Nov 20, 2024

This should not happen anymore, can one of you @AnHeuermann or @adribrune check for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants