Mondaic

salvus.project.tools.mpi_workflows.run_simulations_from_project

salvus.project.tools.mpi_workflows.run_simulations_from_project salvus project tools mpi_workflows run_simulations_from_project

Compute misfits and gradients for certain special cases.

Functions

compute_misfits_and_gradients_from_project()

def compute_misfits_and_gradients_from_project(
    project: Project,
    simulation_configuration: str,
    misfit_configuration: str,
    event_names: list[str],
    execution_config: MPIExecutionConfiguration,
    wavefield_compression: WavefieldCompression | None = None,
    gradient_parameters: set[str] | None = None,
    overwrite_mesh: DistributedMesh | None = None,
    timer: Timer | None = None,
    diagnostic_output_directory: pathlib.Path | None = None,
    verbosity: int = 1,
) -> tuple[dict[str, float], DistributedMesh]: ...

Compute misfits and gradients for the given project using MPI.

Parameters
  • project Project — The Salvus project to compute misfits and gradients for.
  • simulation_configuration str — The name of the simulation configuration to use.
  • misfit_configuration str — The name of the misfit configuration to use.
  • event_names list[str] — The names of the events to compute for.
  • execution_config MPIExecutionConfiguration — The MPI execution configuration to use.
  • wavefield_compression WavefieldCompression | None — Optional wavefield compression settings.
  • gradient_parameters set[str] | None — The set of parameter names to compute gradients for. If None, gradients will be computed for all parameters defined on the mesh.
  • overwrite_mesh DistributedMesh | None — If provided, this mesh will be used for running simulations instead of the mesh defined in the project. The rest of the simulation settings will still be extracted from the simulation configuration.
  • timer Timer | None — Execution timer.
  • diagnostic_output_directory pathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.
  • verbosity int — Controls the amount of progress reporting.
Returns tuple[dict[str, float], DistributedMesh] — A tuple of (misfit_map, summed_gradient) where misfit_map maps event names to misfit values and summed_gradient is a distributed mesh holding the summed gradient.

compute_misfits_from_project()

def compute_misfits_from_project(
    project: Project,
    simulation_configuration: str,
    misfit_configuration: str,
    event_names: list[str],
    execution_config: MPIExecutionConfiguration,
    overwrite_mesh: DistributedMesh | None = None,
    simulation_name_for_extra_outputs: str | None = None,
    timer: Timer | None = None,
    diagnostic_output_directory: pathlib.Path | None = None,
    verbosity: int = 1,
) -> dict[str, float]: ...

Compute misfits (without gradients) for the given project using MPI.

This runs forward simulations and evaluates the misfit for each event. Unlike :func:compute_misfits_and_gradients_from_project, no adjoint simulation is performed and EventData objects are discarded immediately after the misfit has been computed, keeping memory usage low.

Parameters
  • project Project — The Salvus project to compute misfits for.
  • simulation_configuration str — The name of the simulation configuration to use.
  • misfit_configuration str — The name of the misfit configuration to use.
  • event_names list[str] — The names of the events to compute for.
  • execution_config MPIExecutionConfiguration — The MPI execution configuration to use.
  • overwrite_mesh DistributedMesh | None — If provided, this mesh will be used for running simulations instead of the mesh defined in the project. The rest of the simulation settings will still be extracted from the simulation configuration.
  • simulation_name_for_extra_outputs str | None — If provided, this name will be passed to the extra output callback function in the misfit configuration. This thus control the folder the files are temporarily stored in.
  • timer Timer | None — Execution timer.
  • diagnostic_output_directory pathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.
  • verbosity int — Controls the amount of progress reporting.
Returns dict[str, float] — A dictionary mapping event names to misfit values.

run_simulations_from_project()

def run_simulations_from_project(
    project: Project,
    simulation_configuration: str,
    event_names: list[str],
    execution_config: MPIExecutionConfiguration,
    result_callback_function: typing.Callable[..., EventData] | None = None,
    extra_output_configuration: dict[str, typing.Any] | None = None,
    get_all_outputs: bool = True,
    diagnostic_output_directory: pathlib.Path | None = None,
    timer: Timer | None = None,
    verbosity: int = 1,
) -> None: ...

Run simulations for the given project using MPI.

Parameters
  • project Project — The Salvus project to run simulations for.
  • simulation_configuration str — The name of the simulation configuration to use.
  • event_names list[str] — The names of the events to run simulations for.
  • execution_config MPIExecutionConfiguration — The MPI execution configuration to use.
  • result_callback_function typing.Callable[..., EventData] | None — Callback function for performing additional processing on the results from each simulation. The callback function should have arguments result, simulation, and timer, with types EventData, Simulation, and Timer respectively. The callback function should return the processed data. Below is an example of such a callback function: python def result_callback_function( result: EventData, simulation: Simulation, timer: Timer | None = None, ) -> EventData: # Perform custom processing on the result here ... return result
  • extra_output_configuration dict[str, typing.Any] | None — Extra settings for the waveform simulations. Can only be used for settings that do not change the resulting waveforms. python extra_output_configuration={ "volume_data": { "sampling_interval_in_time_steps": 50, "fields": ["displacement"], }, "surface_data": { "sampling_interval_in_time_steps": 20, "fields": ["acceleration", "velocity"], "side_sets": ["x0", "x1"], }, "memory_per_rank_in_MB": 2000.0, }
  • get_all_outputs bool — Whether to copy all volumetric outputs to the project, if they are included in the extra_output_configuration. Generally the only reason where one would set this to False would be for instances where one would wish to perform some custom processing on wavefield outputs in the result_callback_function without copying the full wavefield data to the project.
  • diagnostic_output_directory pathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.
  • timer Timer | None — Execution timer.
  • verbosity int — Controls the amount of progress reporting.
Returns None