3. OpenSn Basics
This section is the short version of the user guide. If you only remember a few things about writing OpenSn inputs, remember these.
3.1. The Core Model
An OpenSn transport input is usually built from six pieces:
a mesh,
block ids and boundary names on that mesh,
cross sections assigned to block ids,
one or more groupsets,
a problem object,
a solver object.
In other words:
the mesh defines the geometry,
xs_mapdefines the materials,groupsetsdefine the engery group structure and iteration parameters,the problem object defines the physics model,
the solver object defines how that model is advanced.
Note
The problem owns the physics model. The solver owns the algorithm. Keeping those roles separate makes most of the rest of the API easier to understand.
3.2. The Typical Workflow
Most Python inputs follow this pattern:
grid = ...
xs = ...
groupsets = ...
phys = DiscreteOrdinatesProblem(
mesh=grid,
num_groups=...,
groupsets=groupsets,
xs_map=[...],
boundary_conditions=[...],
volumetric_sources=[...],
options={...},
)
solver = SteadyStateSourceSolver(problem=phys)
solver.Initialize()
solver.Execute()
scalar_ffs = phys.GetScalarFluxFieldFunction()
If the problem is transient, use TransientSolver.
If it is a criticality problem, use one of the k-eigen solvers.
3.3. What Usually Goes Where
As a rule of thumb:
boundary names and block ids belong on the mesh,
materials belong in
xs_map,angular quadrature and inner iteration parameters belong in
groupsets,outer-iteration parameters belong in the solver.
If you are not sure where an option belongs, ask whether it changes:
a groupset solve,
the whole problem, or
the outer solve.
That usually tells you the right place.
3.4. The Three Most Important Practical Rules
Start simple.
Start with one groupset, simple boundaries, and a small mesh if possible.
Converge the transport solve properly.
If you have multiple groupsets and there is across-groupset upscatter, enable and converge the across-groupset solver (AGS). Do not rely on loose inner solves to be corrected by outer iterations later.
Postprocess through field functions.
The usual output path is to solve first, then get scalar or power field functions and export or interpolate them.
Note
Many user problems are easier to diagnose if you first ask: is this a mesh issue, a material/block id issue, a groupset/iteration issue, or an outer solver issue?
3.5. Good Default Habits
Good starting habits are:
use one groupset unless you know why you need more,
use
petsc_gmresas the default difficult-problem inner method,use
angle_aggregation_type="single"on unstructured meshes,keep inner tolerances tighter than outer tolerances,
create power field functions only when you need them,
inspect exported field functions or interpolated values early in a new model.
Note
petsc_gmres is a strong default for difficult problems, but it stores
Krylov basis vectors between restarts. On large problems, memory usage can
become significant, so keep gmres_restart_interval only as large as the
problem needs.
3.6. What To Read Next
If you want the next level of detail:
read Geometry and Mesh for mesh creation and labeling,
read Materials and Cross-Section Data for materials and cross sections,
read Groupsets and Iterative Methods for transport iteration,
read Discrete-Ordinates Problems and Solvers for problem and solver setup,
read Example Problems for complete input patterns,
read Post Processors for field functions and interpolation.