pyopensn.solver.LBSProblem
- class pyopensn.solver.LBSProblem
Base class for all linear Boltzmann problems.
Wrapper of
opensn::LBSProblem.- 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.
- 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.
- Return type:
float
- Raises:
ValueError – If scalar_flux_iterate is not ‘old’ or ‘new’.
- CreateAndWriteSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write source moments from latest flux iterate to file.
- Parameters:
file_base (str) – File basename.
- 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
- GetPowerFieldFunction(self: pyopensn.solver.LBSProblem) pyopensn.fieldfunc.FieldFunctionGridBased
Returns the power generation field function, if enabled.
- 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
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.LBSProblem) bool
Return
Trueif the problem is in time-dependent mode, otherwiseFalse.
- 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 if all flux moments are in a single file.
- ReadFluxMomentsAndMakeSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read flux moments and compute corresponding source moments.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True if all flux moments are in a single file.
- ReadSourceMoments(self: pyopensn.solver.LBSProblem, file_base: str, single_file_flag: bool) None
Read source moments from file.
- Parameters:
file_base (str) – File basename.
single_file_flag (bool) – True if all source moments are in a single file.
- 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.
Notes
- This is one of two supported mode-setting paths in Python:
options={'adjoint': ...}in the problem constructor.SetAdjoint(...)(this method).
- If this changes mode, OpenSn performs a full mode-transition reset:
Materials are reinitialized in the selected mode.
Point and volumetric sources are cleared.
Boundary conditions are cleared.
Scalar and angular flux vectors are zeroed.
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. However, the mode change is applied to the mapped
MultiGroupXSobjects themselves. If those objects are shared with other problems, they observe the same mode toggle.- After a mode change, reapply the desired driving terms before solving, typically:
This routine is intentionally destructive with respect to source/boundary/flux state to avoid hidden coupling between forward and adjoint setups.
- SetForward(self: pyopensn.solver.LBSProblem) None
Set forward transport mode.
Equivalent to
SetAdjoint(False).
- 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.
- 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.
- 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.
Notes
Forward/adjoint mode toggles via
LBSProblem.SetAdjoint()do not change this map. TheMultiGroupXSobjects themselves are mutable and shared by pointer. If the sameMultiGroupXShandle is shared across multiple problems, toggling adjoint mode in one problem also changes the transport mode seen by the others.
- WriteAngularFluxes(self: opensn::DiscreteOrdinatesProblem, file_base: str) None
Write angular flux data to file.
- Parameters:
file_base (str) – File basename.
- WriteFluxMoments(self: pyopensn.solver.LBSProblem, file_base: str) None
Write flux moments to file.
- Parameters:
file_base (str) – File basename.
- ZeroPhi(self: pyopensn.solver.LBSProblem) None
Zero the scalar-flux vectors (
phi_oldandphi_new) in-place.
- ZeroPsi(self: pyopensn.solver.LBSProblem) None
Zero the angular-flux storage (if present for this problem type).