jaxdem.materials.material_table#
The MaterialTable stores materials in a structure of arrays (SoA). Materials of different types can share a table when the force law supports it.
Classes
|
A container for material properties, organized as Structures of Arrays (SoA) and pre-computed effective pair properties. |
- class jaxdem.materials.material_table.MaterialTable(props: dict[str, Array], pair: dict[str, Array], matcher: MaterialMatchmaker)#
Bases:
objectA container for material properties, organized as Structures of Arrays (SoA) and pre-computed effective pair properties.
The table gives direct access to the scalar properties of each material and to the pre-computed effective properties for material pairs.
Notes:#
Access scalar properties directly with dot notation (e.g., material_table.young).
Access effective pair properties directly with dot notation (e.g., material_table.young_eff).
Example:#
Creating a MaterialTable from multiple material types:
>>> import jax.numpy as jnp >>> import jaxdem as jdem >>> >>> # Define different material instances >>> mat1 = jdem.Material.create("elastic", density=2500.0, young=1.0e4, poisson=0.3) >>> mat2 = jdem.Material.create("elasticfrict", density=7800.0, young=2.0e4, poisson=0.4, mu=0.5, e=1.0) >>> >>> # Create a MaterialTable using a linear matcher >>> matcher_instance = jdem.MaterialMatchmaker.create("linear") >>> mat_table = jdem.MaterialTable.from_materials( >>> [mat1, mat2], >>> matcher=matcher_instance >>> )
- props: dict[str, Array]#
A dictionary mapping scalar material property names (e.g., “young”, “poisson”, “mu”) to JAX arrays. Each array has shape (M,), where M is the total number of distinct material types present in the table.
- pair: dict[str, Array]#
A dictionary mapping effective pair property names (e.g., “young_eff”, “mu_eff”) to JAX arrays. Each array has shape (M, M) and holds the effective property for interactions between any two material types (M_i, M_j).
- matcher: MaterialMatchmaker#
The
jaxdem.MaterialMatchmakerinstance that computed the effective pair properties stored in thepairdictionary.
- static from_materials(mats: Sequence[Material], *, matcher: MaterialMatchmaker | None = None, fill: float = 0.0) MaterialTable[source]#
Construct a
MaterialTablefrom a sequence ofMaterialinstances.- Parameters:
mats (Sequence[Material]) – A sequence of concrete
Materialinstances. Each instance represents a distinct material type in the simulation. The order in this sequence defines their material IDs (0 to len(mats)-1).matcher (MaterialMatchmaker) – The
jaxdem.MaterialMatchmakerinstance used to compute effective pair properties (e.g., harmonic mean, arithmetic mean). If None, defaults to the harmonic matchmaker.fill (float, optional) – Fill value for material properties that a Material subclass does not define. For example, if an
Elasticmaterial appears with anElasticFrictionmaterial, mu takes this value. Defaults to 0.0.
- Returns:
A new MaterialTable instance containing the scalar properties and pre-computed effective pair properties for all provided materials.
- Return type:
- Raises:
TypeError – If mats is not a sequence of Material instances.