Skip to content

Simulation

The Simulation class orchestrates the time-step loop over the energy system horizon. For each step, it obtains a control action, advances the system, performs grid balancing, and stores the resulting step data.

The detailed simulation flow is documented in the user guide section Simulation Flow.

Simulation

Simulation(
    energy_system: EnergySystem,
    controller: Optional[ControllerABC] = None,
)

The Simulation iterates over all simulation time steps of the EnergySystem, asks the controller for an action, applies the action through the EnergySystem, balances any remaining power via the grid builder, and stores one SimulationStepResult per step.

For a detailed sequence diagram and step-by-step explanation of the simulation flow, see the user guide section "Simulation Flow".

Parameters:

Name Type Description Default
energy_system EnergySystem

The EnergySystem to simulate.

required
controller Optional[ControllerABC]

The ControllerABC used as EMS.

None

nrgise.Simulation.register_hook

register_hook(func: SimulationHook) -> None

Register a function to be executed after each completed simulation step (aka. hook). A hook can be used to inject custom logic into the simulation loop.

Required function signature:

def function_defining_the_hook(simulation: Simulation, step_result: SimulationStepResult) -> None

Parameters:

Name Type Description Default
func SimulationHook

Hook function matching SimulationHook.

required

nrgise.Simulation.run

run() -> pd.DataFrame

Run the simulation by looping through the energy system time index.

For each time step, this method:

  1. queries the controller for a control action by passing the current State,
  2. advances the EnergySystem by one step by applying the action,
  3. balances remaining power via the grid builder,
  4. records the resulting SimulationStepResult, and
  5. executes registered simulation hooks.
  6. updates the State for the next time step.

Returns:

Type Description
DataFrame

Simulation results as a Pandas DataFrame indexed by date_time.