Mondaic

salvus.opt.preconditioner

salvus.opt.preconditioner salvus opt preconditioner

Simplified preconditioner interface for unstructured meshes.

Functions

validate()

def validate(
    preconditioner: (
        ConstantSmoothing
        | SpaceDependentSmoothing
        | ModelDependentSmoothing
        | typing.Callable
    ),
    inversion_parameters: typing.Sequence[str],
    prior: UnstructuredMesh | None = None,
) -> None: ...

Validate a preconditioner instance for a set of inversion paramaters, and, optionally, the prior model.

Parameters
  • preconditioner ConstantSmoothing | SpaceDependentSmoothing | ModelDependentSmoothing | typing.Callable — Preconditioner.
  • inversion_parameters typing.Sequence[str] — List of inversion parameters.
  • prior UnstructuredMesh | None — Prior model.
Returns None

Classes

ConstantSmoothing

class ConstantSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_lengths_in_meters: dict[
            str,
            salvus._core.types.float_
            | collections.abc.Sequence[salvus._core.types.float_],
        ],
        courant_number: salvus._core.types.float_ | None = None,
        time_step_in_seconds: salvus._core.types.float_ | None = None,
    ): ...

Constant (an)-isotropic smoothing.

Parameters
  • smoothing_lengths_in_meters dict[str, salvus._core.types.float_ | collections.abc.Sequence[salvus._core.types.float_]] — Smoothing length in meters. Provide a float for isotropic smoothing, or a list of length dim for anisotropic smoothing. Depending on the reference frame of the input mesh the indices of the list either correspond to X, Y, Z or r, theta, phi.
  • courant_number salvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds salvus._core.types.float_ | None — Optional custom time step for diffusion equation.
Methods
from_json()
def from_json(d: builtins.dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d builtins.dict — Dictionary containing its init parameters and a few other things.
Returns Any
get_smoothing_config()
def get_smoothing_config(self) -> dict[str, typing.Any]: ...
Returns dict[str, typing.Any] — A dictionary with a smoothing configurations for each field.
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.

Parameters
  • external_file_hash types — 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.
  • timer types — Execution timer.
  • log_to_logger bool — Log timings to the logger.
  • comm types — MPI communicator, if any.
Returns builtins.dict

ModelDependentSmoothing

class ModelDependentSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_lengths_in_wavelengths: dict[
            str,
            salvus._core.types.float_
            | collections.abc.Sequence[salvus._core.types.float_],
        ],
        reference_frequency_in_hertz: salvus._core.types.float_,
        reference_model: str,
        reference_velocities: dict[str, str] | None = None,
        courant_number: salvus._core.types.float_ | None = None,
        time_step_in_seconds: salvus._core.types.float_ | None = None,
    ): ...

Model-dependent (an)-isotropic smoothing.

Parameters
  • smoothing_lengths_in_wavelengths dict[str, salvus._core.types.float_ | collections.abc.Sequence[salvus._core.types.float_]] — Smoothing length in wave lengths. Provide a float for isotropic smoothing, or a list of length dim for anisotropic smoothing. Depending on the reference frame of the input mesh the indices of the list either correspond to X, Y, Z or r, theta, phi.
  • reference_frequency_in_hertz salvus._core.types.float_ — Reference frequency to compute the wave length in Hz.
  • reference_model str — Reference model to extract the reference velocity from. This can either be a model from an arbitrary simulation configuration, or prior to use the prior model of the inverse problem configuration, or current to use the model of the current iteration, when the preconditioner is applied.
  • reference_velocities dict[str, str] | None — Optional mapping providing the field name of the reference velocity to compute the wave length in Hz. If no reference velocity is provided, the same field name will be used.
  • courant_number salvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds salvus._core.types.float_ | None — Optional custom time step for diffusion equation.
Methods
from_json()
def from_json(d: builtins.dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d builtins.dict — Dictionary containing its init parameters and a few other things.
Returns Any
get_smoothing_config()
def get_smoothing_config(self) -> dict[str, typing.Any]: ...
Returns dict[str, typing.Any] — A dictionary with a smoothing configurations for each field.
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.

Parameters
  • external_file_hash types — 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.
  • timer types — Execution timer.
  • log_to_logger bool — Log timings to the logger.
  • comm types — MPI communicator, if any.
Returns builtins.dict

SpaceDependentSmoothing

class SpaceDependentSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_model: str | pathlib.Path | UnstructuredMesh,
        field_names: dict[str, str | collections.abc.Sequence[str]],
        courant_number: salvus._core.types.float_ | None = None,
        time_step_in_seconds: salvus._core.types.float_ | None = None,
    ): ...

Space-dependent (an)-isotropic smoothing.

Parameters
  • smoothing_model str | pathlib.Path | UnstructuredMesh — Unstructured mesh object containing the smoothing lengths.
  • field_names dict[str, str | collections.abc.Sequence[str]] — Dictionary specifying the field names that contain the smoothing length in meters for each parameter field. This could either be a single field for isotropic, or a list for anisoptropic smoothing, respectively. Depending on the reference frame of the input mesh this is either X, Y, Z or N, E, Z.”
  • courant_number salvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds salvus._core.types.float_ | None — Optional custom time step for diffusion equation.
Methods
from_disk()
def from_disk(
    d: dict, path: pathlib.Path | None = None
) -> SpaceDependentSmoothing: ...

Construct object from a JSON-serializable dictionary.

Parameters
  • d dict — JSON dictionary of the iteration.
  • path pathlib.Path | None — Path to the folder containing auxiliary files.
Returns SpaceDependentSmoothing
from_json()
def from_json(d: builtins.dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d builtins.dict — Dictionary containing its init parameters and a few other things.
Returns Any
get_smoothing_config()
def get_smoothing_config(self) -> dict[str, typing.Any]: ...
Returns dict[str, typing.Any] — A dictionary with a smoothing configurations for each field.
to_disk()
def to_disk(
    self,
    path: pathlib.Path | None = None,
    external_file_hash: str | None = None,
) -> dict: ...

Serialize the object to dictionary that can be written to JSON. Auxiliary files will be written to the specified path.

Parameters
  • path pathlib.Path | None — Path to store auxiliary files.
  • external_file_hash str | None — 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.
Returns dict
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.

Parameters
  • external_file_hash types — 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.
  • timer types — Execution timer.
  • log_to_logger bool — Log timings to the logger.
  • comm types — MPI communicator, if any.
Returns builtins.dict

Used in tutorials