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

MaterialTable(props, pair, matcher)

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: object

A 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.MaterialMatchmaker instance that computed the effective pair properties stored in the pair dictionary.

static from_materials(mats: Sequence[Material], *, matcher: MaterialMatchmaker | None = None, fill: float = 0.0) MaterialTable[source]#

Construct a MaterialTable from a sequence of Material instances.

Parameters:
  • mats (Sequence[Material]) – A sequence of concrete Material instances. 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.MaterialMatchmaker instance 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 Elastic material appears with an ElasticFriction material, 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:

MaterialTable

Raises:

TypeError – If mats is not a sequence of Material instances.

property metadata: dict[str, Any][source]#

MaterialTable configuration parameters for serialization and restoration.