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

salvus.opt.preconditioner

Simplified preconditioner interface for unstructured meshes

Functions

validate()

def validate(
    preconditioner: Union[
        salvus.opt.preconditioner.ConstantSmoothing,
        salvus.opt.preconditioner.SpaceDependentSmoothing,
        salvus.opt.preconditioner.ModelDependentSmoothing,
    ],
    inversion_parameters: Sequence[str],
    prior: Optional[
        salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh
    ] = None,
) -> None: ...

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

Parameters
  • preconditioner Union[salvus.opt.preconditioner.ConstantSmoothing, salvus.opt.preconditioner.SpaceDependentSmoothing, salvus.opt.preconditioner.ModelDependentSmoothing] — Preconditioner.
  • inversion_parameters Sequence[str] — List of inversion parameters.
  • prior Optional[salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh] — Prior model.
Returns None

Classes

ConstantSmoothing

class ConstantSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_lengths_in_meters: Dict[
            str,
            Union[
                int,
                numpy.int32,
                numpy.int64,
                float,
                numpy.float32,
                numpy.float64,
                Sequence[
                    Union[
                        int,
                        numpy.int32,
                        numpy.int64,
                        float,
                        numpy.float32,
                        numpy.float64,
                    ]
                ],
            ],
        ],
        courant_number: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
        time_step_in_seconds: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
    ): ...

Constant (an)-isotropic smoothing

Parameters
  • smoothing_lengths_in_meters Dict[str, Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64, Sequence[Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64]]]] — 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 Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom time step for diffusion equation.
Methods
from_json()
def from_json(d: Dict) -> Any: ...

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

Parameters
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns Any
get_smoothing_config()
def get_smoothing_config(self) -> Dict[str, Any]: ...
Returns Dict[str, Any] — A dictionary with a smoothing configurations for each field.
to_json()
def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash Optional[str] — 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

ModelDependentSmoothing

class ModelDependentSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_lengths_in_wavelengths: Dict[
            str,
            Union[
                int,
                numpy.int32,
                numpy.int64,
                float,
                numpy.float32,
                numpy.float64,
                Sequence[
                    Union[
                        int,
                        numpy.int32,
                        numpy.int64,
                        float,
                        numpy.float32,
                        numpy.float64,
                    ]
                ],
            ],
        ],
        reference_frequency_in_hertz: Union[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ],
        reference_model: str,
        reference_velocities: Optional[Dict[str, str]] = None,
        courant_number: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
        time_step_in_seconds: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
    ): ...

Model-dependent (an)-isotropic smoothing

Parameters
  • smoothing_lengths_in_wavelengths Dict[str, Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64, Sequence[Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64]]]] — 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 Union[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — 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 Optional[Dict[str, str]] — 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 Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom time step for diffusion equation.
Methods
from_json()
def from_json(d: Dict) -> Any: ...

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

Parameters
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns Any
get_smoothing_config()
def get_smoothing_config(self) -> Dict[str, Any]: ...
Returns Dict[str, Any] — A dictionary with a smoothing configurations for each field.
to_json()
def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash Optional[str] — 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

SpaceDependentSmoothing

class SpaceDependentSmoothing(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        smoothing_model: Union[
            str,
            pathlib.Path,
            salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
        ],
        field_names: Dict[str, Union[str, Sequence[str]]],
        courant_number: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
        time_step_in_seconds: Optional[
            int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
        ] = None,
    ): ...

Space-dependent (an)-isotropic smoothing

Parameters
  • smoothing_model Union[str, pathlib.Path, salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh] — Unstructured mesh object containing the smoothing lengths.
  • field_names Dict[str, Union[str, 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 Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom Courant number for auto-time-step detection.
  • time_step_in_seconds Optional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional custom time step for diffusion equation.
Methods
from_disk()
def from_disk(
    d: Dict, path: Optional[pathlib.Path] = None
) -> SpaceDependentSmoothing: ...

Construct object from a JSON-serializable dictionary.

Parameters
  • d Dict — JSON dictionary of the iteration.
  • path Optional[pathlib.Path] — Path to the folder containing auxiliary files.
Returns SpaceDependentSmoothing
from_json()
def from_json(d: Dict) -> Any: ...

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

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

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

Parameters
  • path Optional[pathlib.Path] — Path to store auxiliary files.
  • external_file_hash Optional[str] — 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: Optional[str] = None) -> Dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash Optional[str] — 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