pyopensn.solver.DiscreteOrdinatesCurvilinearProblem
- class pyopensn.solver.DiscreteOrdinatesCurvilinearProblem
Base class for discrete ordinates problems in curvilinear geometry.
Wrapper of
opensn::DiscreteOrdinatesCurvilinearProblem.- ComputeFieldFunctionPowerScaleFactor(self: pyopensn.solver.LBSProblem, power_normalization_target: float) float
Compute the scale factor that would normalize the current scalar flux’s total power to a target value.
This is a collective operation and must be called on all MPI ranks.
- Parameters:
power_normalization_target (float) – Target total power (must be positive). The returned factor is
power_normalization_target / global_total_power, whereglobal_total_poweris the same MPI-reduced, kappa-weighted total powerCreateFieldFunction(..., "power", ...)and thepowerfield function use.
Notes
This does not mutate any solver state. It is the same scale factor
CreateFieldFunction(..., "power", power_normalization_target)applies internally, exposed directly so callers can apply it to their own derived quantities (e.g. postprocessor output) without needing a field function.
- ComputeFissionProduction(self: pyopensn.solver.LBSProblem, scalar_flux_iterate: str) float
Computes the total fission production (nu*fission).
- Parameters:
scalar_flux_iterate ({'old', 'new'}) –
- Specifies which scalar flux vector to use in the calculation.
’old’: Use the previous scalar flux iterate.
’new’: Use the current scalar flux iterate.
- Returns:
The total fission production, integrated over the physical volume. In RZ and 1D spherical geometry the integral covers the full revolution (factors of 2*pi and 4*pi). In adjoint mode the fission operator is transposed, so this is the integral of the adjoint fission source, \(\sum_g \nu\sigma_{f,g} \sum_{g'} \chi_{g'} \phi^\dagger_{g'}\) for a fission spectrum.
- Return type:
float
- Raises:
ValueError – If scalar_flux_iterate is not ‘old’ or ‘new’.
- ComputeFissionRate(self: pyopensn.solver.LBSProblem, scalar_flux_iterate: str) float
Computes the total fission rate.
- Parameters:
scalar_flux_iterate ({'old', 'new'}) –
- Specifies which scalar flux vector to use in the calculation.
’old’: Use the previous scalar flux iterate.
’new’: Use the current scalar flux iterate.
- Returns:
The total fission rate, integrated over the physical volume. In RZ and 1D spherical geometry the integral covers the full revolution (factors of 2*pi and 4*pi). In adjoint mode it is \(\sum_g \sigma_{f,g} \phi^\dagger_g\) of the adjoint flux.
- Return type:
float
- Raises:
ValueError – If scalar_flux_iterate is not ‘old’ or ‘new’.
- ComputeLeakage(self: pyopensn.solver.DiscreteOrdinatesProblem, bnd_names: list) dict
Compute leakage for the problem.
- Parameters:
bnd_names (List[str]) – A list of boundary names for which leakage should be computed. An empty list selects all boundaries. RZ problems use rmin, rmax, zmin, and zmax.
- Returns:
A dictionary mapping boundary names to group-wise leakage vectors. Each array contains the net leakage (per group): the outgoing partial current minus the incoming partial current, integrated over the corresponding boundary surface. On a vacuum boundary this equals the outgoing current; on a boundary with an incident flux it is reduced by the inflow and can be negative; on a reflecting boundary it vanishes at convergence. In RZ geometry the surface integral covers the full revolution. In adjoint mode the sweep runs along the opposite directions, so the value is the net adjoint current entering the domain: the adjoint flux in the directions that enter the domain minus that in the directions that leave it, each weighted by \(|\Omega\cdot n|\). On a vacuum boundary it is the adjoint flux of the particles entering through the boundary. For a problem with an uncollided flux the arrays hold the leakage of the collided part alone, since the angular flux holds only that part. The uncollided outflow is the
uncollided_outflow_rateofComputeBalanceTable(), in total over all boundaries and groups.- Return type:
Dict[str, numpy.ndarray]
- Raises:
ValueError – If one or more boundary ids are not present on the current mesh.
- CreateAndWriteSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write source moments from latest flux iterate to file.
Source moments are in the solver orientation that
LBSProblem.ReadSourceMoments()expects: after an adjoint solve, the moments are made from the adjoint flux mapped back from its physical orientation.- Parameters:
file_base (str) – File basename.
- CreateFieldFunction(self: pyopensn.solver.LBSProblem, name: str, xs_name: str, power_normalization_target: float = -1.0) pyopensn.fieldfunc.FieldFunctionGridBased
Create a named scalar field function derived from a 1D XS or
power.- Parameters:
name (str) – Name to assign to the returned field function.
xs_name (str) – Built-in 1D XS name, custom XS name, or the special value
power. CSDA-enabled discrete-ordinates problems also supportcsda_energy_deposition,cepxs_energy_deposition,csda_charge_deposition,csda_charge_deposition_term, andcsda_charge_deposition_term_cellavg. When CSDA is enabled,energy_depositionis an alias for the conservativecsda_energy_deposition.cepxs_energy_depositionpreserves the imported CEPXS response plus the CSDA energy-space contribution.power_normalization_target (float, default=-1.0) – If positive, scale the derived field function so that the raw power field would integrate to this total power.
Notes
The returned field function is created on demand from the current scalar-flux iterate. For ordinary XS names this computes
sum_g xs[g] * phi_gat each node.The returned field function is a snapshot of the solver state at creation time; it is not refreshed automatically if the solver state changes. It supports
CanUpdate()andUpdate()while its owning problem is still alive. CallingUpdate()explicitly recomputes the same field function from the solver’s latest state.If
xs_name == "power", the same power-generation formula used elsewhere by the solver is applied on demand.CSDA deposition fields are derived from the current scalar flux and terminal charged-particle current information. They should normally be created after the CSDA solve has converged.
If
power_normalization_target > 0, the returned field function is scaled using the power implied by the current scalar flux. This scaling affects only the returned field function; it does not mutate the solver’s internalphivectors.The returned field function is a fresh object created for this call. It is not automatically updated by later solves or timesteps.
- GetAngularFieldFunctionList(self: pyopensn.solver.DiscreteOrdinatesProblem, groups: list, angles: list) list
Create field functions for selected angular flux components.
Note: You must enable angular flux storage (
save_angular_flux=True) in the problem options. For transient problems this is required. The angular flux is also stored whendeterministic_sweeps=True. If neither option is set, the returned field functions will remain zero.Example
solver.Initialize() solver.Execute() ang_ff = phys.GetAngularFieldFunctionList(groups=[0], angles=[0])
For transient/time-dependent runs, each field function is still a snapshot. Either call this after each timestep to create a fresh object or keep the returned object and call
Update()after each timestep before exporting or interpolating it. Two common patterns are:Use
TransientSolver.Execute()with a post-advance callback:
solver = TransientSolver(problem=phys) solver.Initialize() ang_ff = phys.GetAngularFieldFunctionList(groups=[0], angles=[0]) def post_advance(): for ff in ang_ff: ff.Update() FieldFunctionGridBased.ExportMultipleToPVTU(ang_ff, "angular_flux_t") solver.SetPostAdvanceCallback(post_advance) solver.Execute()
Use a custom Python loop with
TransientSolver.Advance():
solver = TransientSolver(problem=phys) solver.Initialize() ang_ff = phys.GetAngularFieldFunctionList(groups=[0], angles=[0]) for _ in range(num_steps): solver.Advance() for ff in ang_ff: ff.Update() FieldFunctionGridBased.ExportMultipleToPVTU(ang_ff, "angular_flux_t")
- Parameters:
groups (List[int]) – Global group indices to export.
angles (List[int]) – Angle indices within the groupset quadrature for each group.
- Returns:
Field functions for the requested
(group, angle)pairs. Each returned field function is a snapshot, but supportsCanUpdate()andUpdate()while its owning problem is alive.- Return type:
- GetPhiNewLocal(self: pyopensn.solver.LBSProblem) memoryview
Get the current scalar flux iterate (local vector).
- Returns:
Memory view of the local new scalar flux vector.
- Return type:
memoryview
- GetPhiOldLocal(self: pyopensn.solver.LBSProblem) memoryview
Get the previous scalar flux iterate (local vector).
- Returns:
Memory view of the local old scalar flux vector.
- Return type:
memoryview
- GetPsi(self: pyopensn.solver.DiscreteOrdinatesProblem) list
Return psi as a list of NumPy arrays (float64).
The arrays are copies of the current angular-flux state. Mutating them does not mutate the problem. With an uncollided flux they hold only the collided part.
- GetScalarFluxFieldFunction(self: pyopensn.solver.LBSProblem, only_scalar_flux: bool = True) list
Return scalar-flux or flux-moment field functions grouped by energy group.
- Parameters:
only_scalar_flux (bool, default=True) – If True, returns only the zeroth moment (scalar flux) field function for each group. If False, returns all moment field functions for each group.
- Returns:
If
only_scalar_flux=True:result[g]is the scalar-flux field function for groupg.If
only_scalar_flux=False:result[g][m]is the field function for groupgand momentm.- Return type:
Union[List[pyopensn.fieldfunc.FieldFunctionGridBased], List[List[pyopensn.fieldfunc.FieldFunctionGridBased]]]
Notes
Field functions are created on demand from the current solver state.
The returned field functions are snapshots of the solver state at creation time; they are not refreshed automatically if the solver state changes.
They support
CanUpdate()andUpdate()while their owning problem is still alive. CallingUpdate()explicitly refreshes the same field-function object from the solver’s latest state.Calling
GetScalarFluxFieldFunction(only_scalar_flux=False)creates all requested moments from the currentphiiterate at the time of the call.In the nested form (
only_scalar_flux=False), the moment index varies fastest within each group (inner index = moment, outer index = group).
- GetTime(self: pyopensn.solver.LBSProblem) float
Get the current simulation time in seconds.
- GetTimeStep(self: pyopensn.solver.LBSProblem) float
Get the current timestep size.
- IsAdjoint(self: pyopensn.solver.LBSProblem) bool
Return
Trueif the problem is in adjoint mode, otherwiseFalse.
- IsTimeDependent(self: pyopensn.solver.DiscreteOrdinatesProblem) bool
Return
Trueif the problem is currently in time-dependent mode.
- ReadAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str) None
Read angular fluxes from file.
- Parameters:
file_base (str) – File basename.
- ReadFluxMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read flux moment data.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True to read the single file
<file_base>.h5instead of the per-rank file<file_base><rank>.h5. Serial runs only: a multi-rank run raisesValueErrorbefore any file is opened.
- ReadFluxMomentsAndMakeSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read flux moments and compute corresponding source moments.
The file must have been written by
LBSProblem.WriteFluxMoments()from a problem in the same forward or adjoint mode as this one. An adjoint flux written after its solve, in physical orientation, is mapped to the solver orientation that source moments use. This call is collective.- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True to read the single file
<file_base>.h5instead of the per-rank file<file_base><rank>.h5. Serial runs only: a multi-rank run raisesValueErrorbefore any file is opened.
- ReadSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read source moments from file.
In adjoint mode, source moments are in the solver orientation: a moment of odd degree describes the adjoint source for the opposite direction.
LBSProblem.CreateAndWriteSourceMoments()writes them that way.- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True to read the single file
<file_base>.h5instead of the per-rank file<file_base><rank>.h5. Serial runs only: a multi-rank run raisesValueErrorbefore any file is opened.
- ReadSurfaceAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str, surfaces: list, partition: Optional[int] = None) list
Read surface angular fluxes from file.
- Parameters:
file_base (str) – File basename.
surfaces (list[str]) – Surface names to read. Use the boundary name for an exterior boundary. An interior surface named ‘<name>’ is stored as ‘<name>_u’, for faces whose outward normal aligns with the positive axis, and ‘<name>_d’, for faces with the opposite orientation: pass ‘<name>’ to read both, ‘_u’ first, or one of the tags to read that side only. A name that is itself a stored tag reads that tag; a bare name reads two tags only if both are recorded as sides of an interior surface.
partition (int, optional) – Index of the file to read,
<file_base><partition>.h5. Defaults to this rank.
- Returns:
Surface mapping and angular-flux data for each groupset and read tag, ordered by groupset and then by tag; ‘surface_name’ is the tag. Each entry has keys ‘groupset_id’, ‘adjoint’, ‘num_partitions’, ‘file_set_id’, ‘num_directions’, ‘num_groups’, ‘first_group’, ‘surface_name’, ‘interior’, ‘mapping’, and ‘data’. ‘adjoint’ is True when the file was written from an adjoint problem. ‘file_set_id’ is shared by the files written by one WriteSurfaceAngularFluxes call. ‘interior’ is True when the tag is one side of an interior surface and False for a boundary. ‘num_partitions’ is the number of files in the set, one per writing rank. ‘num_directions’ (D) and ‘num_groups’ (G) are the counts of the entry’s groupset, and ‘first_group’ its first group.
’mapping’ holds the face geometry, the same for every groupset of a tag. Faces are listed in file order with ‘cell_ids’ and ‘num_face_nodes’; ‘nodes_x’, ‘nodes_y’, ‘nodes_z’, and ‘fe_shape’ (the face integral of each node’s shape function) list the nodes of each face in turn; ‘normals’ holds the outward normal of each face’s cell, three components per face; and ‘M_ij’ the face mass matrix of each face in turn, row-major by face node. Face integrals include the angular extent of curvilinear coordinates. The ‘cell_map’ maps face centroids, with ‘centroid_origin’ subtracted before each coordinate is divided by ‘centroid_spacing’ (1e-9 times the global mesh extent) and rounded to an integer, to the face index. The same face has the same key from either side of an interior surface and in every file for the same mesh.
’data’ holds the groupset’s directions ‘omega’ (three components per direction) and quadrature ‘weights’, and the angular flux ‘psi’ of the face’s cell: the value at node k (counted over the faces in turn), direction d, and group g is
psi[(k * D + d) * G + g]. The cosine of direction d with face f is the dot product of ‘omega’ d and ‘normals’ f. For a boundary tag, ‘upwind_psi’ (empty for an interior tag), laid out like ‘psi’, holds the face value upwind of each direction along the direction the data transport in (Omega for forward data, -Omega for adjoint data): ‘psi’ for a direction leaving the domain, and the boundary-condition value the solve used for one entering it (for a reflecting boundary, the reflected angular flux of the final iterate).- Return type:
List[dict]
Notes
Not collective: each call reads one file. The data are checked for internal consistency but not against this problem, so a file set written by any number of ranks, with any partitioning, can be read. When fewer ranks read a set than wrote it, the files from the reading rank count up to
num_partitions - 1are read only when requested withpartition. Thesurface_angular_fluxesdata option ofpyopensn.response.ResponseEvaluatorreads a whole file set and distributes it over the ranks automatically.- Raises:
ValueError – If
surfacesis empty orpartitionis negative.RuntimeError – If the file is missing, malformed, contains non-finite values, was written by an unsupported version of OpenSn, or records a set of at most
partitionfiles. Files of another set written to the same prefix are not detected by a single read; compare theirfile_set_idwith that of partition 0.
- SetAdjoint(self: pyopensn.solver.LBSProblem, adjoint: bool = True) None
Set forward/adjoint transport mode.
- Parameters:
adjoint (bool, default=True) –
Trueenables adjoint mode andFalseenables forward mode. Adjoint mode is supported only for Cartesian geometries with standard quadrature operators (operator_method='standard') and in steady-state mode. A problem constructed with anuncollided_fluxfile keeps the mode the file was generated in. An unsupported request raisesValueErrorbefore any state changes.- Raises:
ValueError – If
adjoint=Trueand the problem is time-dependent or hasoptions.csda_enabled=True, or if the problem was constructed with anuncollided_fluxfile and the mode would change. The problem is left unchanged.
Notes
- This is one of two supported mode-setting paths in Python:
options={'adjoint': ...}in the problem constructor.SetAdjoint(...)(this method).
Warning
Changing the mode clears all point and volumetric sources, all source moments, and all boundary sources (isotropic and arbitrary boundaries, which become vacuum). Apply the sources for the new mode before solving. Otherwise the solve silently uses no sources, or, with
use_source_moments=True, raisesValueErroruntil new source moments are read. Vacuum and reflecting boundaries are kept. A warning is logged on every mode change.- If this changes mode, OpenSn performs a full mode-transition reset:
Materials are reinitialized in the selected mode.
Point and volumetric sources and source moments are cleared.
Isotropic and arbitrary boundaries are cleared and become vacuum.
Vacuum and reflecting boundaries are kept.
Scalar and angular flux vectors are zeroed.
A warning listing what must be reapplied is logged on rank 0.
If this is called with the same mode as the current setting, no reset is performed.
The block-id to cross-section map is preserved across the transition. The mode change applies to this problem only. Other problems that share the mapped
MultiGroupXSobjects keep their own mode.- After a mode change, apply the driving terms of the new mode before solving, typically:
DiscreteOrdinatesProblem.SetBoundaryOptions()for boundary sourcesLBSProblem.ReadSourceMoments()withuse_source_moments=True
Sources are cleared because a forward source is not an adjoint source, and keeping them would silently couple the forward and adjoint setups.
This is a collective operation and must be called on all ranks.
- SetBoundaryOptions(self: pyopensn.solver.DiscreteOrdinatesProblem, **kwargs) None
Set or clear boundary conditions.
- Parameters:
clear_boundary_conditions (bool, default=False) – If true, all current boundary conditions are deleted.
boundary_conditions (List[Dict]) –
- A list of boundary condition dictionaries. Each dictionary supports:
- name: str (required)
Boundary name that identifies the specific boundary.
- type: {‘vacuum’, ‘isotropic’, ‘reflecting’, ‘arbitrary’} (required)
Boundary type specification.
- group_strength: List[float], optional
Required when
type='isotropic'. Isotropic strength per group.
- start_time: float, optional
Active start time for isotropic boundaries only. Defaults to -infinity.
- end_time: float, optional
Active end time for isotropic boundaries only. Defaults to infinity.
- function: AngularFluxFunction, optional
Required when
type='arbitrary'unlesstime_functionis supplied. Callable that returns incoming angular flux from group and direction.
- time_function: AngularFluxTimeFunction, optional
Required when
type='arbitrary'unlessfunctionis supplied. Callable that returns incoming angular flux from group, direction, and time.
Isotropic boundaries may use
start_time/end_timefor simple on/off behavior. Arbitrary boundaries must specify exactly one offunctionortime_function; usetime_functionfor time-dependent arbitrary inflow and handle any active window inside that callback.
Notes
Mode transitions via
LBSProblem.SetAdjoint()clear isotropic and arbitrary boundaries, which become vacuum, and keep vacuum and reflecting boundaries. Apply the boundary sources of the new mode with this method before solving.This is a collective operation and must be called on all ranks.
- SetForward(self: pyopensn.solver.LBSProblem) None
Set forward transport mode.
Equivalent to
SetAdjoint(False), including its mode-transition reset. Changing the mode clears all point and volumetric sources, all source moments, and all isotropic and arbitrary boundary sources, which become vacuum. Vacuum and reflecting boundaries are kept.
- SetPointSources(self: pyopensn.solver.LBSProblem, **kwargs) None
Set or clear point sources.
- Parameters:
clear_point_sources (bool, default=False) – If true, all current the point sources of the problem are deleted.
point_sources (List[pyopensn.source.PointSource]) – List of new point sources to be added to the problem. When both arguments are given, the current sources are cleared before the new ones are added, regardless of keyword order. The new list is validated as a whole: a rejected call leaves the problem’s sources unchanged.
Notes
This is collective. A source caches mesh data when added. Prefer a separate source object for each problem. Share one only when both problems use the same mesh and spatial layout.
- SetSteadyStateMode(self: pyopensn.solver.DiscreteOrdinatesProblem) None
Set the problem to steady-state mode.
Notes
Switch problem from time-dependent to steady-state mode. This updates problem internals (sweep chunk mode and source-function) while preserving user boundary conditions and fixed sources.
This is a collective operation and must be called on all ranks.
- SetTimeDependentMode(self: pyopensn.solver.DiscreteOrdinatesProblem) None
Set the problem to time-dependent mode.
Notes
Switch problem from steady-state to time-dependent mode. This updates problem internals (sweep chunk mode and source-function) while preserving user boundary conditions and fixed sources.
Requires
options.save_angular_flux=Trueat problem creation andVELOCITYorINV_VELOCITYdata in every cross section. Not supported for adjoint, GPU, curvilinear, or uncollided-flux problems. An unsupported request raisesValueErrorbefore any state changes.This is a collective operation and must be called on all ranks.
- SetVolumetricSources(self: pyopensn.solver.LBSProblem, **kwargs) None
Set or clear volumetric sources.
- Parameters:
clear_volumetric_sources (bool, default=False) – If true, all current the volumetric sources of the problem are deleted.
volumetric_sources (List[pyopensn.source.VolumetricSource]) – List of new volumetric sources to be added to the problem. When both arguments are given, the current sources are cleared before the new ones are added, regardless of keyword order. The new list is validated as a whole: a rejected call leaves the problem’s sources unchanged.
Notes
This is collective. A source caches mesh data when added. Prefer a separate source object for each problem. Share one only when both problems use the same mesh and spatial layout.
- SetXSMap(self: pyopensn.solver.LBSProblem, **kwargs) None
Replace the block-id to cross-section map.
- Parameters:
xs_map (List[Dict]) –
- A list of block-id to cross-section mapping dictionaries. Each dictionary supports:
- block_ids: List[int] (required)
Mesh block ids to associate with the cross section.
- xs: pyopensn.xs.MultiGroupXS (required)
Cross section object.
- Raises:
ValueError – If the problem was constructed with an
uncollided_fluxfile, or ifoptions.csda_enabled=Trueand the new cross sections split a charged-particle group block across groupsets, contain more than two charged-particle group ranges, have negative or non-finite stopping powers or non-positive energy-group widths, or have stopping power or energy bounds that do not match the problem’s group count. CSDA also rejects conflicting supplied energy structures, unknown or conflicting charged-particle species, or a map with no energy structure. Individual materials may omit bounds and use the shared structure.
Notes
This is collective.
The problem is refreshed immediately after replacing the map. Material metadata, precursor storage, GPU carriers, and derived solver state owned by the concrete problem are rebuilt for the new cross sections.
If
options.use_precursors=True, this flag remains active across XS-map changes even when the current map has no precursor-bearing material. In that case delayed-neutron source terms are simply inactive until a later map provides precursor data again.Existing precursor concentrations are remapped by local cell and precursor-family index. When the new material for a cell has fewer precursor families, extra old families are dropped. When it has more families, newly introduced families are initialized to zero. If a cell changes through a material with zero precursors, the precursor history for that cell is discarded and any later reintroduced precursor families start from zero.
If any fissionable material in the new map contains delayed-neutron precursor data and
options.use_precursors=True, all fissionable materials in the map must contain precursor data. Non-fissionable materials may have zero precursors.The new map is validated before it is committed. A validation error leaves the map unchanged. A later rebuild failure may leave partial changes. In time-dependent mode, every cross section must provide
VELOCITYorINV_VELOCITYdata.Forward/adjoint mode toggles via
LBSProblem.SetAdjoint()do not change this map. TheMultiGroupXSobjects themselves are mutable and shared by pointer, so a change to one, such asScale, is seen by every problem that uses it. The transport mode belongs to each problem: problems that share aMultiGroupXShandle can run in different modes.
- WriteAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str) None
Write angular flux data to file.
- Parameters:
file_base (str) – File basename.
- Raises:
ValueError – If the problem has an uncollided flux, whose stored angular flux holds only the collided part.
- WriteFluxMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write flux moments to file.
- Parameters:
file_base (str) – File basename.
- WriteSurfaceAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str, boundary_surfaces: list[str] = [], interior_surfaces: dict[str, tuple[str, float]] = {}) None
Write surface angular flux data to file.
- Parameters:
file_base (str) – File basename.
boundary_surfaces (list[str], default=[]) – Boundary names to export.
interior_surfaces (dict[str, tuple[str, float]], default={}) – Interior surfaces in the form {‘name’: (‘axis’, value)}, where axis is ‘x’, ‘y’, or ‘z’. Each interior surface is written under two tags: ‘<name>_u’ for faces whose outward normal aligns with the positive axis and ‘<name>_d’ for faces with the opposite orientation. An interior surface must lie inside the mesh, on cell faces (it may not cut through a cell), must match at least one cell face, and may not share a plane with another interior surface. Neither its name nor its generated tags may equal a requested boundary name. It may not coincide with an exterior boundary; export that boundary by name using boundary_surfaces instead.
Notes
Requires
options.save_angular_flux=True. Collective over all ranks; surface selections may differ by rank, but each file contains only its rank’s tags, andpyopensn.response.ResponseEvaluatorrequires every requested tag in every file of a set. Request the same surfaces on every rank for data that a ResponseEvaluator will read. Each rank writes<file_base><rank>.h5. The file records whether the problem is in adjoint mode, and for each tag whether it is one side of an interior surface or a boundary, so boundary names may end in_uor_d. An adjoint problem must have completed an adjoint steady-state or k-eigenvalue solve, which leaves the stored angular flux as the adjoint flux for the listed direction, so forward and adjoint data with the same indices refer to the same direction. Restart data are loaded in the internal sweep orientation, so execute an adjoint solver after a restart read before writing. For boundary tags the file also holds the boundary-condition values of the directions entering the domain. They are those the solve that produced the angular flux used, which the solver records when it finishes, so boundary conditions changed after the solve do not affect the file. An angular flux that has not come from a completed solve, because it was zeroed, read from a file, loaded from restart data, or reset by a mode change, has no such record and cannot be written.- Raises:
ValueError – If
options.save_angular_fluxis false; if the stored angular flux has not come from a completed solve; if the problem is in adjoint mode and its solution is not in the physical orientation left by an adjoint solve; if a boundary name is unknown or not on the mesh; or if an interior surface has an invalid axis, lies outside the mesh, cuts through a cell, shares a plane with another interior surface, coincides with an exterior boundary, matches no mesh faces, or has a name or generated tag equal to a requested boundary name. A problem with an uncollided flux is also rejected, because its stored angular flux holds only the collided part.RuntimeError – If no rank requests a surface, or if the file cannot be written.
- ZeroPhi(self: pyopensn.solver.LBSProblem) None
Zero the scalar-flux vectors (
phi_oldandphi_new) in-place.
- ZeroPsi(self: pyopensn.solver.DiscreteOrdinatesProblem) None
Zero the angular-flux storage.
- __init__(self: pyopensn.solver.DiscreteOrdinatesCurvilinearProblem, **kwargs) None
Construct a discrete ordinates problem for curvilinear geometry.
Two geometries are supported: 2D cylindrical (
r-z, a 2D mesh withcoord_sys="cylindrical"andpyopensn.aquad.GLCProductQuadrature2DRZ) and 1D spherical (a 1D radial mesh withcoord_sys="spherical"andpyopensn.aquad.GLProductQuadrature1DSpherical; boundarieszmin(inner) andzmax(outer), and a mesh starting at r = 0 is a solid sphere whose center needs no boundary condition). Groupsets must useangle_aggregation_type'azimuthal'or'single',sweep_typemust be'AAH', and time-dependent problems and GPU acceleration are not supported. Integrated quantities are reported for the full revolution (r-z) or the full sphere.Warning
DiscreteOrdinatesCurvilinearProblem is experimental and should be used with caution!
- Parameters:
mesh (Mesh) – The spatial mesh. Its geometry type (cylindrical or spherical) is taken directly from the mesh – e.g. from the
coord_sysargument used to build it with a mesh generator. There is no separatecoord_systemparameter on this class; supplying one is rejected as an unknown parameter.num_groups (int) – The total number of energy groups.
groupsets (list of dict) –
A list of input parameter blocks, each block provides the iterative properties for a groupset. Each dictionary supports:
- groups_from_to: List[int] (required)
Two-entry list with the first and last group id for the groupset, e.g.
[0, 3].
- angular_quadrature: pyopensn.aquad.AngularQuadrature, optional
Handle to an angular quadrature.
- angle_aggregation_type: {‘single’, ‘azimuthal’}, default=’single’
Angle aggregation method to use during sweeping. Curvilinear problems do not support
'polar'.
inner_linear_method: {‘classic_richardson’, ‘petsc_richardson’, ‘petsc_gmres’, ‘petsc_fgmres’, ‘petsc_bicgstab’}, default=’petsc_richardson’
Iterative method used for inner linear solves.
'petsc_fgmres'is flexible GMRES with right preconditioning; it remains exact when the WGDSA/TGDSA preconditioner solves its diffusion system only approximately.- l_abs_tol: float, default=1.0e-6
Inner linear solver absolute residual tolerance.
- l_max_its: int, default=200
Inner linear solver maximum iterations.
- gmres_restart_interval: int, default=30
GMRES restart interval, if GMRES is used.
- allow_cycles: bool, default=True
Whether cyclic dependencies are allowed in sweeps.
- apply_wgdsa: bool, default=False
Enable within-group DSA for this groupset. After each groupset iteration, one diffusion solve corrects the scalar flux of every group of the groupset. The system is block diagonal in energy: the source of group g is the change of its within-group scattering source, and the groups are not coupled, unless
wgdsa_energy_couplingis set.
- wgdsa_energy_coupling: bool, default=False
Couple the WGDSA corrections of the groupset in energy. The source of group g is the change of the scattering into g from every groupset group, and the groups are solved one at a time from the highest energy, each also receiving the in-groupset downscatter of the corrections of the groups above it. Upscatter of the corrections is not included, so groupsets dominated by upscatter gain less. Each group has its own diffusion solver, and
wgdsa_direct_solve_thresholdcounts the unknowns of one group, so a run on one MPI process can factor every group directly. In 3D, that can cost more thanwgdsa_solver_policy='iterative'. Requiresapply_wgdsa. See Energy-Coupled Within-group Acceleration.
- wgdsa_l_abs_tol: float, default=1.0e-4
Residual tolerance of the WGDSA diffusion solve, relative to the norm of its right-hand side (the name is historical).
- wgdsa_l_max_its: int, default=30
WGDSA maximum iterations.
- wgdsa_verbose: bool, default=False
Verbose WGDSA output.
- wgdsa_petsc_options: str, default=’’
PETSc options string for the WGDSA solver. Options must carry the solver’s prefix, the problem name followed by
_WGDSA. Withwgdsa_energy_coupling, the groupset has one solver per group, whose prefix is the problem name followed by_WGDSA_gand the global group index.
- wgdsa_solver_policy: {‘auto’, ‘direct’, ‘iterative’, ‘petsc_options’}, default=’auto’
WGDSA diffusion solver policy.
autouses a direct PETSc LU solve on one MPI process at or belowwgdsa_direct_solve_thresholdglobal unknowns, and conjugate gradients preconditioned by BoomerAMG otherwise.petsc_optionsletswgdsa_petsc_optionscontrol the PETSc KSP/PC setup.
- wgdsa_direct_solve_threshold: int, default=20000
Maximum global WGDSA diffusion unknown count for the automatic direct solve, the number of spatial nodes times the number of groups in the groupset, or of one group with
wgdsa_energy_coupling.
- wgdsa_boundary_closure: {‘marshak’, ‘closure_r’, ‘dirichlet’}, default=’marshak’
Boundary condition of the WGDSA diffusion correction on vacuum, isotropic and arbitrary boundaries.
marshakimposes the natural Marshak condition, a face mass term with coefficient 1/2;closure_rblends the Marshak form written with the quadrature’s partial current (face mass coefficient 2 beta_f, beta_f the quadrature’s half-range moment, against the analytic 1/2) on thin boundary cells with the half-range transport form on thick ones, uses beta_f as the floor of the interior penalty, and is faster thanmarshakwhen boundary cells are many mean free paths thick;dirichlet(OpenSn’s original) imposes a zero correction weakly (interior-penalty term). Reflecting boundaries are zero-current, except that on a reflecting boundary that lags its incoming flux, WGDSA imposes the inward partial current of the change of the lagged flux.
- apply_tgdsa: bool, default=False
Enable two-grid DSA for this groupset. After each groupset iteration (after WGDSA), one energy-collapsed diffusion solve corrects the error mode that the scattering between the groups of the groupset couples. Requires at least two groups in the groupset.
- tgdsa_l_abs_tol: float, default=1.0e-4
Residual tolerance of the TGDSA diffusion solve, relative to the norm of its right-hand side (the name is historical).
- tgdsa_l_max_its: int, default=30
TGDSA maximum iterations.
- tgdsa_verbose: bool, default=False
Verbose TGDSA output.
- tgdsa_petsc_options: str, default=’’
PETSc options string for the TGDSA solver. Options must carry the solver’s prefix, the problem name followed by
_TGDSA.
- tgdsa_solver_policy: {‘auto’, ‘direct’, ‘iterative’, ‘petsc_options’}, default=’auto’
TGDSA diffusion solver policy.
autouses a direct PETSc LU solve on one MPI process at or belowtgdsa_direct_solve_thresholdglobal unknowns, and conjugate gradients preconditioned by BoomerAMG otherwise.petsc_optionsletstgdsa_petsc_optionscontrol the PETSc KSP/PC setup.
- tgdsa_direct_solve_threshold: int, default=20000
Maximum global TGDSA diffusion unknown count for the automatic direct solve, the number of spatial nodes.
- tgdsa_boundary_closure: {‘marshak’, ‘closure_r’, ‘dirichlet’}, default=’marshak’
Boundary condition of the TGDSA diffusion correction, with the same choices and boundaries as
wgdsa_boundary_closure.
- wgdsa_h_perp_convention: {‘face_side’, ‘cell’}, default=’face_side’
Penalty length of the WGDSA MIP operator.
face_sideuses the face-dependent orthogonal length (3V/A_f tet, V/A_f hex and quad, 2V/A_f triangle) capped by four times the smallest height of the face’s PWLD side simplices, with an extra factor 2 on polygons and polyhedra; the cap keeps the operator positive definite on strongly distorted cells and is inactive on regular ones.cell(OpenSn’s original) uses the cell-wide lengths 3V/S (tet) and V/S (hex) with the extra factor 2, and on polygons the face-dependent lengths without the cap or the factor 2. On polyhedra its penalty is larger (six times on cubes), which slows DSA on cells a few mean free paths thick; on polygons it is half theface_sidepenalty and can make the operator indefinite on strongly distorted cells.
- tgdsa_h_perp_convention: {‘face_side’, ‘cell’}, default=’face_side’
Penalty length of the TGDSA MIP operator, as
wgdsa_h_perp_convention.
xs_map (list of dict) –
- A list of mappings from block ids to cross-section definitions. Each dictionary supports:
- block_ids: List[int] (required)
Mesh block IDs to associate with the cross section.
- xs: pyopensn.xs.MultiGroupXS (required)
Cross-section object to assign to the specified blocks.
boundary_conditions (List[Dict], default=[]) –
- A list containing tables for each boundary specification. Each dictionary supports:
- name: str (required)
Boundary name that identifies the specific boundary.
- type: {‘vacuum’, ‘isotropic’, ‘reflecting’, ‘arbitrary’} (required)
Boundary type specification.
- group_strength: List[float], optional
Required when
type='isotropic'. Isotropic strength per group.
- start_time: float, optional
Active start time for isotropic boundaries only. Defaults to -infinity.
- end_time: float, optional
Active end time for isotropic boundaries only. Defaults to infinity.
- function: AngularFluxFunction, optional
Required when
type='arbitrary'unlesstime_functionis supplied. Callable that returns incoming angular flux from group and direction.
- time_function: AngularFluxTimeFunction, optional
Required when
type='arbitrary'unlessfunctionis supplied. Callable that returns incoming angular flux from group, direction, and time.
Isotropic boundaries may use
start_time/end_timefor simple on/off behavior. Arbitrary boundaries must specify exactly one offunctionortime_function; usetime_functionfor time-dependent arbitrary inflow and handle any active window inside that callback.point_sources (List[pyopensn.source.PointSource], default=[]) – A list of point sources.
volumetric_sources (List[pyopensn.source.VolumetricSource], default=[]) – A list of volumetric sources.
options (dict, optional) –
- A block of optional configuration parameters applied at problem creation, including:
- max_mpi_message_size: int, default=4194304
Maximum size in bytes of one sweep MPI message. Larger angular-flux transfers are split into messages of at most this size.
- max_mpi_outstanding_sends: int, default=0
Maximum number of sweep MPI sends that each rank may have posted and not yet completed. Further messages wait until earlier ones complete, and an angle set whose messages exceed the limit sends them in turn. With CSDA, a psi message and its psiE partner count as 2 sends and are posted together when no other send is outstanding, so a limit of 1 allows 2 posted sends. Set it below the network transmit queue size when MPI runs out of transmit resources, for example below
FI_CXI_DEFAULT_TX_SIZEon Slingshot when MPICH warns about rendezvous message resource exhaustion. The solution does not depend on it. 0 means no limit. Must be at least 0. Requiressweep_type="AAH"anduse_gpus=Falsewhen positive.
- restart_writes_enabled: bool, default=False
Enable restart dump writes for solvers that support restart output.
- write_delayed_psi_to_restart: bool, default=True
Include delayed sweep angular-flux buffers in steady-state restart dumps. These buffers are optional when a steady-state restart is used only as a transient initial condition because the transient initialization can reconstruct angular state from the flux moments. Time-dependent restart dumps always include them, regardless of this option, because continuing a transient requires them whenever the problem has delayed sweep angular state, including partitioned parallel, reflected-boundary, and cyclic-sweep cases.
- write_angular_flux_to_restart: bool, default=True
Include stored angular fluxes in steady-state restart dumps when
save_angular_flux=True. They are optional when a steady-state restart is used only as a transient initial condition. Time-dependent restart dumps always include them, regardless of this option, because continuing a transient requires them.
- read_restart_path: str, default=’’
File stem for reading a full restart. Scalar flux and precursor data can be remapped when the MPI rank count or mesh partition changes. Full transient continuation still requires the original partitioned angular state layout.
- read_initial_condition_path: str, default=’’
File stem for reading restart data as an initial condition. Cannot be combined with
read_restart_path. A steady-state restart may be used byTransientSolverthrough this option. The firstTransientSolver.Initialize()loads it once; later initializations continue from the problem’s current state.
- write_restart_path: str, default=’’
File stem for restart dump writes. OpenSn appends the MPI rank and
.restart.h5to this stem.
write_restart_time_interval: int, default=0
use_precursors: bool, default=True Enable delayed neutrons. With
Falseevery solve uses prompt neutrons only, even if the cross sections have delayed-neutron data. This remains active across laterSetXSMapcalls, even if the current map temporarily has no precursor-bearing material. When XS maps change, precursor concentrations are remapped by cell and precursor-family index; newly introduced families start at zero and removed families are discarded.delayed_neutrons: bool, default=True Alias of
use_precursors. Give at most one of the two names.use_source_moments: bool, default=False Use the problem’s source moments as the fixed source instead of its volumetric and point sources. Provide them (e.g. with
ReadSourceMoments) after creating the problem and before solving; a solve without them raisesValueError. They are an external source, so the k-eigenvalue solvers reject a problem with this option.save_angular_flux: bool, default=False Store angular flux state (psi) for transient mode, angular-flux field functions, and angular-flux I/O.
deterministic_sweeps: bool, default=False Make every sweep bitwise reproducible from run to run: the scalar flux moments and face outflows are summed from stored angular fluxes in a fixed angle order instead of in the order that MPI messages arrive. Stores the angular flux in host memory without enabling
save_angular_flux. Meant for debugging and reproducible comparisons.csda_enabled: bool, default=False Enable CSDA charged-particle transport for CEPXS data loaded with
csda_format=True. CSDA is not supported for this curvilinear problem class.verbose_inner_iterations: bool, default=True Print inner iteration details, including WGS and AGS iterations.
verbose_outer_iterations: bool, default=True Print outer solver progress, including PI/NLKE iterations and transient steps.
max_ags_iterations: int, optional Maximum across-groupset iterations per transport solve. A value set here is used by every solver. If it is not set, each solver uses its own default: 100 for the steady-state and transient solvers, and 1 in each power iteration of
pyopensn.solver.PowerIterationKEigenSolver.ags_tolerance: float, default=1.0e-6
ags_convergence_check: {‘pointwise’, ‘l2’}, default=’pointwise’
power_default_kappa: float, default=3.20435e-11
field_function_prefix_option: {‘prefix’, ‘solver_name’}, default=’prefix’
field_function_prefix: str, default=’’
sweep_type (str, optional) – The sweep type to use. Curvilinear problems support only AAH, the default. Time-dependent mode is not supported for curvilinear problems.