OpenModelica / OMSimulator

The OpenModelica FMI & SSP-based co-simulation environment.
Other
69 stars 49 forks source link

CVode error doesn't stop simulation / infinite loop #1213

Open AnHeuermann opened 1 year ago

AnHeuermann commented 1 year ago

Description

I have a broken FMU which can't satisfy error tests, because the evaluation of the ODE system is wrong (playing around with some neural networks in there). CVODE will fail the error test, OMSimulator prints a warning and then does the exact same step again. This loop never stops.

Steps to reproduce the behavior

oms_setTempDirectory("./temp/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_sc)
oms_addSubModel("modelname", "../modelname.fmu")

oms_setStopTime("model", 1)
oms_setFixedStepSize("model.root", 2e-4)

oms_instantiate("model")
oms_initialize("model")
oms_simulate("model")
oms_terminate("model")
oms_delete("model")
[CVODE ERROR]  CVode
  At t = 1.0002 and h = 0.0002, the error test failed repeatedly or with |h| = hmin.

Expected behavior

CVODE already tries multiple times (e.g. reducing the internal step size?) and fails to do the integrator step. In that case oms::SystemSC::doStep should fail after printing the error message.

Version and OS