discrete1.multi_group_0d module
Infinite medium multigroup solver.
This module provides multigroup-level driver routines that orchestrate outer iterations over energy groups and angles (discrete ordinates).
Public routines include: - source_iteration: standard multigroup source iteration - discrete_ordinates: discrete ordinates for one group
The multigroup drivers expect arrays shaped as used by the rest of the package (angular and group axes as described in function docstrings).
- discrete1.multi_group_0d.discrete_ordinates_aniso(flux_old, xs_total, xs_self_scatter, xs_scatter_w, off_scatter, external, angle_x, angle_w, P, P_weights)[source]
Angular sweep for anisotropic scattering.
This function returns the updated scalar flux array evaluated at a specific energy group.
- Parameters:
flux_old (
float) – Previous iterate of the scalar flux.xs_total (
float) – Total macroscopic cross sections per material.xs_self_scatter (
float) – Within-group Legendre scatter momentsxs_scatter_w (
numpy.ndarray,shape (L+1,)) – Precomputed (2l+1) * xs_self_scatter.off_scatter (
float) – Off-diagonal scatter correction/source term (shape: n_cells,).external (
numpy.ndarray) – External source array (n_angles, n_groups).angle_x (
numpy.ndarray) – Angular ordinates (n_angles,).angle_w (
numpy.ndarray) – Quadrature weights (n_angles,).P (
numpy.ndarray,shape (L+1,angles)) – Precomputed P[l, n] = P_l(mu_n).P_weights (
numpy.ndarray,shape (L+1,angles)) – Precomputed w_n * P_l(mu_n).
- Returns:
Updated scalar flux for energy group.
- Return type:
float
- discrete1.multi_group_0d.discrete_ordinates_iso(flux_old, xs_total, xs_scatter, off_scatter, external, angle_x, angle_w)[source]
Angular sweep for isotropic scattering.
This function returns the updated scalar flux array evaluated at a specific energy group.
- Parameters:
flux_old (
float) – Previous iterate of the scalar flux.xs_total (
float) – Total macroscopic cross sections per material.xs_scatter (
float) – Scatter cross section used in source evaluation.off_scatter (
float) – Off-diagonal scatter correction/source term (shape: n_cells,).external (
numpy.ndarray) – External source array (n_angles, n_groups).angle_x (
numpy.ndarray) – Angular ordinates (n_angles,).angle_w (
numpy.ndarray) – Quadrature weights (n_angles,).
- Returns:
Updated scalar flux for energy group.
- Return type:
float
- discrete1.multi_group_0d.source_iteration(flux_old, xs_total, xs_scatter, external, angle_x, angle_w, P=None, P_weights=None)[source]
Multigroup source iteration solver - dispatches to iso or aniso variant.
Performs outer iterations over energy groups using inner discrete ordinates sweeps for each group. Off-diagonal scatter (up- and down-scatter) contributions are handled via an “off_scatter” accumulator that uses the previous and current flux iterates.
- Parameters:
flux_old (
numpy.ndarray) – Initial scalar flux guess with shape (n_groups,).xs_total (
array_like) – Total cross sections (n_groups,).xs_scatter (
array_like) – Scatter cross sections (n_groups, n_groups).external (
numpy.ndarray) – External source array (n_angles, n_groups) or with singleton dimensions where appropriate.angle_x (
array_like) – Angular ordinates (n_angles,).angle_w (
array_like) – Quadrature weights (n_angles,).P (
numpy.ndarray,shape (L+1,angles), optional) – Precomputed Legendre polynomials. Required for anisotropic.P_weights (
numpy.ndarray,shape (L+1,angles), optional) – Precomputed w_n * P_l(mu_n). Required for anisotropic.
- Returns:
Converged scalar flux.
- Return type:
numpy.ndarray,shape (n_groups,)
- discrete1.multi_group_0d.source_iteration_aniso(flux_old, xs_total, xs_scatter, external, angle_x, angle_w, P, P_weights)[source]
Multigroup source iteration for anisotropic scattering.
Identical workflow to
source_iteration_iso()but each group sweep uses the full Legendre expansion of the scatter kernel. The within-group anisotropic correction is applied inside the angular sweep; only the L=0 moment drives the off-diagonal scatter term.- Parameters:
flux_old (
numpy.ndarray) – Initial scalar flux guess with shape (n_groups,).xs_total (
array_like) – Total cross sections (n_groups,).xs_scatter (
array_like) – Scatter cross sections (n_groups, n_groups).external (
numpy.ndarray) – External source array (n_angles, n_groups) or with singleton dimensions where appropriate.angle_x (
array_like) – Angular ordinates (n_angles,).angle_w (
array_like) – Quadrature weights (n_angles,).P (
numpy.ndarray,shape (L+1,n_angles)) – Precomputed Legendre polynomialsP[l, n]= P_l(mu_n).P_weights (
numpy.ndarray,shape (L+1,n_angles)) – Precomputedw_n * P_l(mu_n)used for flux moment accumulation.
- Returns:
Converged scalar flux array with shape (n_groups,).
- Return type:
numpy.ndarray
- discrete1.multi_group_0d.source_iteration_iso(flux_old, xs_total, xs_scatter, external, angle_x, angle_w)[source]
Multigroup source iteration solver for isotropic scattering.
Performs outer iterations over energy groups using inner discrete ordinates sweeps for each group. Off-diagonal scatter (up- and down-scatter) contributions are handled via an “off_scatter” accumulator that uses the previous and current flux iterates.
- Parameters:
flux_old (
numpy.ndarray) – Initial scalar flux guess with shape (n_groups,).xs_total (
array_like) – Total cross sections (n_groups,).xs_scatter (
array_like) – Scatter cross sections (n_groups, n_groups).external (
numpy.ndarray) – External source array (n_angles, n_groups) or with singleton dimensions where appropriate.angle_x (
array_like) – Angular ordinates (n_angles,).angle_w (
array_like) – Quadrature weights (n_angles,).
- Returns:
Converged scalar flux array with shape (n_groups,).
- Return type:
numpy.ndarray