openmc.lib.TemporarySession

class openmc.lib.TemporarySession(model=None, cwd=None, **init_kwargs)[source]

Context manager for running via openmc.lib in a temporary directory.

This class is useful for accessing functionality from openmc.lib without polluting your current working directory with OpenMC files. It is used internally as a persistent session to avoid loading cross sections multiple times.

Parameters:
  • model (openmc.Model, optional) – OpenMC model to use for the session. If None, a minimal working model is created.

  • cwd (PathLike, optional) – Working directory in which to run OpenMC. If None, a temporary directory is created and deleted automatically.

  • **init_kwargs – Keyword arguments to pass to openmc.lib.init().

Variables:
  • model (openmc.Model) – The OpenMC model used for the session.

  • comm (mpi4py.MPI.Intracomm) – The MPI intracommunicator used for the session.