pyopensn.solver.TransientSolver

class pyopensn.solver.TransientSolver

Transient solver.

Wrapper of opensn::TransientSolver.

Advance(self: pyopensn.solver.TransientSolver) → None

Advance the solver by a single timestep.

Notes

You must call Initialize() before calling Advance() or Execute().

ComputeBalanceTable(self: pyopensn.solver.TransientSolver) → dict

Compute and return the global balance table using the solver’s normalization. This is a collective operation and must be called on all ranks.

Returns:

Dictionary with the following entries:

  • absorption_rate: Global absorption rate, approximately integral sigma_a * phi dV summed over groups and the full domain.

  • production_rate: Global volumetric production/source rate used by the solver, approximately integral Q dV summed over groups and the full domain.

  • inflow_rate: Global incoming boundary contribution integrated over incoming angular flux on boundaries. On reflecting boundaries the outgoing partial current is counted as the incoming one, so reflecting faces add equal amounts to inflow_rate and outflow_rate and cancel in balance.

  • outflow_rate: Global outgoing boundary contribution accumulated from face outflow tallies, including reflecting boundaries (see inflow_rate).

  • balance: Rate balance, production_rate + inflow_rate - absorption_rate - outflow_rate.

  • initial_inventory: Total particle inventory at the start of the timestep, computed as integral (1 / v_g) * phi_old dV summed over groups and the full domain.

  • final_inventory: Total particle inventory at the end of the timestep, computed as integral (1 / v_g) * phi_new dV summed over groups and the full domain.

  • predicted_inventory_change: Inventory change predicted by the current timestep balance, computed as dt * balance.

  • actual_inventory_change: Measured change in total particle inventory over the timestep, computed as final_inventory - initial_inventory.

  • inventory_residual: Mismatch between the measured and predicted timestep inventory changes, computed as actual_inventory_change - predicted_inventory_change.

Return type:

dict

Notes

This solver applies no extra normalization to the balance table.

The transient inventory terms currently use the end-of-step rate balance to estimate the timestep inventory change.

Execute(self: pyopensn.solver.Solver) → None

Execute the solver.

The problem’s current state and the solver’s requirements are checked first, so changes made to the problem after Initialize (for example a mode switch or SetXSMap) are validated before they are used. Initialize must be called before Execute.

For MPI transport solvers, this is a collective operation and must be called on all ranks.

Initialize(self: pyopensn.solver.Solver) → None

Initialize the solver.

Solvers check that the problem is in a supported state (for example, steady-state mode without external sources for the k-eigenvalue solvers) and raise ValueError otherwise. Setup and post-setup validation must both succeed. Calling Initialize again clears the previous initialized state first.

For MPI transport solvers, this is a collective operation and must be called on all ranks.

IsConverged(self: pyopensn.solver.TransientSolver) → bool

Return True if the transport solve of every time step since Initialize() converged.

A time step whose solve reaches its iteration limit, fails, or applies no convergence test (a single sweep, petsc_richardson with l_max_its = 1) makes this False until the next Initialize(), so checking it after each Advance() identifies the first such step. Returns False before the first time step.

SetPostAdvanceCallback(*args, **kwargs)

Overloaded function.

  1. SetPostAdvanceCallback(self: pyopensn.solver.TransientSolver, arg0: Callable[[], None]) -> None

    Register a callback that runs after each advance within Execute().

    param callback:

    Function invoked after the solver advances a timestep. Pass None to clear.

    type callback:

    Optional[Callable[[], None]]

  2. SetPostAdvanceCallback(self: pyopensn.solver.TransientSolver, arg0: None) -> None

Clear the PostAdvance callback by passing None.

SetPreAdvanceCallback(*args, **kwargs)

Overloaded function.

  1. SetPreAdvanceCallback(self: pyopensn.solver.TransientSolver, arg0: Callable[[], None]) -> None

    Register a callback that runs before each advance within Execute().

    param callback:

    Function invoked before the solver advances a timestep. Pass None to clear. If the callback modifies the timestep, the new value is used for the upcoming step.

    type callback:

    Optional[Callable[[], None]]

  2. SetPreAdvanceCallback(self: pyopensn.solver.TransientSolver, arg0: None) -> None

Clear the PreAdvance callback by passing None.

SetTheta(self: pyopensn.solver.TransientSolver, arg0: float) → None

Set the theta parameter used by Advance().

Parameters:

theta (float) – Theta value between 1.0e-16 and 1.

SetTimeStep(self: pyopensn.solver.TransientSolver, arg0: float) → None

Set the timestep size used by Advance().

Parameters:

dt (float) – New timestep size.

__init__(self: pyopensn.solver.TransientSolver, **kwargs) → None

Construct a transient solver.

Parameters:
  • pyopensn.solver.DiscreteOrdinatesProblem (DiscreteOrdinatesProblem) – Existing discrete ordinates problem instance.

  • dt (float, optional, default=2.0e-3) – Time step size used during the simulation.

  • stop_time (float, optional, default=0.1) – Absolute end time of the transient, not a duration. A solver that starts after another one on the same problem continues from that problem’s time.

  • theta (float, optional, default=0.5) – Time differencing scheme parameter.

  • initial_state (str, optional, default="existing") – Initial state for the transient solve. Allowed values: existing, zero. “existing” continues from the problem’s current solution and time. “zero” resets the scalar flux, precursors, and stored angular fluxes to zero and starts at time 0. Restart data and a pending initial condition (read_initial_condition_path) take precedence.

  • verbose (bool, optional, default=True) – Enable verbose logging.

  • compute_balance (bool, optional, default=False) – If true, print the timestep balance table (the one ComputeBalanceTable() returns) after every timestep, whether taken by Execute() or Advance().

Notes

The associated problem must have save_angular_flux=True enabled. This is required for transient problems.

If the problem was constructed with options={'read_restart_path': ...}, restart data is read during Initialize(). If it was constructed with options={'read_initial_condition_path': ...}, restart data is read as a transient initial condition during Initialize(), then the problem is switched to time-dependent mode; a steady-state restart may be used in this mode. In this initial-condition path, stored angular fluxes and delayed sweep angular-flux buffers are optional in the steady-state restart; the transient solver reconstructs angular state from the loaded flux moments. If it was constructed with options={'restart_writes_enabled': True, ...}, timed restart dumps may be written during Execute() and a final restart dump is written when execution completes.

A full transient continuation restart read with read_restart_path is different from a steady-state initial-condition restart read with read_initial_condition_path. Full transient continuation restarts require angular flux state in the restart file; if the problem has delayed sweep angular state, including partitioned parallel, reflected-boundary, or cyclic-sweep cases, continuation also requires delayed sweep angular-flux buffers in the restart. Restart files are rank-layout specific: use the same MPI rank count and compatible problem definition when reading files written by a previous run.