neml2.drivers¶
Native [Drivers] registrations.
One file per registered driver type. Importing this package fires the
@register_neml2_object decorators so the factory can resolve [Drivers] blocks
from HIT input.
- class neml2.drivers.TransientDriver(model, prescribed_time, time_name, forces, ics)[source]¶
Bases:
DriverDrive a model over a prescribed time history.
Mirrors C++
TransientDriver. See module docstring for differences.- Parameters:
model (Model)
prescribed_time (Scalar)
time_name (str)
forces (dict[str, TensorWrapper])
ics (dict[str, TensorWrapper])
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- result()[source]¶
Flatten
result_in/result_outinto ainput.<i>.<name>/output.<i>.<name>dict, matching the C++ModuleDictlayout thattorch.jit.load(gold).named_buffers()produces. Typed wrappers are unwrapped to rawtorch.Tensorat this boundary.
- save_gold(path)[source]¶
Serialize
result()to a.ptfile as a flattorch.savedict.The dict carries the same keys as
result():input.<step>.<var>/output.<step>.<var>, each mapping to a detached, clonedtorch.Tensor. Read it back withtorch.load(path, weights_only=True).Replaces the old TorchScript-Module format (a Module-of-Modules with
register_bufferper entry, dumped viatorch.jit.script(...).save(...)). The flat-dict format avoids thetorch.jit.{script,load}deprecation warnings and survives round-trip withweights_only=True(which is safe for plain tensor dicts and prevents arbitrary code execution on load).TransientRegressionreads both formats so existing on-disk goldens from the v2 C++ pipeline keep working — seeTransientRegression.
- class neml2.drivers.TransientRegression(driver, reference, rtol=1e-05, atol=1e-08)[source]¶
Bases:
DriverRun a TransientDriver and diff its result against a gold
.ptfile.- Parameters:
driver (TransientDriver)
reference (Path)
rtol (float)
atol (float)
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶
- class neml2.drivers.Verification(driver, refs, rtol=1e-05, atol=1e-08, time_steps=())[source]¶
Bases:
DriverRun a TransientDriver and diff its result against per-variable references.
- Parameters:
driver (TransientDriver)
refs (dict[str, TensorWrapper])
rtol (float)
atol (float)
- classmethod from_hit(node, factory)[source]¶
- Parameters:
node (nmhit.Node)
factory (_NativeInputFile)
- Return type:
- hit = <neml2.schema.HitSchema object>¶