Skip to content

Cvode regression#1567

Open
arun3688 wants to merge 2 commits intoOpenModelica:maintenance/v2.1from
arun3688:cvode_regression
Open

Cvode regression#1567
arun3688 wants to merge 2 commits intoOpenModelica:maintenance/v2.1from
arun3688:cvode_regression

Conversation

@arun3688
Copy link
Contributor

Related Issues

https://test.openmodelica.org/jenkins/blue/organizations/jenkins/OpenModelica/detail/PR-15120/4/tests/

Purpose

Fix regression caused by commits

0b76945 (#1519)

8f53f47 (#1522)

Causes

After the above two commits, Regression happened if CVode has larger stepSize defined in modelDescription.xml, see the below lua script

oms_setCommandLineOption("--suppressPath=true")
oms_setTempDirectory("./Pendulum-lua/")
oms_newModel("model")
oms_addSystem("model.root", oms_system_sc)
oms_addSubModel("model.root.A", "../resources/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.fmu")
initialStepSize = 0.01
minimumStepSize = 0.01
maximumStepSize = 0.01
oms_setVariableStepSize("model", initialStepSize, minimumStepSize, maximumStepSize);
oms_setResultFile("model", "pendulum_res.mat")
oms_instantiate("model")
oms_initialize("model")
oms_simulate("model")
oms_terminate("model")
oms_delete("model")

output

# ../../install/bin/OMSimulator Pendulum.lua
info:    maximum step size for 'model.root': 0.010000
info:    Result file: pendulum_res.mat (bufferSize=1)
info:    Parameter model.root.A.world.label1 will not be stored in the result file, because the signal type is not supported
info:    Parameter model.root.A.world.label2 will not be stored in the result file, because the signal type is not supported

[CVODE ERROR]  CVode
  At t = 0 and h = 0.01, the error test failed repeatedly or with |h| = hmin.

error:   [doStepCVODE] SUNDIALS_ERROR: CVode() failed with flag = -3
warning: Bad return code at time 0.000000
info:    Final Statistics for 'model.root':
         NumSteps = 0 NumRhsEvals  = 3 NumLinSolvSetups = 1
         NumNonlinSolvIters = 2 NumNonlinSolvConvFails = 0 NumErrTestFails = 1
info:    1 warnings
info:    1 errors

However if you reduce to a smaller StepSize for example (0.0001) then it works fine. But this should not happen and the fmu should run with larger stepSize as well.

@arun3688
Copy link
Contributor Author

arun3688 commented Feb 27, 2026

@rruusu Can you please look into it and fix the issue, May be your other Two PR's that conflict can fix these issue, But i am not sure about that

@rruusu
Copy link

rruusu commented Feb 28, 2026

@rruusu Can you please look into it and fix the issue, May be your other Two PR's that conflict can fix these issue, But i am not sure about that

Could you provide further pointers? I cannot find a test case named Pendulum.lua anywhere. Which branch contains the test case? (Edit: I see now that it has been newly added in https://github.com/arun3688/OMSimulator/commits/cvode_regression/)

Based on the nature of the issue itself, I suspect this may have been caused by the earlier merge of #1521 in October (commit 95ff321). That merge included a change to the default maximum CVODE order from 5 to 2 (Issue #1514), which I imagine could result in such a failure with a larger step size, as CVODE is prevented from increasing the step size by using a higher order.

Could you try whether this failure disappears with a command line flag --cvodeMaxOrder=5?

@arun3688
Copy link
Contributor Author

arun3688 commented Feb 28, 2026

Could you provide further pointers? I cannot find a test case named Pendulum.lua anywhere. Which branch contains the test case? (Edit: I see now that it has been newly added in https://github.com/arun3688/OMSimulator/commits/cvode_regression/)

Sorry the test case is in this PR it is not merged yet, if you can pull my PR you can get it or below is the attached zip file which contains the fmu and lua script Pendulum.lua. The fmu is generated from the MSL library Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum

Pendulum.zip

Unfortunately these test cases were not in the OMSimulator repository and it was in our OpenModelica master repository which test OMSimulator. Here are the test cases location

https://github.com/OpenModelica/OpenModelica/tree/master/testsuite/omsimulator

https://github.com/OpenModelica/OpenModelica/blob/master/testsuite/omsimulator/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos

I tried with --CVODEMaxOrder=5 and it did not work, if this is fixed i will add the remaining regression test directly to the OMSimulator repository

# ../../install/bin/OMSimulator Pendulum.lua --CVODEMaxOrder=5
info:    maximum step size for 'model.root': 0.010000
info:    Result file: pendulum_res.mat (bufferSize=1)
info:    Parameter model.root.A.world.label1 will not be stored in the result file, because the signal type is not supported
info:    Parameter model.root.A.world.label2 will not be stored in the result file, because the signal type is not supported

[CVODE ERROR]  CVode
  At t = 0 and h = 0.01, the error test failed repeatedly or with |h| = hmin.

error:   [doStepCVODE] SUNDIALS_ERROR: CVode() failed with flag = -3
warning: Bad return code at time 0.000000
info:    Final Statistics for 'model.root':
         NumSteps = 0 NumRhsEvals  = 3 NumLinSolvSetups = 1
         NumNonlinSolvIters = 2 NumNonlinSolvConvFails = 0 NumErrTestFails = 1
info:    1 warnings
info:    1 errors

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

Successfully merging this pull request may close these issues.

2 participants