ndiffusion.make_materials

ndiffusion.make_materials(data_list, G, descending_energy=None, scatter_orientation='to_from')[source]

Build a configured Materials object from a list of cross-section dicts.

Each dict (e.g., the result of np.load("material.npz")) must contain:

  • D - diffusion coefficients, shape (G,)

  • Siga - absorption cross sections, shape (G,)

  • Scat - scatter matrix, shape (G, G), scatter[g_to][g_from] by default (see scatter_orientation)

  • nuSigf - nu-fission cross sections, shape (G,) or (G, G)

Optional keys:

  • Removal - precomputed removal cross sections, shape (G,).

    If present, skips removal computation and does not zero the scatter diagonal. Siga is then unused and may be omitted (this is the path ndiffusion.make_materials_from_transport() takes).

  • chi - fission spectrum, shape (G,). Defaults to all-zeros

    when absent (activates fission-matrix mode in the solver when nuSigf is also a matrix).

Removal computation and the scatter diagonal

The solver convention is scatter[g_to][g_from] with the self-scatter diagonal excluded (it cancels out of the removal term). When Removal is not supplied, this function derives it as Siga[g] + (total out-scatter from g) - Scat[g, g] and then zeroes the diagonal of Scat in place. When Removal is supplied the data is taken as-is and the diagonal is left untouched - the caller is then responsible for providing a Scat matrix consistent with that Removal.

The “total out-scatter from g” is the column sum sum_{g_to} Scat[g_to][g] once Scat is in the solver’s [g_to][g_from] order - that is, axis=0. Which axis that is in the input depends on how the caller stored the matrix, so it is selected by scatter_orientation, as in ndiffusion.transport_to_diffusion(). A "from_to" matrix is transposed into solver order first, keeping the stored transfer matrix and the derived removal consistent.

param data_list:

Ordered list of cross-section data containers, one per material.

type data_list:

list of dict-like

param G:

Number of energy groups.

type G:

int

param descending_energy:

Deprecated - use scatter_orientation, which names the array orientation this argument actually selected. True is equivalent to scatter_orientation="to_from" and warns; False raises, because it summed the out-scatter over one axis while passing the matrix through untransposed - pass scatter_orientation="from_to" instead.

type descending_energy:

bool or None, optional

param scatter_orientation:

Storage order of the input Scat matrix. "to_from" (default) is the solver’s own convention, Scat[g_to][g_from], and is used as-is; "from_to" is the usual transport-library convention, Scat[g_from][g_to], and is transposed into solver order. Applies whether or not Removal is supplied.

type scatter_orientation:

{“to_from”, “from_to”}, optional

returns:

Fully configured Materials object ready to pass to a solver.

rtype:

Materials