salvus.flow.executors.direct.simulations
salvus.flow.executors.direct.simulations salvus flow executors direct simulations Run simulations.
Functions
run_adjoint()
run_adjoint()def run_adjoint(
w: simple_config.simulation.Waveform,
mesh: Mesh | UnstructuredMesh,
event_block: EventBlock,
source_time_functions: list[BaseSourceTimeFunction],
adjoint_source_callback: typing.Callable[[EventData], EventMisfit],
wavefield_compression: WavefieldCompression | None = None,
gradient_parameters: set[str] | None = None,
skip_gradient_assembly: bool = False,
event_name: str | None = None,
cores_per_simulation: int,
threads_per_core: int,
_force_in_process_run: bool = False,
_force_subprocess_run: bool = False,
run_directory: pathlib.Path | None = None,
mpirun_binary: pathlib.Path | None = None,
salvus_binary: pathlib.Path | None = None,
use_gpus: bool = False,
environment_variables: dict[str, str] | None = None,
keep_intermediate_data_on_disk: bool = False,
timer: Timer | None = None,
reentrant_timer: bool = False,
) -> tuple[float, Mesh]: ...Run a forward simulation followed by an adjoint simulation to compute the gradient.
This function first runs a forward simulation, then calls the provided callback function with the resulting EventData to compute the misfit and adjoint sources. Finally, it runs an adjoint simulation to compute the gradient.
Parameters
wsimple_config.simulation.Waveform — The waveform configuration.meshMesh | UnstructuredMesh — The mesh to run the simulation on.event_blockEventBlock — The event block defining sources and receivers.source_time_functionslist[BaseSourceTimeFunction] — The source time functions to use.adjoint_source_callbacktyping.Callable[[EventData], EventMisfit] — A callback function that takes the EventData from the forward simulation and returns an EventMisfit object containing the adjoint sources. The misfit value will be retrieved from the EventMisfit.misfit_value property.wavefield_compressionWavefieldCompression | None — Wavefield compression settings.gradient_parametersset[str] | None — Model parameters to compute the gradients for. Must be a subset of the model parameters. If not given, gradients will be computed for all model fields.skip_gradient_assemblybool — Setting for skipping the pre-assembly after gradient computation. If True, the sensitivity kernels won’t be mapped to nodal fields and scaled with the mass matrix, which will have to be done manually.event_namestr | None — An optional name for the event.cores_per_simulationint — Number of MPI ranks to use.threads_per_coreint — Number of threads per MPI rank._force_in_process_runbool — Force using the in-process direct executor._force_subprocess_runbool — Force using the subprocess executor.run_directorypathlib.Path | None — The directory to run the simulation in (for subprocess runs).mpirun_binarypathlib.Path | None — The path to the mpirun binary (for subprocess runs).salvus_binarypathlib.Path | None — The path to the Salvus binary (for subprocess runs).use_gpusbool — Whether to use GPUs for the simulation. By default it will grab all available GPUs, otherwise please specify with the environment_variables.environment_variablesdict[str, str] | None — Optional environment variables to set for the subprocess run.keep_intermediate_data_on_diskbool — Whether to keep intermediate data on disk.timerTimer | None — Execution timer.reentrant_timerbool — Whether the child timers should be reentrant.
Returns tuple[float, Mesh] — A tuple of (misfit, gradient) where misfit is a float and the gradient is a
Mesh object.run_diffusion()
run_diffusion()def run_diffusion(
diffusion_sim: simple_config.simulation.Diffusion,
run_directory: pathlib.Path,
cores_per_simulation: int,
threads_per_simulation: int,
mpirun_binary: pathlib.Path,
salvus_binary: pathlib.Path,
use_gpus: bool = False,
environment_variables: dict[str, str] | None = None,
timer: Timer | None = None,
log_to_logger: bool = True,
reentrant_timer: bool = False,
) -> pathlib.Path: ...Run a diffusion simulation in a subprocess.
Parameters
diffusion_simsimple_config.simulation.Diffusion — The diffusion simulation configuration.run_directorypathlib.Path — The directory to run the simulation in.cores_per_simulationint — Number of MPI ranks to use.threads_per_simulationint — Number of threads per MPI rank.mpirun_binarypathlib.Path — The path to the mpirun binary.salvus_binarypathlib.Path — The path to the Salvus binary.use_gpusbool — Whether to use GPUs for the simulation.environment_variablesdict[str, str] | None — Optional environment variables to set for the subprocess.timerTimer | None — Execution timer.log_to_loggerbool — Whether to log the subprocess output to the logger.reentrant_timerbool — Whether the child timers should be reentrant.
Returns pathlib.Path — The path to the smoothed final values HDF5 file.
run_simulation()
run_simulation()def run_simulation(
w: simple_config.simulation.Waveform,
mesh: Mesh | UnstructuredMesh,
event_block: EventBlock,
source_time_functions: list[BaseSourceTimeFunction],
event_name: str | None = None,
keep_intermediate_data_on_disk: bool = False,
cores_per_simulation: int,
threads_per_core: int,
_force_in_process_run: bool = False,
_force_subprocess_run: bool = False,
run_directory: pathlib.Path | None = None,
mpirun_binary: pathlib.Path | None = None,
salvus_binary: pathlib.Path | None = None,
use_gpus: bool = False,
environment_variables: dict[str, str] | None = None,
timer: Timer | None = None,
reentrant_timer: bool = False,
) -> EventData: ...Run a simulation.
Parameters
wsimple_config.simulation.Waveform — The waveform configuration.meshMesh | UnstructuredMesh — The mesh to run the simulation on.event_blockEventBlock — The event block defining sources and receivers.source_time_functionslist[BaseSourceTimeFunction] — The source time functions to use.event_namestr | None — An optional name for the event.keep_intermediate_data_on_diskbool — Whether to keep intermediate data on disk after the run. This includes the data specified in therun_directoryargument.cores_per_simulationint — Number of MPI ranks to use.threads_per_coreint — Number of threads per core._force_in_process_runbool — Force using the in-process direct executor._force_subprocess_runbool — Force using the subprocess executor.run_directorypathlib.Path | None — The directory to run the simulation in (for subprocess runs).mpirun_binarypathlib.Path | None — The path to the mpirun binary (for subprocess runs).salvus_binarypathlib.Path | None — The path to the Salvus binary (for subprocess runs).use_gpusbool — Whether to use GPUs for the simulation. By default it will grab all available GPUs, otherwise please specify with the environment_variables.environment_variablesdict[str, str] | None — Optional environment variables to set for the subprocess run.timerTimer | None — Execution timer.reentrant_timerbool — Whether the child timers should be reentrant.
Returns EventData