salvus.material.elastic.hexagonal
salvus.material.elastic.hexagonal salvus material elastic hexagonal Hexagonal (VTI) anisotropic elastic materials.
Classes
EngineeringConstants
EngineeringConstantsclass EngineeringConstants(salvus.material.elastic.hexagonal._Hexagonal):
def __init__(
self,
RHO: _pd.types.ParameterOrConstantT,
E1: _pd.types.ParameterOrConstantT,
E3: _pd.types.ParameterOrConstantT,
G13: _pd.types.ParameterOrConstantT,
V12: _pd.types.ParameterOrConstantT,
V13: _pd.types.ParameterOrConstantT,
) -> None: ...An hexagonal material parametrized with engineering constants.
An hexagonal material has two planes of symmetry and therefore 6 independent parameters plus the density.
The shear moduli here are assumed to be in the engineering convention: twice the normal shear moduli.
The following equalities hold compared to the full orthotropic case:
E2 = E1V32 = V31V23 = V13V31 / E3 = V13 / E1V21 = V12G21 = E2 / (2 * (1 + V21))
The normal and reverse Poisson’s ratios are also named the major and minor
Poisson’s ratio, depending on which has the larger magnitude. However, this
material always defines it by first and second axes, i.e. v12 and v13.
This material is rotationally symmetric around its vertical, the dimensions described in these constants by the index 3. This means that:
- the Young’s modulus in the 1 and 2 dimensions are equal.
- The two Poisson’s ratio between the third and the two other dimensions are equal, as are their reverse Poisson’s ratio.
- The Poisson’s ratio between dimension 1 and dimension 2 is the same as its reverse.
RHO_pd.types.ParameterOrConstantT — The density in kg / m^3.E1_pd.types.ParameterOrConstantT — Young’s modulus in Pa.E3_pd.types.ParameterOrConstantT — Young’s modulus in Pa.G13_pd.types.ParameterOrConstantT — Shear modulus in Pa, engineering convention.V12_pd.types.ParameterOrConstantT — Poisson’s ratio.V13_pd.types.ParameterOrConstantT — Poisson’s ratio.
ds typing.Mapping
ds typing.MappingMaterial’s xarray representation.
flatten dict
flatten dictGet all parameters as a dict.
viscosity Material | None
viscosity Material | NoneGet the optional attenuation.
from_dataset()
from_dataset()def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...Construct a material from an xarray Dataset.
dsxr.Dataset — The dataset to construct the material from.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
from_material()
from_material()def from_material(
m: Material,
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> _Hexagonal: ...Construct this material from another within the same physical system.
mMaterial — Material to transform.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
from_params()
from_params()def from_params(
rho: _pd.types.ParameterInput,
e1: _pd.types.ParameterInput,
e3: _pd.types.ParameterInput,
g13: _pd.types.ParameterInput,
v12: _pd.types.ParameterInput,
v13: _pd.types.ParameterInput,
) -> typing.Self: ...Construct an hexagonal material from its engineering constants.
The shear moduli here are assumed to be in the engineering convention: twice the normal shear moduli.
rho_pd.types.ParameterInput — The density in kg / m^3.e1_pd.types.ParameterInput — Young’s modulus in Pa.e3_pd.types.ParameterInput — Young’s modulus in Pa.g13_pd.types.ParameterInput — Shear modulus in Pa, engineering convention.v12_pd.types.ParameterInput — Poisson’s ratio.v13_pd.types.ParameterInput — Poisson’s ratio.
from_tensor_components()
from_tensor_components()def from_tensor_components(
m: GenericTensorComponents[_pd.types.ParameterFlavorT],
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> typing.Self: ...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.
mGenericTensorComponents[_pd.types.ParameterFlavorT] — The material in tensor components parametrization to be used to construct the new material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
material_system()
material_system()def material_system() -> type[PhysicalMaterial]: ...Get the material system of the material.
map()
map()def map(
self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...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.
ftyping.Callable[[str, typing.Any], tuple[str, typing.Any]] — The function to map over the dataclass.
map_realized_parameters()
map_realized_parameters()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: ...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.
f_constanttyping.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter] — The function to apply to constant parameters. Defaults to returning the parameter as-is.f_discretetyping.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter] — The function to apply to discrete parameters. Defaults to returning the parameter as-is.f_analytictyping.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter] — The function to apply to analytic parameters. Defaults to returning the parameter as-is.
qc_test()
qc_test()def qc_test(
self,
level: validation.QCLevel | str = QCLevel.strict,
display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...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.
levelvalidation.QCLevel | str — 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.display_issuesbool — If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
type is the type of the issue (e.g, “mesh” or “material”) and code is a specific code for the issue (e.g., “NON_POSITIVE_VP”). If no issues are found, an empty dictionary is returned.to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
to_tensor_components()
to_tensor_components()def to_tensor_components(
self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
expand_symmetriesbool — boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
to_wavelength_oracle()
to_wavelength_oracle()def to_wavelength_oracle(
self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...The wavelength oracle.
n_dimtyping.Literal[2, 3] | None — Dimension to return the oracle for, deprecated.
with_attenuation()
with_attenuation()def with_attenuation(self, attenuation: Material | None) -> Self: ...Add attenuation to an object.
attenuationMaterial | None — The attenuation material.
with_orientation()
with_orientation()def with_orientation(self, orientation: Material | None) -> Material: ...Experimental way to add orientation to a material.
orientationMaterial | None — The orientation.
TensorComponents
TensorComponentsclass TensorComponents(
salvus.material.elastic.hexagonal._Hexagonal,
salvus.material.elastic.ElasticTensorComponents,
):
def __init__(
self,
RHO: _pd.types.ParameterOrConstantT,
C11: _pd.types.ParameterOrConstantT,
C12: _pd.types.ParameterOrConstantT,
C13: _pd.types.ParameterOrConstantT,
C33: _pd.types.ParameterOrConstantT,
C44: _pd.types.ParameterOrConstantT,
) -> None: ...Hexagonal anisotropic elastic material parametrized by elastic constants.
RHO_pd.types.ParameterOrConstantT — The density in kg / m^3.C11_pd.types.ParameterOrConstantT — The c_11 component of the stiffness tensor in Pa.C12_pd.types.ParameterOrConstantT — The c_12 component of the stiffness tensor in Pa.C13_pd.types.ParameterOrConstantT — The c_13 component of the stiffness tensor in Pa.C33_pd.types.ParameterOrConstantT — The c_33 component of the stiffness tensor in Pa.C44_pd.types.ParameterOrConstantT — The c_44 component of the stiffness tensor in Pa.
ds typing.Mapping
ds typing.MappingMaterial’s xarray representation.
flatten dict
flatten dictGet all parameters as a dict.
halfC11minC12 _pd.types.ParameterFlavorT
halfC11minC12 _pd.types.ParameterFlavorTMaterial property that might be accessed in checking symmetry.
viscosity Material | None
viscosity Material | NoneGet the optional attenuation.
all_components()
all_components()def all_components() -> list[str]: ...Get all components.
equal_components()
equal_components()def equal_components() -> dict[str, str]: ...Get equal components for a material class.
from_dataset()
from_dataset()def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...Construct a material from an xarray Dataset.
dsxr.Dataset — The dataset to construct the material from.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
from_material()
from_material()def from_material(
m: Material,
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> _Hexagonal: ...Construct this material from another within the same physical system.
mMaterial — Material to transform.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
from_params()
from_params()def from_params(
rho: _pd.types.ParameterInput,
c11: _pd.types.ParameterInput,
c12: _pd.types.ParameterInput,
c13: _pd.types.ParameterInput,
c33: _pd.types.ParameterInput,
c44: _pd.types.ParameterInput,
) -> typing.Self: ...Construct a hexagonal material from elastic constants.
rho_pd.types.ParameterInput — The density in kg / m^3.c11_pd.types.ParameterInput — The c_11 component of the stiffness tensor in Pa.c12_pd.types.ParameterInput — The c_12 component of the stiffness tensor in Pa.c13_pd.types.ParameterInput — The c_13 component of the stiffness tensor in Pa.c33_pd.types.ParameterInput — The c_33 component of the stiffness tensor in Pa.c44_pd.types.ParameterInput — The c_44 component of the stiffness tensor in Pa.
from_tensor_components()
from_tensor_components()def from_tensor_components(
m: GenericTensorComponents[_pd.types.ParameterFlavorT],
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> Self: ...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.
mGenericTensorComponents[_pd.types.ParameterFlavorT] — The material in tensor components parametrization to be used to construct the new material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
material_system()
material_system()def material_system() -> type[PhysicalMaterial]: ...Get the material system of the material.
nonzero_components()
nonzero_components()def nonzero_components() -> list[str]: ...Get nonzero components for a material class.
zero_components()
zero_components()def zero_components() -> list[str]: ...Get zero components for a material class.
map()
map()def map(
self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...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.
ftyping.Callable[[str, typing.Any], tuple[str, typing.Any]] — The function to map over the dataclass.
map_realized_parameters()
map_realized_parameters()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: ...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.
f_constanttyping.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter] — The function to apply to constant parameters. Defaults to returning the parameter as-is.f_discretetyping.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter] — The function to apply to discrete parameters. Defaults to returning the parameter as-is.f_analytictyping.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter] — The function to apply to analytic parameters. Defaults to returning the parameter as-is.
qc_test()
qc_test()def qc_test(
self,
level: validation.QCLevel | str = QCLevel.strict,
display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...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.
levelvalidation.QCLevel | str — 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.display_issuesbool — If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
type is the type of the issue (e.g, “mesh” or “material”) and code is a specific code for the issue (e.g., “NON_POSITIVE_VP”). If no issues are found, an empty dictionary is returned.to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
to_tensor_components()
to_tensor_components()def to_tensor_components(
self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
expand_symmetriesbool — boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
to_wavelength_oracle()
to_wavelength_oracle()def to_wavelength_oracle(
self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...The wavelength oracle.
n_dimtyping.Literal[2, 3] | None — Dimension to return the oracle for, deprecated.
with_attenuation()
with_attenuation()def with_attenuation(self, attenuation: Material | None) -> Self: ...Add attenuation to an object.
attenuationMaterial | None — The attenuation material.
with_orientation()
with_orientation()def with_orientation(self, orientation: Material | None) -> Material: ...Experimental way to add orientation to a material.
orientationMaterial | None — The orientation.
Thomsen
Thomsenclass Thomsen(salvus.material.elastic.hexagonal._Hexagonal):
def __init__(
self,
RHO: _pd.types.ParameterOrConstantT,
VP: _pd.types.ParameterOrConstantT,
VS: _pd.types.ParameterOrConstantT,
DELTA: _pd.types.ParameterOrConstantT,
GAMMA: _pd.types.ParameterOrConstantT,
EPSILON: _pd.types.ParameterOrConstantT,
) -> None: ...Anisotropic elastic materials specified using Thomsen’s parameters, with hexagonal symmetry.
VP and VS are defined along the materials symmetry axis (the vertical).
RHO_pd.types.ParameterOrConstantT — Density in kg / m^3.VP_pd.types.ParameterOrConstantT — P-wave velocity in m / s along the symmetry axis.VS_pd.types.ParameterOrConstantT — S-wave velocity in m / s along the symmetry axis.DELTA_pd.types.ParameterOrConstantT — Thomsen’s delta parameter (dimensionless).GAMMA_pd.types.ParameterOrConstantT — Thomsen’s gamma parameter (dimensionless).EPSILON_pd.types.ParameterOrConstantT — Thomsen’s epsilon parameter (dimensionless).
ds typing.Mapping
ds typing.MappingMaterial’s xarray representation.
flatten dict
flatten dictGet all parameters as a dict.
viscosity Material | None
viscosity Material | NoneGet the optional attenuation.
from_acoustic()
from_acoustic()def from_acoustic(
acoustic_thomsen: AThomsen[_pd.types.ParameterFlavorT],
vp_vs: _pd.types.ParameterInput,
gamma: _pd.types.ParameterInput,
qmu: _pd.types.ParameterInput | None = None,
) -> typing.Self: ...Create this material from the elastic constants parametrization.
acoustic_thomsenAThomsen[_pd.types.ParameterFlavorT] — The material to create this material from.vp_vs_pd.types.ParameterInput — Ratio between vp and vs speeds.gamma_pd.types.ParameterInput — the anisotropy parameter for shear wave speed.qmu_pd.types.ParameterInput | None — Qmu.
from_dataset()
from_dataset()def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...Construct a material from an xarray Dataset.
dsxr.Dataset — The dataset to construct the material from.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
from_material()
from_material()def from_material(
m: Material,
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> _Hexagonal: ...Construct this material from another within the same physical system.
mMaterial — Material to transform.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
from_params()
from_params()def from_params(
rho: _pd.types.ParameterInput,
vp: _pd.types.ParameterInput,
vs: _pd.types.ParameterInput,
delta: _pd.types.ParameterInput,
gamma: _pd.types.ParameterInput,
epsilon: _pd.types.ParameterInput,
) -> typing.Self: ...Construct this material from generic parameters.
rho_pd.types.ParameterInput — Density in kg / m^3.vp_pd.types.ParameterInput — P-wave velocity in m / s.vs_pd.types.ParameterInput — S-wave velocity in m / s.delta_pd.types.ParameterInput — Thomsen’s delta parameter (dimensionless).gamma_pd.types.ParameterInput — Thomsen’s gamma parameter (dimensionless).epsilon_pd.types.ParameterInput — Thomsen’s epsilon parameter (dimensionless).
from_tensor_components()
from_tensor_components()def from_tensor_components(
m: GenericTensorComponents[_pd.types.ParameterFlavorT],
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> typing.Self: ...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.
mGenericTensorComponents[_pd.types.ParameterFlavorT] — The material in tensor components parametrization to be used to construct the new material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
material_system()
material_system()def material_system() -> type[PhysicalMaterial]: ...Get the material system of the material.
map()
map()def map(
self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...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.
ftyping.Callable[[str, typing.Any], tuple[str, typing.Any]] — The function to map over the dataclass.
map_realized_parameters()
map_realized_parameters()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: ...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.
f_constanttyping.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter] — The function to apply to constant parameters. Defaults to returning the parameter as-is.f_discretetyping.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter] — The function to apply to discrete parameters. Defaults to returning the parameter as-is.f_analytictyping.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter] — The function to apply to analytic parameters. Defaults to returning the parameter as-is.
qc_test()
qc_test()def qc_test(
self,
level: validation.QCLevel | str = QCLevel.strict,
display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...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.
levelvalidation.QCLevel | str — 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.display_issuesbool — If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
type is the type of the issue (e.g, “mesh” or “material”) and code is a specific code for the issue (e.g., “NON_POSITIVE_VP”). If no issues are found, an empty dictionary is returned.to_acoustic()
to_acoustic()def to_acoustic(self) -> AThomsen[_pd.types.ParameterFlavorT]: ...Create acoustic variant of this material from the elastic.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
to_tensor_components()
to_tensor_components()def to_tensor_components(
self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
expand_symmetriesbool — boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
to_wavelength_oracle()
to_wavelength_oracle()def to_wavelength_oracle(
self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...The wavelength oracle.
n_dimtyping.Literal[2, 3] | None — Dimension to return the oracle for, deprecated.
with_attenuation()
with_attenuation()def with_attenuation(self, attenuation: Material | None) -> Self: ...Add attenuation to an object.
attenuationMaterial | None — The attenuation material.
with_orientation()
with_orientation()def with_orientation(self, orientation: Material | None) -> Material: ...Experimental way to add orientation to a material.
orientationMaterial | None — The orientation.
Thomsen2D
Thomsen2Dclass Thomsen2D(salvus.material.elastic.hexagonal._Hexagonal):
def __init__(
self,
RHO: _pd.types.ParameterOrConstantT,
VP: _pd.types.ParameterOrConstantT,
VS: _pd.types.ParameterOrConstantT,
DELTA: _pd.types.ParameterOrConstantT,
EPSILON: _pd.types.ParameterOrConstantT,
) -> None: ...Anisotropic elastic 2D in-plane material specified using Thomsen’s parameters.
Five-parameter set: {RHO, VP, VS, DELTA, EPSILON}. GAMMA — the V_SH/V_SV shear-anisotropy parameter — is dropped because the 2D in-plane elastic system has only one shear mode. The wavefront’s diamond-ness along the symmetry axis is therefore fixed and γ has no degree of freedom to tune.
VP and VS are defined along the material’s symmetry axis (the vertical).
RHO_pd.types.ParameterOrConstantT — Density in kg / m^3.VP_pd.types.ParameterOrConstantT — P-wave velocity in m / s along the symmetry axis.VS_pd.types.ParameterOrConstantT — S-wave velocity in m / s along the symmetry axis.DELTA_pd.types.ParameterOrConstantT — Thomsen’s delta parameter (dimensionless).EPSILON_pd.types.ParameterOrConstantT — Thomsen’s epsilon parameter (dimensionless).
ds typing.Mapping
ds typing.MappingMaterial’s xarray representation.
flatten dict
flatten dictGet all parameters as a dict.
viscosity Material | None
viscosity Material | NoneGet the optional attenuation.
from_dataset()
from_dataset()def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...Construct a material from an xarray Dataset.
dsxr.Dataset — The dataset to construct the material from.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
from_material()
from_material()def from_material(
m: Material,
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> _Hexagonal: ...Construct this material from another within the same physical system.
mMaterial — Material to transform.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
from_params()
from_params()def from_params(
rho: _pd.types.ParameterInput,
vp: _pd.types.ParameterInput,
vs: _pd.types.ParameterInput,
delta: _pd.types.ParameterInput,
epsilon: _pd.types.ParameterInput,
) -> typing.Self: ...Construct this material from generic parameters.
rho_pd.types.ParameterInput — Density in kg / m^3.vp_pd.types.ParameterInput — P-wave velocity in m / s.vs_pd.types.ParameterInput — S-wave velocity in m / s.delta_pd.types.ParameterInput — Thomsen’s delta parameter (dimensionless).epsilon_pd.types.ParameterInput — Thomsen’s epsilon parameter (dimensionless).
from_tensor_components()
from_tensor_components()def from_tensor_components(
m: GenericTensorComponents[_pd.types.ParameterFlavorT],
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> typing.Self: ...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.
mGenericTensorComponents[_pd.types.ParameterFlavorT] — The material in tensor components parametrization to be used to construct the new material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
material_system()
material_system()def material_system() -> type[PhysicalMaterial]: ...Get the material system of the material.
map()
map()def map(
self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...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.
ftyping.Callable[[str, typing.Any], tuple[str, typing.Any]] — The function to map over the dataclass.
map_realized_parameters()
map_realized_parameters()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: ...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.
f_constanttyping.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter] — The function to apply to constant parameters. Defaults to returning the parameter as-is.f_discretetyping.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter] — The function to apply to discrete parameters. Defaults to returning the parameter as-is.f_analytictyping.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter] — The function to apply to analytic parameters. Defaults to returning the parameter as-is.
qc_test()
qc_test()def qc_test(
self,
level: validation.QCLevel | str = QCLevel.strict,
display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...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.
levelvalidation.QCLevel | str — 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.display_issuesbool — If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
type is the type of the issue (e.g, “mesh” or “material”) and code is a specific code for the issue (e.g., “NON_POSITIVE_VP”). If no issues are found, an empty dictionary is returned.to_acoustic()
to_acoustic()def to_acoustic(self) -> AThomsen[_pd.types.ParameterFlavorT]: ...Create acoustic variant of this material from the elastic.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
to_tensor_components()
to_tensor_components()def to_tensor_components(
self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
expand_symmetriesbool — boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
to_wavelength_oracle()
to_wavelength_oracle()def to_wavelength_oracle(
self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...The wavelength oracle.
n_dimtyping.Literal[2, 3] | None — Dimension to return the oracle for, deprecated.
with_attenuation()
with_attenuation()def with_attenuation(self, attenuation: Material | None) -> Self: ...Add attenuation to an object.
attenuationMaterial | None — The attenuation material.
with_orientation()
with_orientation()def with_orientation(self, orientation: Material | None) -> Material: ...Experimental way to add orientation to a material.
orientationMaterial | None — The orientation.
Velocity
Velocityclass Velocity(salvus.material.elastic.hexagonal._Hexagonal):
def __init__(
self,
RHO: _pd.types.ParameterOrConstantT,
VPH: _pd.types.ParameterOrConstantT,
VPV: _pd.types.ParameterOrConstantT,
VSH: _pd.types.ParameterOrConstantT,
VSV: _pd.types.ParameterOrConstantT,
ETA: _pd.types.ParameterOrConstantT,
) -> None: ...Hexagonal anisotropic elastic material parametrized by velocities.
RHO_pd.types.ParameterOrConstantT — Density in kg / m^3.VPH_pd.types.ParameterOrConstantT — Horizontal P-wave velocity in m / s.VPV_pd.types.ParameterOrConstantT — Vertical P-wave velocity in m / s.VSH_pd.types.ParameterOrConstantT — Horizontal S-wave velocity in m / s.VSV_pd.types.ParameterOrConstantT — Vertical S-wave velocity in m / s.ETA_pd.types.ParameterOrConstantT — Eta.
ds typing.Mapping
ds typing.MappingMaterial’s xarray representation.
flatten dict
flatten dictGet all parameters as a dict.
viscosity Material | None
viscosity Material | NoneGet the optional attenuation.
from_dataset()
from_dataset()def from_dataset(ds: xr.Dataset) -> Material[_pd.types.ParameterFlavorT]: ...Construct a material from an xarray Dataset.
dsxr.Dataset — The dataset to construct the material from.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
from_material()
from_material()def from_material(
m: Material,
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> _Hexagonal: ...Construct this material from another within the same physical system.
mMaterial — Material to transform.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
from_params()
from_params()def from_params(
rho: _pd.types.ParameterInput,
vph: _pd.types.ParameterInput,
vpv: _pd.types.ParameterInput,
vsh: _pd.types.ParameterInput,
vsv: _pd.types.ParameterInput,
eta: _pd.types.ParameterInput,
) -> typing.Self: ...Construct this material from generic parameters.
rho_pd.types.ParameterInput — Density in kg / m^3.vph_pd.types.ParameterInput — Horizontal P-wave velocity in m / s.vpv_pd.types.ParameterInput — Vertical P-wave velocity in m / s.vsh_pd.types.ParameterInput — Horizontal S-wave velocity in m / s.vsv_pd.types.ParameterInput — Vertical S-wave velocity in m / s.eta_pd.types.ParameterInput — Eta.
from_tensor_components()
from_tensor_components()def from_tensor_components(
m: GenericTensorComponents[_pd.types.ParameterFlavorT],
reduction_method: (
typing.Literal["remove-components", "force"] | None
) = None,
) -> typing.Self: ...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.
mGenericTensorComponents[_pd.types.ParameterFlavorT] — The material in tensor components parametrization to be used to construct the new material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.
material_system()
material_system()def material_system() -> type[PhysicalMaterial]: ...Get the material system of the material.
map()
map()def map(
self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...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.
ftyping.Callable[[str, typing.Any], tuple[str, typing.Any]] — The function to map over the dataclass.
map_realized_parameters()
map_realized_parameters()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: ...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.
f_constanttyping.Callable[[str, _pd.realized.constant.Parameter], _pd.realized.constant.Parameter] — The function to apply to constant parameters. Defaults to returning the parameter as-is.f_discretetyping.Callable[[str, _pd.realized.discrete.Parameter], _pd.realized.discrete.Parameter] — The function to apply to discrete parameters. Defaults to returning the parameter as-is.f_analytictyping.Callable[[str, _pd.realized.analytic.Parameter], _pd.realized.analytic.Parameter] — The function to apply to analytic parameters. Defaults to returning the parameter as-is.
qc_test()
qc_test()def qc_test(
self,
level: validation.QCLevel | str = QCLevel.strict,
display_issues: bool = True,
) -> dict[str, MaterialQCIssue]: ...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.
levelvalidation.QCLevel | str — 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.display_issuesbool — If True, prints the issues found during the quality control checks. If False, issues are collected but not printed.
type is the type of the issue (e.g, “mesh” or “material”) and code is a specific code for the issue (e.g., “NON_POSITIVE_VP”). If no issues are found, an empty dictionary is returned.to_acoustic()
to_acoustic()def to_acoustic(self) -> AVelocity[_pd.types.ParameterFlavorT]: ...Create acoustic variant of this material.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — 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.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
to_tensor_components()
to_tensor_components()def to_tensor_components(
self, expand_symmetries: bool = False
) -> MaterialDict | GenericTensorComponents: ...Generate a tensor component representation of the material.
This method ensures compatibility with solver and other symmetries.
expand_symmetriesbool — boolean determining if to return a expanded canonical parameters instead of the TensorComponents object in the relevant symmetry system. Defaults to False.
to_wavelength_oracle()
to_wavelength_oracle()def to_wavelength_oracle(
self, n_dim: typing.Literal[2, 3] | None = None
) -> _pd.types.ParameterOrConstantT: ...The wavelength oracle.
n_dimtyping.Literal[2, 3] | None — Dimension to return the oracle for, deprecated.
with_attenuation()
with_attenuation()def with_attenuation(self, attenuation: Material | None) -> Self: ...Add attenuation to an object.
attenuationMaterial | None — The attenuation material.
with_orientation()
with_orientation()def with_orientation(self, orientation: Material | None) -> Material: ...Experimental way to add orientation to a material.
orientationMaterial | None — The orientation.