discrete1.utils.hybrid module
Functions to be used with the collision-based hybrid method.
Allows for discretizing energy grids and material cross sections
- discrete1.utils.hybrid.coarsen_external(external, edges_g, edges_gidx, weight=False)[source]
Coarsen (… x groups) arrays to (… x groups').
- Parameters:
external (
numpy.ndarray) – Array with float type of shape (…, groups). Array to coarsen.edges_g (
numpy.ndarray) – 1D array with float type of shape (groups + 1,). Energy group bounds.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups' + 1,). Index of energy group bounds for new energy grid.weight (
bool, optional) – Weighting the collapsing groups. Default is False.
- Returns:
Array with float type of shape (…, groups').
- Return type:
numpy.ndarray
- discrete1.utils.hybrid.coarsen_materials(xs_total, xs_scatter, xs_fission, edges_g, edges_gidx)[source]
Coarsen (materials, groups) arrays to (materials, groups').
- Parameters:
xs_total (
numpy.ndarray) – 2D array with float type of shape (materials, groups). Total cross section.xs_scatter (
numpy.ndarray) – 3D array with float type of shape (materials, groups, groups). Scatter cross section.xs_fission (
numpy.ndarray) – 3D array with float type of shape (materials, groups, groups). Fission cross section.edges_g (
numpy.ndarray) – 1D array with float type of shape (groups + 1,). Energy group bounds.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups' + 1,). Index of energy group bounds for new energy grid.
- Returns:
coarse_total (
numpy.ndarray) – 2D array with float type of shape (materials, groups'). Coarsened total cross section.coarse_scatter (
numpy.ndarray) – 3D array with float type of shape (materials, groups', groups'). Coarsened scatter cross section.coarse_fission (
numpy.ndarray) – 3D array with float type of shape (materials, groups', groups'). Coarsened fission cross section.
- discrete1.utils.hybrid.coarsen_velocity(vector, edges_gidx)[source]
Coarsen (groups,) vector to (groups',) where groups > groups'.
- Parameters:
vector (
numpy.ndarray) – 1D array with float type of shape (groups,). Array to coarsen.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups' + 1,). Index of energy group bounds for new energy grid
- Returns:
1D array with float type of shape (groups',).
- Return type:
numpy.npdarray
- discrete1.utils.hybrid.collided_index(groups_fine, edges_gidx)[source]
Calculate which coarse group a fine energy group is a part of.
This is done through:
fine grid : |---g1---|--g2--|---g3---|--g4--| coarse grid: |-------g1------|-------g2------|
results in coarse_idx = [0, 0, 1, 1]
- Parameters:
groups_fine (
int) – Number of fine energy groups.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups_coarse + 1,). Index of energy group bounds for coarse energy grid.
- Returns:
1D array with int type of shape (groups_fine,).
- Return type:
numpy.ndarray
- discrete1.utils.hybrid.energy_coarse_index(fine, coarse)[source]
Get the indices for resizing matrices.
- Parameters:
fine (
int) – Larger energy group size.coarse (
int) – Coarser energy group size.
- Return type:
numpy.ndarray,int,shape (coarse + 1,)
- discrete1.utils.hybrid.energy_grid_change(starting_grid, groups_u, groups_c)[source]
Calculate the variables needed for refining and coarsening fluxes in vhybrid.
- Parameters:
starting_grid (
int) – Value of starting energy grid, could be 87, 361, 618.groups_u (
int) – Number of uncollided energy groups.groups_c (
int) – Number of collided energy groups.
- Returns:
coarse_idx (
numpy.ndarray) – 1D array with int type of shape (groups_fine,). Coarse group mapping.factor (
numpy.ndarray) – 1D array with float type of shape (groups_fine,). Fine energy bin width / coarse energy bin width for specific location.edges_gidx_c (
numpy.ndarray) – 1D array with int type of shape (groups_c + 1,). Coarse group index mapping.edges_g (
numpy.ndarray) – 1D array with float type of shape (groups_u + 1,). Energy bound locations.
- discrete1.utils.hybrid.hybrid_factor(delta_fine, delta_coarse, edges_gidx)[source]
Calculate the fine energy bin width per coarse energy bin width.
This is done through
location (eV): 0 3 5 8 10 fine grid : |---g1---|--g2--|---g3---|--g4--| coarse grid : |-------g1------|-------g2------|
results in factor = [3/5, 2/5, 3/5, 2/5] with widths [3, 2, 2, 3] for the fine groups and [5, 5] for the coarse groups
- Parameters:
delta_fine (
numpy.ndarray) – 1D array with float type of shape (groups_fine,). Energy group width for fine grid.delta_coarse (
numpy.ndarray) – 1D array with float type of shape (groups_fine,). Energy group width for coarse grid.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups_coarse + 1,). Index of energy group bounds for coarse energy grid.
- Returns:
1D array of float type with shape (groups_fine,). Fine energy bin width / coarse energy bin width for specific location.
- Return type:
numpy.ndarray
- discrete1.utils.hybrid.indexing(edges_g, edges_gidx_fine, edges_gidx_coarse)[source]
Calculate the variables needed for refining and coarsening fluxes.
- Parameters:
edges_g (
numpy.ndarray) – 1D array with float type of shape (groups_fine + 1,). Energy group bounds for fine grid.edges_gidx_fine (
numpy.ndarray) – 1D array with int type of shape (groups_fine + 1,). Index of energy group bounds for fine energy grid.edges_gidx_coarse (
numpy.ndarray) – 1D array with int type of shape (groups_coarse + 1,) Index of energy group bounds for coarse energy grid.
- Returns:
coarse_idx (
numpy.ndarray) – 1D array with int type of shape (groups_fine,). Coarse group mapping.fine_idx (
numpy.ndarray) – 1D array with int type of shape (groups_coarse + 1,). Location of edges between the coarse and fine energy grids.factor (
numpy.ndarray) – 1D array with float type of shape (groups_fine,). Fine energy bin width / coarse energy bin width for specific location.
- discrete1.utils.hybrid.uncollided_index(groups_coarse, edges_gidx)[source]
Calculate the location of edges between the coarse and fine energy grids.
This is done through
edge : 0 1 2 3 4 fine grid : |---g1---|--g2--|---g3---|--g4--| coarse grid: |-------g1------|-------g2------|
results in fine_idx = [0, 2, 4]
- Parameters:
groups_coarse (
int) – Number of coarse energy groups where groups_fine >= groups_coarse.edges_gidx (
numpy.ndarray) – 1D array with int type of shape (groups_coarse + 1,). Index of energy group bounds for coarse energy grid.
- Returns:
1D array with int type of shape (groups_coarse + 1,). Location of edges between the coarse and fine energy grids.
- Return type:
numpy.ndarray