Search code examples
jmodelica

Is it possible to suppress the output of the JModelica solver?


I am using JModelica to perform many simulations simultaneously. It would be very nice to suppress the solver statistics like

Final Run Statistics: --- 

Number of steps                                 : 691
Number of function evaluations                  : 904
Number of Jacobian evaluations                  : 16
Number of function eval. due to Jacobian eval.  : 896
Number of error test failures                   : 20
Number of nonlinear iterations                  : 900
Number of nonlinear convergence failures        : 0
Number of state function evaluations            : 692

Solver options:

Solver                   : CVode
Linear multistep method  : BDF
Nonlinear solver         : Newton
Linear solver type       : DENSE
Maximal order            : 5
Tolerances (absolute)    : [1.0000e-01 1.0000e-01 1.0000e-01 1.0000e-06 3.0000e-04 3.0000e-04
3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 2.9315e-04 2.9315e-04
2.9315e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04
3.0000e-04 2.9315e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04
2.9315e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 2.9315e-04
1.0000e-01 1.0000e-06 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04
3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04
3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04 3.0000e-04
3.0000e-04 1.0000e-06 1.0000e-06 3.0000e-04 3.0000e-04 1.0000e-06
1.0000e-06 1.0000e-06]
Tolerances (relative)    : 0.0001

Simulation interval    : 0.0 - 432000.0 seconds.
Elapsed simulation time: 0.262155771255 seconds.

Is there an option for the solver? I didn't find anything in the JModelica documentation. Is there another option in Python?


Solution

  • Yes there is. It is set using solver specific options. For example:

    model = load_fmu("MyModel.fmu")
    
    opts = model.simulate_options()
    opts["CVode_options"]["verbosity"] = 50
    
    res = model.simulate(options=opts)