Class fmipp.RollbackFMU¶
-
class
RollbackFMU
([fmuDirUri, ]modelIdentifier[, loggingOn=False, timeDiffResolution=1e-4, integratorType=integratorBDF])¶ This class implements an easy way to reset the state of an FMU for Model Exchange to a state corresponding to a previous time step using the methods
saveCurrentStateForRollback()
andreleaseRollbackState()
.Assume that at time
t0
the method callintegrate( t1 )
was issued, i.e., the integration of the associated FMU from timet0
to timet1
>t0
. In case there happend no event during the integration, after the method call the internal state of the FMU corresponds to timet1
. Now, in order to rollback the FMU to a state corresponding to timet2
, witht0
<t2
<t1
, the method callintegrate( t2 )
is sufficient.Internally, class
RollbackFMU
stores a rollback state. No rollbacks corresponding to a time previous to that internally stored rollback state are possible. If not otherwise instructed, the latest stored rollback state is overwritten with the current state, in case the requested integration endpoint is in the future. However, the methodsaveCurrentStateForRollback()
enforces the current state to be stored as rollback state until it is explicitly released with methodreleaseRollbackState()
. This allows to make a rollback over more than one time-consecutive integration cycle.Note
This class uses objects of type
SwigPyObject
as inputs and outputs, which are wrappers around C/C++ arrays. Instantiation of and data access to these objects should be done via the corresponding helper functions.- Parameters
fmuDirUri (str) – URI to the unzipped FMU
modelIdentifier (str) – model identifier of the FMU
loggingOn (bool) – enable logger for debugging
timeDiffResolution (float) – internal resolution for comparing time differences
integratorType (int) – the numerical integration method for solving ODEs (see list of available integrators here)
Methods for interacting with the FMU
-
instantiate
(instanceName)¶ This functions creates a new internal FMU instance. This function must be called successfully, before any of the following functions can be called.
- Parameters
instanceName (str) – a unique identifier for a given FMI component instance, used to identify a component within a co-simulation graph model and for logging messages
- Return type
int (
statusOK
,statusWarning
,statusDiscard
,statusError
orstatusFatal
)
-
initialize
(toleranceDefined=False, tolerance=1e-05)¶ Informs the FMU instance that the simulation run starts now.
- Parameters
toleranceDefined (bool) – if
True
, the model is called with a numerical integration scheme where the step size is controlled by usingtolerance
tolerance (float) – relative tolerance for error estimation
- Return type
int (
statusOK
,statusWarning
,statusDiscard
,statusError
orstatusFatal
)
-
integrate
(tstop[, deltaT=1E-5])¶ In case there happend no event during the integration, after the method call the internal state of the FMU corresponds to time
tstop
. To rollback the FMU to a state corresponding to timetrollback
, the method callintegrate( trollback )
is sufficient.- Parameters
tend (float) – stop time for the integration
deltaT (int) – starting step size to be used by the integrator, smaller values lead to more accuracy
- Returns
integration stop time
- Return type
float
-
saveCurrentStateForRollback
()¶ Saves the current state of the FMU as internal rollback state. This rollback state will not be overwritten until
releaseRollbackState()
is called.
-
releaseRollbackState
()¶ Realease an internal rollback state, that was previously saved via
saveCurrentStateForRollback()
.
Methods for getting/setting values
-
getBooleanValue
(name)¶ - Parameters
name (str) – variable name
- Return type
bool
-
getIntegerValue
(name)¶ - Parameters
name (str) – variable name
- Return type
int
-
getRealValue
(name)¶ - Parameters
name (str) – variable name
- Return type
float
-
getStringValue
(name)¶ - Parameters
name (str) – variable name
- Return type
str
Miscellaneous methods
-
getTime
()¶ - Return type
float
-
getLastStatus
()¶ - Return type
int (
statusOK
,statusWarning
,statusDiscard
,statusError
orstatusFatal
)