Mondaic
This API reference is not for the latest stable Salvus version.

salvus.mesh.layered_meshing.material.parameter

Implementation of parameter types.

Functions

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.

Parameters
  • a salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — First parameter to compare.
  • b salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — Second parameter to compare.
  • rtol float — See documentation for np.all_close.
  • atol float — See documentation for np.all_close.
Returns bool — Whether or not the parameter are equal within some tolerance.

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.

Parameters
  • p salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra — The parameter.
Returns Optional[float] — A constant value if the parameter is constant, else None.

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.

Parameters
  • p Any — The parameter’s representation type.
  • interpolation_method Literal[('nearest', 'linear')] — Interpolation method for xarray representations. Only used if the value passed for p is indeed a xarray.DataArray. Defaults to linear.
  • name Optional[str] — An optional name to display on conversion failure.
Returns Union[ConstantParameter, DiscreteParameter, AnalyticParameter, salvus.mesh.layered_meshing.material.parameter._RealizedParameter] — The constructed parameter.

Classes

AnalyticParameter

class 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.

Parameters
  • p sympy.core.expr.Expr — The sympy expression.

ConstantParameter

class ConstantParameter(
    salvus.mesh.layered_meshing.material.parameter._ParameterAlgebra
):
    def __init__(self, p: float) -> None:
        ...

A scalar parameter that does not vary within a layer.

Parameters
  • p float — The value.
Attributes
xr xarray.core.dataarray.DataArray

The parameter wrapped in a DataArray.

DiscreteParameter

class 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.

Parameters
  • p xarray.core.dataarray.DataArray — The xarray.DataArray.
  • interpolation_method Literal[('nearest', 'linear')] — The interpolation method to use between points.
Attributes
xr xarray.core.dataarray.DataArray

The parameter wrapped in a DataArray.