jaxdem.materialMatchmaker#
Tooling for mixing materials of the same type. The MaterialMatchmaker defines how to compute the effective material property.
Classes
A MaterialMatchmaker implementation that computes the effective property as the harmonic mean of two properties: |
|
A MaterialMatchmaker implementation that computes the effective property as the arithmetic mean (linear average) of two properties: |
|
Abstract base class for defining how to combine (mix) material properties. |
- class jaxdem.materialMatchmaker.MaterialMatchmaker[source][source]#
Bases:
Factory
[MaterialMatchmaker
],ABC
Abstract base class for defining how to combine (mix) material properties.
Notes
Implementations should be JIT-compilable and work with JAX’s transformation functions.
These matchmakers are used by the
MaterialTable
to pre-compute interaction matrices.
- abstractmethod static get_effective_property(prop1: Array, prop2: Array) Array [source][source]#
Abstract method to compute the effective property value from two individual material properties.
Concrete implementations define the specific mixing rule
- Parameters:
prop1 (jax.Array) – The property value from the first material. Can be a scalar or an array.
prop2 (jax.Array) – The property value from the second material. Can be a scalar or an array.
- Returns:
A JAX array representing the effective property, computed from prop1 and prop2 according to the matchmaker’s specific rule.
- Return type:
jax.Array
- Raises:
NotImplementedError – This is an abstract method and must be implemented by subclasses.
- classmethod create(key: str, /, **kw: Any) T [source]#
Creates and returns an instance of a registered subclass.
This method looks up the subclass associated with the given key in the factory’s registry and then calls its constructor with the provided arguments.
- Parameters:
key (str) – The registration key of the subclass to be created.
**kw (Any) – Arbitrary keyword arguments to be passed directly to the constructor of the registered subclass.
- Returns:
An instance of the registered subclass.
- Return type:
T
- Raises:
KeyError – If the provided key is not found in the factory’s registry.
TypeError – If the provided **kw arguments do not match the signature of the registered subclass’s constructor.
Example
Given Foo factory and Bar registered:
>>> bar_instance = Foo.create("bar", value=42) >>> print(bar_instance) Bar(value=42)
- classmethod register(key: str | None = None) Callable[[Type[T]], Type[T]] [source]#
Registers a subclass with the factory’s registry.
This method returns a decorator that can be applied to a class to register it under a specific key.
- Parameters:
key (str or None, optional) – The string key under which to register the subclass. If None, the lowercase name of the subclass itself will be used as the key.
- Returns:
A decorator function that takes a class and registers it, returning the class unchanged.
- Return type:
Callable[[Type[T]], Type[T]]
- Raises:
ValueError – If the provided key (or the default class name) is already registered in the factory’s registry.
Example
Register a class named “MyComponent” under the key “mycomp”:
>>> @MyFactory.register("mycomp") >>> class MyComponent: >>> ...
Register a class named “DefaultComponent” using its own name as the key:
>>> @MyFactory.register() >>> class DefaultComponent: >>> ...
- class jaxdem.materialMatchmaker.LinearMaterialMatchmaker[source][source]#
Bases:
MaterialMatchmaker
A MaterialMatchmaker implementation that computes the effective property as the arithmetic mean (linear average) of two properties:
\[P_{eff} = \frac{P_1 + P_2}{2}\]where \(P_1\) and \(P_2\) are the property values from the two materials.
- classmethod create(key: str, /, **kw: Any) T [source]#
Creates and returns an instance of a registered subclass.
This method looks up the subclass associated with the given key in the factory’s registry and then calls its constructor with the provided arguments.
- Parameters:
key (str) – The registration key of the subclass to be created.
**kw (Any) – Arbitrary keyword arguments to be passed directly to the constructor of the registered subclass.
- Returns:
An instance of the registered subclass.
- Return type:
T
- Raises:
KeyError – If the provided key is not found in the factory’s registry.
TypeError – If the provided **kw arguments do not match the signature of the registered subclass’s constructor.
Example
Given Foo factory and Bar registered:
>>> bar_instance = Foo.create("bar", value=42) >>> print(bar_instance) Bar(value=42)
- classmethod register(key: str | None = None) Callable[[Type[T]], Type[T]] [source]#
Registers a subclass with the factory’s registry.
This method returns a decorator that can be applied to a class to register it under a specific key.
- Parameters:
key (str or None, optional) – The string key under which to register the subclass. If None, the lowercase name of the subclass itself will be used as the key.
- Returns:
A decorator function that takes a class and registers it, returning the class unchanged.
- Return type:
Callable[[Type[T]], Type[T]]
- Raises:
ValueError – If the provided key (or the default class name) is already registered in the factory’s registry.
Example
Register a class named “MyComponent” under the key “mycomp”:
>>> @MyFactory.register("mycomp") >>> class MyComponent: >>> ...
Register a class named “DefaultComponent” using its own name as the key:
>>> @MyFactory.register() >>> class DefaultComponent: >>> ...
- class jaxdem.materialMatchmaker.HarmonicMaterialMatchmaker[source][source]#
Bases:
MaterialMatchmaker
A MaterialMatchmaker implementation that computes the effective property as the harmonic mean of two properties:
\[P_{eff} = \frac{2}{\frac{1}{P_1} + \frac{1}{P_2}}\]where \(P_1\) and \(P_2\) are the property values from the two materials.
- classmethod create(key: str, /, **kw: Any) T [source]#
Creates and returns an instance of a registered subclass.
This method looks up the subclass associated with the given key in the factory’s registry and then calls its constructor with the provided arguments.
- Parameters:
key (str) – The registration key of the subclass to be created.
**kw (Any) – Arbitrary keyword arguments to be passed directly to the constructor of the registered subclass.
- Returns:
An instance of the registered subclass.
- Return type:
T
- Raises:
KeyError – If the provided key is not found in the factory’s registry.
TypeError – If the provided **kw arguments do not match the signature of the registered subclass’s constructor.
Example
Given Foo factory and Bar registered:
>>> bar_instance = Foo.create("bar", value=42) >>> print(bar_instance) Bar(value=42)
- classmethod register(key: str | None = None) Callable[[Type[T]], Type[T]] [source]#
Registers a subclass with the factory’s registry.
This method returns a decorator that can be applied to a class to register it under a specific key.
- Parameters:
key (str or None, optional) – The string key under which to register the subclass. If None, the lowercase name of the subclass itself will be used as the key.
- Returns:
A decorator function that takes a class and registers it, returning the class unchanged.
- Return type:
Callable[[Type[T]], Type[T]]
- Raises:
ValueError – If the provided key (or the default class name) is already registered in the factory’s registry.
Example
Register a class named “MyComponent” under the key “mycomp”:
>>> @MyFactory.register("mycomp") >>> class MyComponent: >>> ...
Register a class named “DefaultComponent” using its own name as the key:
>>> @MyFactory.register() >>> class DefaultComponent: >>> ...