ogstools.core.simulation_controller module#

class ogstools.core.simulation_controller.SimulationStatus[source]#

Bases: Enum

Enumeration of possible simulation states.

Attributes:

not_started: Simulation has not been started yet. running: Simulation is currently executing. paused: Simulation is paused (interactive mode only). done: Simulation completed successfully. error: Simulation terminated with an error.

not_started = 0#
running = 1#
paused = 2#
done = 3#
error = 4#
unknown = 5#
class ogstools.core.simulation_controller.SimulationController[source]#

Bases: ABC

Abstract base class for controlling OGS simulation execution.

Provides a unified interface for running simulations, whether in interactive stepwise mode or batch mode. Handles signal interruption (SIGINT, SIGTERM) and manages simulation status.

Concrete implementations: - OGSInteractiveController: For stepwise execution control - OGSNativeController: For batch execution

Initialize a SimulationController.

Parameters:
  • model_ref (ogstools.Model) – The ogstools.Model to simulate.

  • sim_output (Path | str | None) – Optional path for simulation output directory. If None, uses a default location.

  • overwrite (bool | None) – If True, overwrite existing output directory.

Status#

alias of SimulationStatus

__init__(model_ref, sim_output=None, overwrite=None)[source]#

Initialize a SimulationController.

Parameters:
  • model_ref (ogstools.Model) – The ogstools.Model to simulate.

  • sim_output (Path | str | None) – Optional path for simulation output directory. If None, uses a default location.

  • overwrite (bool | None) – If True, overwrite existing output directory.

property is_interrupted: bool#

Check if an interrupt signal was received and reset the flag.

Returns:

True if SIGINT or SIGTERM was received, False otherwise.

abstractmethod terminate()[source]#

Terminate the simulation immediately.

Return type:

bool

Returns:

True if termination was successful, False otherwise.

abstractmethod run(target=None, id=None)[source]#

Run the simulation to completion.

Parameters:
  • target (Path | str | None) – Optional path for the simulation output directory.

  • id (str | None) – Optional identifier for the resulting Simulation.

Return type:

ogstools.Simulation

Returns:

A ogstools.Simulation object containing the completed simulation.

abstract property status: SimulationStatus#

Get the current simulation status.

Returns:

Current SimulationStatus.

abstractmethod status_str()[source]#

Get a human-readable status string.

Return type:

str

Returns:

String describing the current simulation state.

property log_file: Path#

Get the path to the log file.

property meshseries_file: Path#

Get the path to the mesh series file.

property cmd: str#

Get the full command used to run the simulation.

error_report()[source]#

Generate an error report if the simulation failed.

Includes the last lines of the log file if available.

Return type:

str

Returns:

A formatted error report string.