jaxdem.utils.load_legacy#
Adapter for loading HDF5 data saved with the pre-merge-2-27-26 branch.
The old format differs from the current one in several ways:
- State field renames:
angVel->ang_vel,clump_ID->clump_id,deformable_ID->bond_id,unique_ID->unique_id.- System changes:
New fields
bonded_force_modelandinteract_same_bond_iddid not exist.- DeformableParticle changes:
Class moved from
jaxdem.forces.deformable_particle:DeformableParticleContainertojaxdem.bonded_forces.deformable_particle:DeformableParticleModel. Fields renamed:elements_ID->elements_id,initial_bending->initial_bendings. Fields removed:edges_ID,element_adjacency_ID,weighted_ref_vectors,directed_edges_source,directed_edges_target,lame_lambda,lame_mu. New field:w_b(bending normalization, computed from reference geometry).
Functions
|
Load an old |
|
Load state, system, and (optionally) a deformable-particle container from old-format h5 files and wire them into a ready-to-use |
|
Load a |
|
Load a |
- jaxdem.utils.load_legacy.load_legacy_dp(path: str, ref_pos: jax.Array | None = None, dim: int = 3) DeformableParticleModel[source]#
Load an old
DeformableParticleContainerh5 file and return a newDeformableParticleModel.- Parameters:
path (str) – Path to the
.h5file containing the saved DP container.ref_pos (jax.Array, optional) – Reference vertex positions, shape
(N, dim). Required for 3D to compute the neww_bbending normalization. You can obtain this from the legacy state:ref_pos = state.pos.dim (int) – Spatial dimension (2 or 3). Needed to choose the correct
w_bcomputation.
- Returns:
A new model instance with fields mapped from the old container.
- Return type:
- jaxdem.utils.load_legacy.load_legacy_simulation(state_path: str, system_path: str, dp_path: str | None = None) tuple[State, System][source]#
Load state, system, and (optionally) a deformable-particle container from old-format h5 files and wire them into a ready-to-use
(State, System)pair.When dp_path is given, the DP model is attached to the system via
system.bonded_force_modeland its force/energy functions are registered in the force manager.- Parameters:
state_path (str) – Path to the legacy State h5 file.
system_path (str) – Path to the legacy System h5 file.
dp_path (str, optional) – Path to the legacy DeformableParticleContainer h5 file.
- Returns:
state (State) – The loaded state with current field names.
system (System) – The loaded system, with bonded forces wired up if dp_path was given.
Example
from jaxdem.utils.load_legacy import load_legacy_simulation state, system = load_legacy_simulation( "old_data/state.h5", "old_data/system.h5", dp_path="old_data/dp.h5", )
- jaxdem.utils.load_legacy.load_legacy_state(path: str) State[source]#
Load a
Statesaved with the old field naming convention (angVel,clump_ID,deformable_ID,unique_ID).- Parameters:
path (str) – Path to the
.h5file containing the saved State.- Returns:
A new State constructed with the current field names.
- Return type:
- jaxdem.utils.load_legacy.load_legacy_system(path: str, state_shape: tuple[int, ...] | None = None) System[source]#
Load a
Systemsaved with the old schema (nobonded_force_modelorinteract_same_bond_idfields).The current
System.createfactory is used to produce a valid skeleton; scalar fields (dt,time,step_count,key) and nested component dataclasses that still exist (collider,domain,force_model,mat_table,force_manager, integrators) are overwritten from the file where the schemas still match.- Parameters:
path (str) – Path to the
.h5file containing the saved System.state_shape (tuple of int, optional) – Shape hint
(N, dim)passed toSystem.createto build default components. If None, inferred from the storedforce_manager/external_forceorforce_manager/external_force_comdataset.
- Returns:
A new System instance populated with as much data from the file as possible.
bonded_force_modeldefaults to None andinteract_same_bond_iddefaults to False.- Return type: