ndiffusion.layouts

Preset core layouts, symmetry orientations, and matching boundary conditions.

Three things compose here, and each is independent of the other two:

  • a geometry - cartesian_mesh() or hex_mesh() produce cells and tagged boundary faces, and know nothing about cross sections;

  • an orientation - the symmetry sector the geometry is cut down to, which also decides which boundary faces are symmetry cuts and which are the physical outer surface;

  • a layout - a painter (x, y) -> material index handed to ndiffusion.assign_materials().

So one geometry drives many layouts, and one layout can be evaluated on any geometry:

mesh = layouts.cartesian_mesh(width=100.0, h=2.0, orientation="quarter")
nd.assign_materials(mesh, layouts.core_reflector(core_radius=35.0))
bc = layouts.boundary_conditions(mesh, D=[1.4, 0.4], albedo=0.0)
keff = nd.KEigenSolverUnstructured2D(mats, mesh, bc).solve().keff

Boundary tags

Generators tag every boundary face either SYMMETRY or OUTER. boundary_conditions() then builds the tag-indexed bc array the unstructured solvers expect - reflective on the symmetry cuts, Marshak with the given albedo on the outer surface. Getting that pairing wrong is silent (a missed vacuum surface just reads as a higher keff), which is the main reason to preset it.

Module Attributes

SYMMETRY

Boundary tag for symmetry cuts introduced by an orientation (reflective).

OUTER

Boundary tag for the physical outer surface (vacuum, or an albedo).

Functions

annular(radii, materials[, origin])

Concentric rings.

boundary_conditions(mesh, D[, albedo])

Tag-indexed bc array pairing symmetry cuts with the outer surface.

cartesian_mesh(width, h[, height, ...])

Quad mesh of a rectangular core, centered on the origin.

checkerboard(pitch[, materials, origin])

Alternating materials on a square lattice of the given pitch.

core_reflector([core_radius, ...])

Two regions: a central core inside a reflector.

hex_mesh(pitch, n_rings[, orientation, symmetry])

Honeycomb of regular hexagons arranged in rings about the origin.

hex_rings(pitch, ring_materials[, origin])

Material per hexagonal ring, ring 0 being the central cell.

homogeneous([material])

One material everywhere.

with_rods(base, positions, radius, material)

Overlay control rods on another layout.

ndiffusion.layouts.SYMMETRY = 0

Boundary tag for symmetry cuts introduced by an orientation (reflective).

ndiffusion.layouts.OUTER = 1

Boundary tag for the physical outer surface (vacuum, or an albedo).

ndiffusion.layouts.cartesian_mesh(width, h, height=None, orientation='full', symmetry='mirror')[source]

Quad mesh of a rectangular core, centered on the origin.

Parameters:
  • width (float) – Full core dimensions in cm; height defaults to width.

  • height (float) – Full core dimensions in cm; height defaults to width.

  • h (float) – Target cell size. Rounded so that x=0 and y=0 fall on cell edges, which keeps the symmetry cuts free of sliver cells.

  • orientation ({"full", "half", "quarter", "eighth", "infinite"}) – Symmetry sector to keep. "half" keeps x >= 0, "quarter" also y >= 0, "eighth" also y <= x (the 45-degree octant). "infinite" keeps the full domain but tags every boundary as a symmetry cut, giving k-infinity for a repeating lattice.

  • symmetry ({"mirror", "rotational"}) – How the symmetry cuts are closed. "mirror" (default) makes them reflective. "rotational" joins the two cuts periodically instead, imposing rotational symmetry without mirror symmetry - the right choice for a spiral or pinwheel loading, where reflecting would solve a different problem. Not available for "full" or "infinite", which have no cuts.

Returns:

Boundary faces tagged SYMMETRY or OUTER.

Return type:

UnstructuredMesh2D

ndiffusion.layouts.hex_mesh(pitch, n_rings, orientation='full', symmetry='mirror')[source]

Honeycomb of regular hexagons arranged in rings about the origin.

Ring 0 is the single central cell and ring k adds 6k cells, so the full core has 1 + 3 n (n+1) cells. Hexagons are pointy-top; pitch is the center-to-center distance of neighbors.

Parameters:
  • pitch (float) – Lattice pitch in cm.

  • n_rings (int) – Number of rings beyond the central cell.

  • orientation ({"full", "half", "sector120", "sector60", "sector30", "infinite"}) – Symmetry sector. The sector cuts pass through the origin, so they slice hexagons into smaller polygons - which the solver handles directly.

  • symmetry ({"mirror", "rotational"}) – How the symmetry cuts are closed. "mirror" (default) makes them reflective. "rotational" joins the two cuts periodically instead, imposing rotational symmetry without mirror symmetry - the right choice for a spiral or pinwheel loading, where reflecting would solve a different problem. Not available for "full" or "infinite", which have no cuts.

Return type:

UnstructuredMesh2D

ndiffusion.layouts.boundary_conditions(mesh, D, albedo=0.0)[source]

Tag-indexed bc array pairing symmetry cuts with the outer surface.

Parameters:
  • mesh (UnstructuredMesh2D) – Mesh from one of the generators above, carrying SYMMETRY / OUTER tags.

  • D (sequence of float) – Diffusion coefficient per energy group, for the Marshak outer condition.

  • albedo (float) – 0 = vacuum, 1 = fully reflective, in between = partial return.

Returns:

Length 2 * n_groups, indexed bc[tag * n_groups + g].

Return type:

list of BoundaryCondition

ndiffusion.layouts.homogeneous(material=0)[source]

One material everywhere. The baseline for sanity checks.

ndiffusion.layouts.core_reflector(core_radius=None, core_half_width=None, core=0, reflector=1)[source]

Two regions: a central core inside a reflector.

Give exactly one of core_radius (circular core) or core_half_width (square core). The circular form puts a curved material interface on the mesh, which is where the non-orthogonal correction earns its keep.

ndiffusion.layouts.checkerboard(pitch, materials=(0, 1), origin=(0.0, 0.0))[source]

Alternating materials on a square lattice of the given pitch.

The sharpest heterogeneity a two-material problem can have: every cell borders only the other material, which is the worst case for the group-sweep iteration.

ndiffusion.layouts.annular(radii, materials, origin=(0.0, 0.0))[source]

Concentric rings.

radii are the outer radii of the inner regions, ascending; materials is one longer, the last entry covering everything beyond the final radius.

ndiffusion.layouts.hex_rings(pitch, ring_materials, origin=(0.0, 0.0))[source]

Material per hexagonal ring, ring 0 being the central cell.

ring_materials is indexed by ring number; anything beyond its length takes the last entry, so [0, 0, 1] is a two-ring core inside a reflector.

ndiffusion.layouts.with_rods(base, positions, radius, material)[source]

Overlay control rods on another layout.

Pairs with the un-rodded base to give the perturbation the mesh/material split was built for: paint one, solve, paint the other, solve, and the two eigenvalues give the rod worth on an identical geometry:

unrodded = layouts.core_reflector(core_radius=35.0)
rodded   = layouts.with_rods(unrodded, [(0.0, 0.0)], 5.0, material=2)
rho = (k_rodded - k_unrodded) / (k_rodded * k_unrodded)