Python API

Math

Spherical harmonics

math.Ylm

Compute the tesseral spherical harmonics.

Point

math.Vector3

General 3-element vector structure.

Function wrappers

math.VectorSpatialFunction

Vector spatial function.

Angular quadrature

Quadrature points

aquad.QuadraturePointPhiTheta

Angular quadrature point.

Base class

aquad.AngularQuadrature

Angular quadrature.

Product quadratures

aquad.ProductQuadrature

Product quadrature.

aquad.CurvilinearProductQuadrature

Curvilinear product quadrature.

aquad.GLProductQuadrature1DSlab

Gauss-Legendre quadrature for 1D, slab geometry.

aquad.GLCProductQuadrature2DXY

Gauss-Legendre-Chebyshev quadrature for 2D, XY geometry.

aquad.GLCProductQuadrature3DXYZ

Gauss-Legendre-Chebyshev quadrature for 3D, XYZ geometry.

aquad.GLCProductQuadrature2DRZ

Gauss-Legendre-Chebyshev product quadrature for 2D, RZ geometry.

Triangular quadrature

aquad.TriangularQuadrature

Triangular quadrature base class.

aquad.GLCTriangularQuadrature2DXY

Triangular Gauss-Legendre-Chebyshev quadrature for 2D, XY geometry.

aquad.GLCTriangularQuadrature3DXYZ

Triangular Gauss-Legendre-Chebyshev quadrature for 3D, XYZ geometry.

Lebedev quadrature

aquad.LebedevQuadrature2DXY

Lebedev quadrature for 2D, XY geometry.

aquad.LebedevQuadrature3DXYZ

Lebedev quadrature for 3D, XYZ geometry.

Simplified LDFES quadrature

aquad.SLDFEsqQuadrature3DXYZ

Piecewise-linear finite element quadrature using quadrilaterals.

aquad.SLDFEsqQuadrature2DXY

Two-dimensional variant of the piecewise-linear finite element quadrature.

Field functions

Base class

fieldfunc.FieldFunction

Field function.

Grid-based

fieldfunc.FieldFunctionGridBased

Field function grid based.

Interpolation

fieldfunc.FieldFunctionInterpolation

Base class for field-function interpolation objects.

fieldfunc.FieldFunctionInterpolationPoint

Interpolate the field function at a point.

fieldfunc.FieldFunctionInterpolationLine

Line based interpolation function.

fieldfunc.FieldFunctionInterpolationVolume

A line based interpolation function.

Mesh

Mesh

mesh.MeshContinuum

Mesh continuum.

Surface mesh

mesh.SurfaceMesh

Surface mesh.

Mesh generator

mesh.MeshGenerator

Generic mesh generator.

mesh.ExtruderMeshGenerator

Extruded mesh generator.

mesh.OrthogonalMeshGenerator

Orthogonal mesh generator.

mesh.FromFileMeshGenerator

From file mesh generator.

mesh.SplitFileMeshGenerator

Split file mesh generator.

mesh.DistributedMeshGenerator

Distributed mesh generator.

Graph partitioner

mesh.GraphPartitioner

Generic graph partitioner.

mesh.KBAGraphPartitioner

Koch, Baker and Alcouffe based partitioning.

mesh.LinearGraphPartitioner

Basic linear partitioning.

mesh.PETScGraphPartitioner

PETSc based partitioning.

Logical volume

Base class

logvol.LogicalVolume

Generic logical volume.

Logical volume types

logvol.BooleanLogicalVolume

Boolean logical volume.

logvol.RCCLogicalVolume

Right circular cylinder logical volume.

logvol.RPPLogicalVolume

Rectangular parallel piped logical volume.

logvol.SphereLogicalVolume

Spherical logical volume.

logvol.SurfaceMeshLogicalVolume

Surface mesh logical volume.

Response evaluator

response.ResponseEvaluator

Response evaluator by folding sources against adjoint solutions.

Source

source.PointSource

Point sources, defined by its location and a group-wise strength vector.

source.VolumetricSource

Multi-group isotropic volumetric sources.

Cross section

xs.MultiGroupXS

Multi-group cross section.

Problem

Note

Forward/adjoint mode transitions are destructive by design. In Python there are three valid ways to set mode:

  1. Set options={'adjoint': ...} in the problem constructor.

  2. Call problem.SetOptions(adjoint=...).

  3. Call problem.SetAdjoint(...) (low-level equivalent).

A mode transition triggers:

  • reinitializes material mode (forward vs adjoint),

  • clears point and volumetric sources,

  • clears boundary conditions,

  • zeros scalar and angular flux state.

The block-id to cross-section map is preserved. After switching mode, reapply the desired driving terms (sources and boundaries) before solving.

SetOptions is additive: only explicitly supplied options are updated. If adjoint is omitted in a SetOptions call, the current mode is unchanged.

Adjoint mode is applied to the mapped MultiGroupXS objects themselves. If the same cross-section object is shared across multiple problems, toggling adjoint mode in one problem affects all problems using that object.

Base class

solver.Problem

Base class for all problems.

solver.LBSProblem

Base class for all linear Boltzmann problems.

Discrete ordinates problem

Note

Steady-state <-> transient mode transitions are non-destructive for problem setup. Calling SetTimeDependentMode() or SetSteadyStateMode() preserves:

  • mesh and discretization,

  • block-id to cross-section mapping,

  • boundary conditions and source definitions,

  • scalar flux moments (phi_new/phi_old state).

For SetTimeDependentMode(), OpenSn needs angular fluxes (psi) for the transient RHS time term. Mode transition behavior is as follows:

  • If save_angular_flux is already enabled: - the mode switch performs internal transient mode configuration only.

  • If save_angular_flux is disabled: - OpenSn enables angular flux storage, - caches the scalar flux and performs a sweep to reconstruct psi, - restores the cached scalar flux, - completes internal transient mode configuration.

For SetSteadyStateMode(), transient-only internals are reset. If angular flux saving had been temporarily forced for transient use, the original save_angular_flux user setting is restored.

Practical implication: - save_angular_flux=False is valid for steady-state solves that later

transition to transient; OpenSn will reconstruct psi needed by the transient solver by performing a fixed-point iteration on the lagged angular fluxes with phi/q held at the converged steady-state value.

Warning

Reconstructed angular flux (psi) is consistent with the converged scalar scalar flux moments, but it is not guaranteed to be identical to the angular flux that would have been available if save_angular_flux=True had been used during the steady-state solve. Small first-step transient differences can therefore appear, especially for problems with reflecting boundaries or lagged angular fluxes.

solver.DiscreteOrdinatesProblem

Base class for discrete ordinates problems in Cartesian geometry.

Discrete ordinates curvilinear problem

solver.DiscreteOrdinatesCurvilinearProblem

Base class for discrete ordinates problems in curvilinear geometry.

Solvers

Solver base class

solver.Solver

Base class for all solvers.

Steady state source solver

solver.SteadyStateSourceSolver

Steady state solver.

Transient solver

solver.TransientSolver

Transient solver.

Non-linear k-eigen

solver.NonLinearKEigenSolver

Non-linear k-eigenvalue solver.

Power iteration solver

solver.PowerIterationKEigenSolver

Power iteration k-eigenvalue solver.

Acceleration methods

Discrete ordinates k-eigen acceleration base class

solver.DiscreteOrdinatesKEigenAcceleration

Base class for discrete ordinates k-eigenvalue acceleration methods.

Discrete ordinates k-eigen acceleration

solver.SCDSAAcceleration

Construct an SCDSA accelerator for the power iteration k-eigenvalue solver.

solver.SMMAcceleration

Construct an SMM accelerator for the power iteration k-eigenvalue solver.

Settings

Important

Functions in this section are only available to the module mode. For the console mode, refer to opensn --help for more information.

Logs

context.SetVerbosityLevel

Set verbosity level (0 to 3).

context.UseColor

Enable/disable color output.

context.EnablePETScErrorHandler

Allow PETSc error handler.

Caliper configuration

context.SetCaliperConfig

Set configuration to the Caliper manager.

context.EnableCaliper

Start the Caliper manager and mark the program begin.

Argument vector

context.InitializeWithArgv

Overwrite OpenSn settings using sys.argv.

context.Finalize

Finalize OpenSn context.