SimulationEngine

SimulationEngine

module ModiaMath.SimulationEngine

Simulation engine for implicit index 1 DAE models with events.

Main developer

Martin Otter, DLR - Institute of System Dynamics and Control

source
ModiaMath.simulate!(simulationModel; log=false, startTime=NaN, stopTime=NaN,
                                     tolerance=NaN, interval=NaN,
                                     maxStepSize=NaN, maxNumberOfSteps=missing)

Simulates a DAE simulationModel that is defined with package Modia, package Modia3D or with the ModiaMath.@component macro. The DAE is mathematically described as implicit, index 1 DAE with events (containing an ODE or a semi-explicit index 1 DAE as special cases). For details see ModiaMath.StructureOfDAE.

During continuous integration, the DAE is solved with the Sundials IDA solver (accessed via the Julia Sundials interface package).

Input arguments

  • simulationModel::ModiaMath.AbstractSimulationModel: Model struct (generated with Modia, Modia3D or ModiaMath.@component).
  • log::Bool: = true, if logging is enabled, otherwise it is disabled.
  • startTime::Float64: Start time of the simulation in [s]. If startTime=NaN, the default startTime is used that is defined by the simulationModel.
  • stopTime::Float64: Stop time of the simulation in [s]. If stopTime=NaN, the default stopTime is used that is defined by the simulationModel.
  • tolerance::Float64: The relative tolerance for the integration. The absolute tolerance is computed as 0.1*tolerance*nominal(variable) where nominal(variable) is the nominal value of the variable. If tolerance=NaN, the default tolerance is used that is defined by the simulationModel.
  • interval::Float64: Output interval for results in [s]. If events occur, the event time instants are additionally added to the result. If interval=NaN, the default interval is used that is defined by the simulationModel.
  • maxStepSize::Float64: Maximum absolute value of the step size. If maxStepSize=NaN, the default maximum step size of the integrator is used.
  • maxNumberOfSteps::Union{Int,Missing}: Maximum number of steps to be taken by the solver in its attempt to reach the next output time. If maxNumberOfSteps=missing, the default value of the integrator is used (= 500).
source