salvus.opt.preconditioner
salvus.opt.preconditioner salvus opt preconditioner Simplified preconditioner interface for unstructured meshes.
Functions
validate()
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.
preconditionerConstantSmoothing | SpaceDependentSmoothing | ModelDependentSmoothing | typing.Callable — Preconditioner.inversion_parameterstyping.Sequence[str] — List of inversion parameters.priorUnstructuredMesh | None — Prior model.
Classes
ConstantSmoothing
ConstantSmoothingclass 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.
smoothing_lengths_in_metersdict[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 toX,Y,Zorr,theta,phi.courant_numbersalvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.time_step_in_secondssalvus._core.types.float_ | None — Optional custom time step for diffusion equation.
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.
get_smoothing_config()
get_smoothing_config()def get_smoothing_config(self) -> dict[str, typing.Any]: ...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.
ModelDependentSmoothing
ModelDependentSmoothingclass 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.
smoothing_lengths_in_wavelengthsdict[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 toX,Y,Zorr,theta,phi.reference_frequency_in_hertzsalvus._core.types.float_ — Reference frequency to compute the wave length in Hz.reference_modelstr — Reference model to extract the reference velocity from. This can either be a model from an arbitrary simulation configuration, orpriorto use the prior model of the inverse problem configuration, orcurrentto use the model of the current iteration, when the preconditioner is applied.reference_velocitiesdict[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_numbersalvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.time_step_in_secondssalvus._core.types.float_ | None — Optional custom time step for diffusion equation.
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.
get_smoothing_config()
get_smoothing_config()def get_smoothing_config(self) -> dict[str, typing.Any]: ...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.
SpaceDependentSmoothing
SpaceDependentSmoothingclass 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.
smoothing_modelstr | pathlib.Path | UnstructuredMesh — Unstructured mesh object containing the smoothing lengths.field_namesdict[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 eitherX,Y,ZorN,E,Z.”courant_numbersalvus._core.types.float_ | None — Optional custom Courant number for auto-time-step detection.time_step_in_secondssalvus._core.types.float_ | None — Optional custom time step for diffusion equation.
from_disk()
from_disk()def from_disk(
d: dict, path: pathlib.Path | None = None
) -> SpaceDependentSmoothing: ...Construct object from a JSON-serializable dictionary.
ddict — JSON dictionary of the iteration.pathpathlib.Path | None — Path to the folder containing auxiliary files.
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.
get_smoothing_config()
get_smoothing_config()def get_smoothing_config(self) -> dict[str, typing.Any]: ...to_disk()
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.
pathpathlib.Path | None — Path to store auxiliary files.external_file_hashstr | 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.
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.