mcdc.Lattice#

class mcdc.Lattice(name: str = '', x: tuple[float, float, int] | None = None, y: tuple[float, float, int] | None = None, z: tuple[float, float, int] | None = None, universes: list[Universe] = [])#

Repeated arrangements of universes in the simulation geometry.

Parameters:
  • name (str, optional) – User-facing lattice name.

  • x (tuple of (float, float, int), optional) – (origin, spacing, number_of_bins) for each finite lattice axis, in cm. An omitted axis is treated as a single unbounded bin.

  • y (tuple of (float, float, int), optional) – (origin, spacing, number_of_bins) for each finite lattice axis, in cm. An omitted axis is treated as a single unbounded bin.

  • z (tuple of (float, float, int), optional) – (origin, spacing, number_of_bins) for each finite lattice axis, in cm. An omitted axis is treated as a single unbounded bin.

  • universes (nested list of Universe, optional) – Universe layout supplied in [z][y][x] order. The y and z axes are reversed internally to match MC/DC’s Cartesian indexing convention.

Notes

A lattice retains the supplied Universe objects. When the owning simulation is compiled, those universes are registered and the packed lattice IDs are rebuilt from their simulation-local IDs.

Examples

Place two universes next to each other along x:

>>> import mcdc
>>> left = mcdc.Universe(name="Left")
>>> right = mcdc.Universe(name="Right")
>>> lattice = mcdc.Lattice(
...     x=(-1.0, 1.0, 2),
...     universes=[[left, right]],
... )

Build a two-dimensional 2-by-2 lattice:

>>> u00 = mcdc.Universe(name="Lower left")
>>> u10 = mcdc.Universe(name="Lower right")
>>> u01 = mcdc.Universe(name="Upper left")
>>> u11 = mcdc.Universe(name="Upper right")
>>> lattice_xy = mcdc.Lattice(
...     x=(-1.0, 1.0, 2),
...     y=(-1.0, 1.0, 2),
...     universes=[
...         [u00, u10],
...         [u01, u11],
...     ],
... )

Place the lattice inside a cell:

>>> lattice_cell = mcdc.Cell(fill=lattice_xy)