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()
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
projectProject — The Salvus project to compute misfits and gradients for.simulation_configurationstr — The name of the simulation configuration to use.misfit_configurationstr — The name of the misfit configuration to use.event_nameslist[str] — The names of the events to compute for.execution_configMPIExecutionConfiguration — The MPI execution configuration to use.wavefield_compressionWavefieldCompression | None — Optional wavefield compression settings.gradient_parametersset[str] | None — The set of parameter names to compute gradients for. IfNone, gradients will be computed for all parameters defined on the mesh.overwrite_meshDistributedMesh | 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.timerTimer | None — Execution timer.diagnostic_output_directorypathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.verbosityint — 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()
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
projectProject — The Salvus project to compute misfits for.simulation_configurationstr — The name of the simulation configuration to use.misfit_configurationstr — The name of the misfit configuration to use.event_nameslist[str] — The names of the events to compute for.execution_configMPIExecutionConfiguration — The MPI execution configuration to use.overwrite_meshDistributedMesh | 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_outputsstr | 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.timerTimer | None — Execution timer.diagnostic_output_directorypathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.verbosityint — Controls the amount of progress reporting.
Returns dict[str, float] — A dictionary mapping event names to misfit values.
run_simulations_from_project()
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
projectProject — The Salvus project to run simulations for.simulation_configurationstr — The name of the simulation configuration to use.event_nameslist[str] — The names of the events to run simulations for.execution_configMPIExecutionConfiguration — The MPI execution configuration to use.result_callback_functiontyping.Callable[..., EventData] | None — Callback function for performing additional processing on the results from each simulation. The callback function should have argumentsresult,simulation, andtimer, with typesEventData,Simulation, andTimerrespectively. 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 resultextra_output_configurationdict[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_outputsbool — Whether to copy all volumetric outputs to the project, if they are included in theextra_output_configuration. Generally the only reason where one would set this toFalsewould be for instances where one would wish to perform some custom processing on wavefield outputs in theresult_callback_functionwithout copying the full wavefield data to the project.diagnostic_output_directorypathlib.Path | None — If set, the input files and mesh for the offending simulation will be moved to that directory.timerTimer | None — Execution timer.verbosityint — Controls the amount of progress reporting.
Returns None