neml2.data

Native [Data] objects.

Construction-time inputs shared by reference across consumers (mirrors the C++ [Data] section). CrystalGeometry is the base slip-system geometry; CubicCrystal is the registered [Data] block that specializes it to the cubic crystal system. Importing this package fires the @register_neml2_object side effects.

class neml2.data.CrystalGeometry(*, sym_ops, lattice_vectors, slip_directions, slip_planes)[source]

Bases: Module

Slip-system geometry shared by all CP leaves in a single crystal model.

Constructed once at HIT-load time by the factory; CP slip leaves (ResolvedShear, PlasticDeformationRate, PlasticVorticity) receive it by reference through their from_hit constructors and read $M$ / $W$ / $A$ in their forward pass.

nn.Module is the parent so that assigning a CrystalGeometry to a CP leaf via self._cg = crystal_geometry registers it as a sub-module — leaf.to('cuda') then moves the Schmid / lattice buffers via the standard PyTorch buffer-propagation path. Without this, the buffers stay on CPU and Inductor trips a device-mismatch on the first bmm against a CUDA input during torch.export. Wrapper-typed views ($A$, $M$, $W$, sym_ops, slip_directions, slip_planes) are reconstructed on the fly from the underlying buffers so they always carry the current device.

Buffer attributes

sym_ops_datatorch.Tensor

(nsym, 3, 3) proper-rotation symmetry operators.

lattice_vectorstorch.Tensor

(3, 3) real-space lattice vectors (rows).

reciprocal_lattice_vectorstorch.Tensor

(3, 3) reciprocal-lattice vectors (rows).

cartesian_slip_directions, cartesian_slip_planestorch.Tensor

(nslip, 3) unit-vector representations.

burgerstorch.Tensor

(nslip,) Burgers vector lengths.

A_data, M_data, W_datatorch.Tensor

Raw storage for the wrapper-typed Schmid tensors ((nslip, 3, 3), (nslip, 6), (nslip, 3) respectively).

slip_directions_data, slip_planes_datatorch.Tensor

Raw Miller-index storage.

slip_offsetslist[int]

[0, ..., nslip] group boundaries; the size of group i is slip_offsets[i+1] - slip_offsets[i]. Plain Python list; not a buffer.

Wrapper-typed properties

sym_ops : R2 A : R2 (sub_batch_ndim=1) M : SR2 (sub_batch_ndim=1) W : WR2 (sub_batch_ndim=1) slip_directions, slip_planes : MillerIndex

property A: R2
property M: SR2
property W: WR2
property nslip: int
property nslip_groups: int
nslip_in_group(i)[source]
Parameters:

i (int)

Return type:

int

property slip_directions: MillerIndex
property slip_planes: MillerIndex
property sym_ops: R2
Parameters:
class neml2.data.CubicCrystal[source]

Bases: object

A specialization of the general CrystalGeometry class defining a cubic crystal system.

SECTION = 'Data'
classmethod from_hit(node, factory)[source]
Parameters:
  • node (nmhit.Node)

  • factory (_NativeInputFile)

Return type:

CrystalGeometry

hit = <neml2.schema.HitSchema object>
neml2.data.cubic_symmetry_operators(*, dtype=None, device=None)[source]

Return the 24 cubic (432) proper-rotation symmetry operators as R2.

Shape: (24, 3, 3) with sub_batch_ndim=1 so the leading axis acts as a per-operator sub-batch. Mirrors neml2::crystallography::symmetry("432").

Parameters:
Return type:

R2