Version:

salvus.material.elastic.isotropic

salvus.material.elastic.isotropic salvus material elastic isotropic
Isotropic elastic materials.

Classes

BulkAndShearModulus

An elastic material parametrized by its bulk and shear modulus.
SIGNATURE
class BulkAndShearModulus(salvus.material.elastic.isotropic._Isotropic):
    def __init__(
        self,
        KAPPA: _pd.types.ParameterOrConstantT,
        G: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
KAPPA
Type:_pd.types.ParameterOrConstantT
Description:
The bulk modulus in SI units (Pa).
Required
G
Type:_pd.types.ParameterOrConstantT
Description:
The shear modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

BulkAndShearModulus.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
BulkAndShearModulus.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
BulkAndShearModulus.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
BulkAndShearModulus.from_params()
An elastic material parameterized by its bulk and shear moduli.
SIGNATURE
def from_params(
    kappa: _pd.types.ParameterInput,
    g: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
kappa
Type:_pd.types.ParameterInput
Description:
The bulk modulus in SI units (Pa).
Required
g
Type:_pd.types.ParameterInput
Description:
The shear modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
BulkAndShearModulus.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
BulkAndShearModulus.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

BulkAndShearModulus.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
BulkAndShearModulus.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
BulkAndShearModulus.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
BulkAndShearModulus.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
BulkAndShearModulus.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
BulkAndShearModulus.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
BulkAndShearModulus.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
BulkAndShearModulus.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

LameParameters

An elastic material parameterized by lambda and mu.
SIGNATURE
class LameParameters(salvus.material.elastic.isotropic._Isotropic):
    def __init__(
        self,
        LAM: _pd.types.ParameterOrConstantT,
        MU: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
LAM
Type:_pd.types.ParameterOrConstantT
Description:
Lame's first parameter (lambda) in SI units.
Required
MU
Type:_pd.types.ParameterOrConstantT
Description:
Lame's second parameter (mu) in SI units.
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

LameParameters.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
LameParameters.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
LameParameters.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
LameParameters.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    lam: _pd.types.ParameterInput,
    mu: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
lam
Type:_pd.types.ParameterInput
Description:
Lame's first parameter (lambda) in SI units.
Required
mu
Type:_pd.types.ParameterInput
Description:
Lame's second parameter (mu) in SI units.
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
LameParameters.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
LameParameters.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

LameParameters.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
LameParameters.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
LameParameters.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
LameParameters.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
LameParameters.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
LameParameters.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
LameParameters.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
LameParameters.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

ShearModulusAndPoissonsRatio

An elastic material parameterized by its shear modulus and Poisson's ratio.
SIGNATURE
class ShearModulusAndPoissonsRatio(
    salvus.material.elastic.isotropic._Isotropic
):
    def __init__(
        self,
        G: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
        V: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
G
Type:_pd.types.ParameterOrConstantT
Description:
The shear modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.
Required
V
Type:_pd.types.ParameterOrConstantT
Description:
The Poisson's ratio.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

ShearModulusAndPoissonsRatio.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
ShearModulusAndPoissonsRatio.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
ShearModulusAndPoissonsRatio.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
ShearModulusAndPoissonsRatio.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    g: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
    v: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
g
Type:_pd.types.ParameterInput
Description:
The shear modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
Required
v
Type:_pd.types.ParameterInput
Description:
The Poisson's ratio.
ShearModulusAndPoissonsRatio.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
ShearModulusAndPoissonsRatio.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

ShearModulusAndPoissonsRatio.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
ShearModulusAndPoissonsRatio.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
ShearModulusAndPoissonsRatio.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
ShearModulusAndPoissonsRatio.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
ShearModulusAndPoissonsRatio.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
ShearModulusAndPoissonsRatio.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
ShearModulusAndPoissonsRatio.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
ShearModulusAndPoissonsRatio.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

ShearModulusAndPoissonsRatio2D

A 2-D elastic material parameterized by its shear modulus and Poisson's ratio.
SIGNATURE
class ShearModulusAndPoissonsRatio2D(
    salvus.material.elastic.isotropic._Isotropic
):
    def __init__(
        self,
        G: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
        V_2D: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
G
Type:_pd.types.ParameterOrConstantT
Description:
The shear modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.
Required
V_2D
Type:_pd.types.ParameterOrConstantT
Description:
The 2-D Poisson's ratio.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

ShearModulusAndPoissonsRatio2D.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
ShearModulusAndPoissonsRatio2D.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
ShearModulusAndPoissonsRatio2D.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
ShearModulusAndPoissonsRatio2D.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    g: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
    v_2d: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
g
Type:_pd.types.ParameterInput
Description:
The 2-D shear modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
Required
v_2d
Type:_pd.types.ParameterInput
Description:
The 2-D Poisson's ratio.
ShearModulusAndPoissonsRatio2D.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
ShearModulusAndPoissonsRatio2D.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

ShearModulusAndPoissonsRatio2D.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
ShearModulusAndPoissonsRatio2D.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
ShearModulusAndPoissonsRatio2D.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
ShearModulusAndPoissonsRatio2D.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
ShearModulusAndPoissonsRatio2D.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
ShearModulusAndPoissonsRatio2D.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
ShearModulusAndPoissonsRatio2D.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
ShearModulusAndPoissonsRatio2D.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

TensorComponents

Isotropic elastic material parametrized by elastic constants.
SIGNATURE
class TensorComponents(
    salvus.material.elastic.isotropic._Isotropic,
    salvus.material.elastic.ElasticTensorComponents,
):
    def __init__(
        self,
        RHO: _pd.types.ParameterOrConstantT,
        C11: _pd.types.ParameterOrConstantT,
        C12: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
The density in kg / m^3.
Required
C11
Type:_pd.types.ParameterOrConstantT
Description:
The c_11 component of the stiffness tensor in Pa.
Required
C12
Type:_pd.types.ParameterOrConstantT
Description:
The c_12 component of the stiffness tensor in Pa.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • halfC11minC12(_pd.types.ParameterFlavorT)-Material property that might be accessed in checking symmetry.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

TensorComponents.all_components()
Get all components.
SIGNATURE
def all_components() -> list[str]: ...
TensorComponents.equal_components()
Get equal components for a material class.
SIGNATURE
def equal_components() -> dict[str, str]: ...
TensorComponents.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
TensorComponents.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
TensorComponents.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
TensorComponents.from_params()
Construct an isotropic material from elastic constants.
SIGNATURE
def from_params(
    rho: _pd.types.ParameterInput,
    c11: _pd.types.ParameterInput,
    c12: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
rho
Type:_pd.types.ParameterInput
Description:
The density in kg / m^3.
Required
c11
Type:_pd.types.ParameterInput
Description:
The c_11 component of the stiffness tensor in Pa.
Required
c12
Type:_pd.types.ParameterInput
Description:
The c_12 component of the stiffness tensor in Pa.
TensorComponents.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
TensorComponents.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...
TensorComponents.nonzero_components()
Get nonzero components for a material class.
SIGNATURE
def nonzero_components() -> list[str]: ...
TensorComponents.zero_components()
Get zero components for a material class.
SIGNATURE
def zero_components() -> list[str]: ...

Methods

TensorComponents.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
TensorComponents.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
TensorComponents.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
TensorComponents.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
TensorComponents.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
TensorComponents.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
TensorComponents.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
TensorComponents.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

Velocity

An elastic material parameterized by density and p- and s-wave velocity.
SIGNATURE
class Velocity(salvus.material.elastic.isotropic._Isotropic):
    def __init__(
        self,
        RHO: _pd.types.ParameterOrConstantT,
        VP: _pd.types.ParameterOrConstantT,
        VS: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.
Required
VP
Type:_pd.types.ParameterOrConstantT
Description:
P-wave velocity in m / s.
Required
VS
Type:_pd.types.ParameterOrConstantT
Description:
S-wave velocity in m / s.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

Velocity.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
Velocity.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
Velocity.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
Velocity.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    rho: _pd.types.ParameterInput,
    vp: _pd.types.ParameterInput,
    vs: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
Required
vp
Type:_pd.types.ParameterInput
Description:
P-wave velocity in m / s.
Required
vs
Type:_pd.types.ParameterInput
Description:
S-wave velocity in m / s.
Velocity.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
Velocity.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

Velocity.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
Velocity.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
Velocity.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
Velocity.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
Velocity.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
Velocity.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
Velocity.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
Velocity.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

YoungsAndShearModulus

An elastic material parameterized by its Young's and shear moduli.
SIGNATURE
class YoungsAndShearModulus(salvus.material.elastic.isotropic._Isotropic):
    def __init__(
        self,
        E: _pd.types.ParameterOrConstantT,
        G: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
E
Type:_pd.types.ParameterOrConstantT
Description:
The Young's modulus in SI units (Pa).
Required
G
Type:_pd.types.ParameterOrConstantT
Description:
The shear modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

YoungsAndShearModulus.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
YoungsAndShearModulus.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
YoungsAndShearModulus.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsAndShearModulus.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    e: _pd.types.ParameterInput,
    g: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
e
Type:_pd.types.ParameterInput
Description:
The Young's modulus in SI units (Pa).
Required
g
Type:_pd.types.ParameterInput
Description:
The shear modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
YoungsAndShearModulus.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsAndShearModulus.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

YoungsAndShearModulus.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
YoungsAndShearModulus.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
YoungsAndShearModulus.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
YoungsAndShearModulus.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
YoungsAndShearModulus.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
YoungsAndShearModulus.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
YoungsAndShearModulus.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
YoungsAndShearModulus.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

YoungsAndShearModulus2D

A 2-D elastic material parameterized by its Young's and shear moduli.
SIGNATURE
class YoungsAndShearModulus2D(salvus.material.elastic.isotropic._Isotropic):
    def __init__(
        self,
        E_2D: _pd.types.ParameterOrConstantT,
        G: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
E_2D
Type:_pd.types.ParameterOrConstantT
Description:
The 2-D Young's modulus in SI units (Pa).
Required
G
Type:_pd.types.ParameterOrConstantT
Description:
The shear modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

YoungsAndShearModulus2D.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
YoungsAndShearModulus2D.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
YoungsAndShearModulus2D.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsAndShearModulus2D.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    e_2d: _pd.types.ParameterInput,
    g: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
e_2d
Type:_pd.types.ParameterInput
Description:
The 2-D Young's modulus in SI units (Pa).
Required
g
Type:_pd.types.ParameterInput
Description:
The shear modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
YoungsAndShearModulus2D.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsAndShearModulus2D.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

YoungsAndShearModulus2D.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
YoungsAndShearModulus2D.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
YoungsAndShearModulus2D.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
YoungsAndShearModulus2D.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
YoungsAndShearModulus2D.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
YoungsAndShearModulus2D.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
YoungsAndShearModulus2D.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
YoungsAndShearModulus2D.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

YoungsModulusAndPoissonsRatio

An elastic material parameterized by its Young's modulus and Poisson's ratio.
SIGNATURE
class YoungsModulusAndPoissonsRatio(
    salvus.material.elastic.isotropic._Isotropic
):
    def __init__(
        self,
        E: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
        V: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
E
Type:_pd.types.ParameterOrConstantT
Description:
The Young's modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.
Required
V
Type:_pd.types.ParameterOrConstantT
Description:
The Poisson's ratio.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

YoungsModulusAndPoissonsRatio.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
YoungsModulusAndPoissonsRatio.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
YoungsModulusAndPoissonsRatio.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsModulusAndPoissonsRatio.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    e: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
    v: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
e
Type:_pd.types.ParameterInput
Description:
The Young's modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
Required
v
Type:_pd.types.ParameterInput
Description:
The Poisson's ratio.
YoungsModulusAndPoissonsRatio.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsModulusAndPoissonsRatio.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

YoungsModulusAndPoissonsRatio.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
YoungsModulusAndPoissonsRatio.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
YoungsModulusAndPoissonsRatio.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
YoungsModulusAndPoissonsRatio.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
YoungsModulusAndPoissonsRatio.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
YoungsModulusAndPoissonsRatio.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
YoungsModulusAndPoissonsRatio.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
YoungsModulusAndPoissonsRatio.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.

YoungsModulusAndPoissonsRatio2D

A 2-D elastic material parameterized by its Young's modulus and Poisson's ratio.
SIGNATURE
class YoungsModulusAndPoissonsRatio2D(
    salvus.material.elastic.isotropic._Isotropic
):
    def __init__(
        self,
        E_2D: _pd.types.ParameterOrConstantT,
        RHO: _pd.types.ParameterOrConstantT,
        V_2D: _pd.types.ParameterOrConstantT,
    ) -> None: ...
ARGUMENTS
Required
E_2D
Type:_pd.types.ParameterOrConstantT
Description:
The 2-D Young's modulus in SI units (Pa).
Required
RHO
Type:_pd.types.ParameterOrConstantT
Description:
Density in kg / m^3.
Required
V_2D
Type:_pd.types.ParameterOrConstantT
Description:
The 2-D Poisson's ratio.

Properties

  • ds(typing.Mapping)-Material's xarray representation.
  • flatten(dict)-Get all parameters as a dict.
  • viscosity(Material | None)-Get the optional attenuation.

Class Methods

YoungsModulusAndPoissonsRatio2D.from_dataset()
Construct a material from an xarray Dataset.
SIGNATURE
def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
ds
Type:xr.Dataset
Description:
The dataset to construct the material from.
YoungsModulusAndPoissonsRatio2D.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.
YoungsModulusAndPoissonsRatio2D.from_material()
Construct this material from another within the same physical system.
SIGNATURE
def from_material(
    m: Material[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> PhysicalMaterial[_pd.types.ParameterFlavorT]: ...
ARGUMENTS
Required
m
Type:Material[_pd.types.ParameterFlavorT]
Description:
Material to transform.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsModulusAndPoissonsRatio2D.from_params()
Construct this material from generic parameters.
SIGNATURE
def from_params(
    e_2d: _pd.types.ParameterInput,
    rho: _pd.types.ParameterInput,
    v_2d: _pd.types.ParameterInput,
) -> typing.Self: ...
ARGUMENTS
Required
e_2d
Type:_pd.types.ParameterInput
Description:
The 2-D Young's modulus in SI units (Pa).
Required
rho
Type:_pd.types.ParameterInput
Description:
Density in kg / m^3.
Required
v_2d
Type:_pd.types.ParameterInput
Description:
The 2-D Poisson's ratio.
YoungsModulusAndPoissonsRatio2D.from_tensor_components()
Create material from tensor components acoustic parameter material.
Overwrite this method if your material can not be constructed from acoustic constants.
A class method to create a anisotropic material of a desired symmetry class from a canonical TC material. The method will automatically check if the canonical material that is passed meets the symmetry requirements of the desired materials. If it does not, a TypeError will be raised.
SIGNATURE
def from_tensor_components(
    m: GenericTensorComponents[_pd.types.ParameterFlavorT],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> typing.Self: ...
ARGUMENTS
Required
m
Type:GenericTensorComponents[_pd.types.ParameterFlavorT]
Description:
The material in tensor components parametrization to be used to construct the new material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
YoungsModulusAndPoissonsRatio2D.material_system()
Get the material system of the material.
SIGNATURE
def material_system() -> type[PhysicalMaterial]: ...

Methods

YoungsModulusAndPoissonsRatio2D.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
YoungsModulusAndPoissonsRatio2D.map_realized_parameters()
Apply functions to each parameter individually, distinguishing _pd.
Useful when one wants to transform each parameter type separately. For instance, transformations of discrete parameters often require more associated logic than their constant equivalents. This function abstracts away the boilerplate of check for each parameter type, and subsequently transforming it with some function, as well as ensuring that the parameters are indeed of the correct realized type.
The signatures of each transformation function should take the parameter's name and value as two distinct inputs, and return the (potentially modified) parameter value.
SIGNATURE
def map_realized_parameters(
    self,
    f_constant: typing.Callable[
        [str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_discrete: typing.Callable[
        [str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter
    ] = salvus.material.base_materials._map_realized_default,
    f_analytic: typing.Callable[
        [str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter
    ] = salvus.material.base_materials._map_realized_default,
) -> Self: ...
ARGUMENTS
Optional
f_constant
Type:typing.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to constant parameters. Defaults to returning the parameter as-is.
Optional
f_discrete
Type:typing.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to discrete parameters. Defaults to returning the parameter as-is.
Optional
f_analytic
Type:typing.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter]
Default value:salvus.material.base_materials._map_realized_default
Description:
The function to apply to analytic parameters. Defaults to returning the parameter as-is.
YoungsModulusAndPoissonsRatio2D.qc_test()
Run a series of material quality control tests.
The function also prints a summary of the issues found, including their severity and any mitigation steps that can be taken.
SIGNATURE
def qc_test(
    self,
    level: validation.QCLevel | str = QCLevel.strict,
    display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...
ARGUMENTS
Optional
level
Type:validation.QCLevel | str
Default value:QCLevel.strict
Description:
The level of quality control to perform. The BASIC level performs minimal checks, while the STRICT level performs more thorough checks that are potentially slow. One can pass an enumeration value or a string representation of the level.
Optional
display_issues
Type:bool
Default value:True
Description:
If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
YoungsModulusAndPoissonsRatio2D.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
YoungsModulusAndPoissonsRatio2D.to_tensor_components()
Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
SIGNATURE
def to_tensor_components(
    self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...
ARGUMENTS
Optional
expand_symmetries
Type:bool
Default value:False
Description:
boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
YoungsModulusAndPoissonsRatio2D.to_wavelength_oracle()
The wavelength oracle.
SIGNATURE
def to_wavelength_oracle(
    self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...
ARGUMENTS
Optional
n_dim
Type:typing.Literal[2, 3] | None
Default value:None
Description:
Dimension to return the oracle for, deprecated.
YoungsModulusAndPoissonsRatio2D.with_attenuation()
Add attenuation to an object.
SIGNATURE
def with_attenuation(self, attenuation: Material | None) -> Self: ...
ARGUMENTS
Required
attenuation
Type:Material | None
Description:
The attenuation material.
YoungsModulusAndPoissonsRatio2D.with_orientation()
Experimetal method to add orientation to a material.
SIGNATURE
def with_orientation(self, orientation: Material | None) -> Material: ...
ARGUMENTS
Required
orientation
Type:Material | None
Description:
The orientation.
PAGE CONTENTS