salvus.mesh.layered_meshing.material.parameter
Implementation of parameter types.
Functions
all_close()
all_close()def all_close(
a: salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra,
b: salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra,
rtol: float = 1e-05,
atol: float = 1e-08,
) -> bool:
...Check whether a parameter is “close” (approximately equal) to another.
All fields belonging to this parameter are checked in turn. Numerical
quantities will be compared with numpy.all_close(...) and the rtol and
atol parameters will be passed on accordingly. Normalization is attempted
on sympy expressions via sympy.nsimplify before comparison.
asalvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — First parameter to compare.bsalvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — Second parameter to compare.rtolfloat — See documentation fornp.all_close.atolfloat — See documentation fornp.all_close.
constant_value()
constant_value()def constant_value(
p: salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra,
) -> Optional[float]:
...If a parameter is constant, return its constant value.
If it is not constant return None.
psalvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — The parameter.
None.factory()
factory()def factory(
p: Any,
interpolation_method: Literal[("nearest", "linear")] = "linear",
name: Optional[str] = None,
) -> Union[
ConstantParameter,
DiscreteParameter,
AnalyticParameter,
salvus.mesh.layered_meshing.material.parameter._RealizedParameter,
]:
...Construct a generic parameter from a variety of argument types.
pAny — The parameter’s representation type.interpolation_methodLiteral[('nearest', 'linear')] — Interpolation method forxarrayrepresentations. Only used if the value passed for p is indeed axarray.DataArray. Defaults to linear.nameOptional[str] — An optional name to display on conversion failure.
Classes
AnalyticParameter
AnalyticParameterclass AnalyticParameter(
salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra
):
def __init__(self, p: sympy.core.expr.Expr) -> None:
...A parameter defined analytically that may vary within a layer.
Analytic parameters are represented internally by a sympy Expr type.
psympy.core.expr.Expr — The sympy expression.
ConstantParameter
ConstantParameterclass ConstantParameter(
salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra
):
def __init__(self, p: float) -> None:
...A scalar parameter that does not vary within a layer.
pfloat — The value.
xr xarray.core.dataarray.DataArray
xr xarray.core.dataarray.DataArrayThe parameter wrapped in a DataArray.
DiscreteParameter
DiscreteParameterclass DiscreteParameter(
salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra
):
def __init__(
self,
p: xarray.core.dataarray.DataArray,
interpolation_method: Literal[("nearest", "linear")] = "linear",
) -> None:
...A parameter defined at a set of points that may vary within a layer.
Discrete parameters are represented internally by an xarray.DataArray,
along with an interpolation method for computing values in between points.
pxarray.core.dataarray.DataArray — Thexarray.DataArray.interpolation_methodLiteral[('nearest', 'linear')] — The interpolation method to use between points.
xr xarray.core.dataarray.DataArray
xr xarray.core.dataarray.DataArrayThe parameter wrapped in a DataArray.