cosapp.drivers.time.base¶
Classes
|
Generic implementation of a time driver with managed time step. |
- class cosapp.drivers.time.base.AbstractTimeDriver(name='Time driver', owner: System | None = None, time_interval: tuple[float, float] | None = None, dt: float | None = None, record_dt: bool = False, **options)[source]¶
Bases:
DriverGeneric implementation of a time driver with managed time step. Specialization of derived classes is achieved by the implementation of abstract method _update_transients
- add_recorder(recorder: AnyRecorder, period: Number | None = None) AnyRecorder[source]¶
Add an internal recorder storing the time evolution of values of interest.
- Parameters:
[BaseRecorder] (- recorder) – The recorder to be added.
[Number (- period) – Recording period. If None (default), data are recorded at all time steps.
optional] – Recording period. If None (default), data are recorded at all time steps.
- property dt: None | Number¶
Nominal time step (None if unspecified)
- property event_data: DataFrame¶
DataFrame detailing all event cascades occurring during simulation
- Type:
pandas.DataFrame
- log_debug_message(handler: HandlerWithContextFilters, record: LogRecord, format=LogFormat.RAW) bool[source]¶
Callback method on the system to log more detailed information.
This method will be called by the log handler when
log_context()is active if the logging level is lower or equals to VERBOSE_LEVEL. It allows the object to send additional log message to help debugging a simulation.- Parameters:
handler (HandlerWithContextFilters) – Log handler on which additional message should be published.
record (logging.LogRecord) – Log record
format (LogFormat) – Format of the message
- Returns:
Should the provided record be logged?
- Return type:
bool
- record_dt¶
- property recorded_dt: ndarray¶
list of time steps recorded during driver execution
- Type:
numpy.ndarray
- property recorded_events: list[EventRecord]¶
list of recorded event cascades
- Type:
list[EventRecord]
- property recording_period: Number¶
Recording period of time driver’s internal recorder
- Type:
float
- property scenario: Scenario¶
the simulation scenario, defining initial and boundary conditions
- Type:
- set_scenario(name='scenario', init: dict[str, Any] = {}, values: dict[str, Any] = {}, stop: str | Event | None = None) None[source]¶
Define a simulation scenario, from initial and boundary conditions.
- Parameters:
init (dict) – Dictionary of initial conditions, of the kind {variable: value}
values (dict) – Dictionary of boundary conditions, of the kind {variable: value} Explicit time dependency may be specified, as {variable: ‘cos(omega * t)’}, for example
name (str) – Name of the scenario (by default, ‘scenario’)
- setup_run() None[source]¶
Setup the driver once before starting the simulation and before calling the systems setup_run.
- property system_update_signal¶
Signal emitted after the owner system is updated, at each time step
- property time: Number¶
Current simulation time
- property time_interval: tuple[Number, Number]¶
Time interval covered by driver
- transition(time: float, events: Collection[Event] = ()) None[source]¶
Execute owner system transition and reinitialize sub-drivers
- static value_and_derivative(var: TimeUnknown) tuple[float, float] | tuple[ndarray, ndarray][source]¶