This documentation is not for the latest stable Salvus version.
%matplotlib inline
%config Completer.use_jedi = False
import os
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")scaling="homogeneous" in the mapping function of an InverseProblemConfiguration enables inversion for homogeneous model parameters with full-waveform inversion.sn.Mapping( scaling="homogeneous", inversion_parameters=[...], ... )
import matplotlib.pyplot as plt
import numpy as np
import pathlib
import time
import xarray as xr
import salvus.namespace as snp = sn.Project.from_domain(
path="project",
domain=sn.domain.dim2.BoxDomain(
x0=0.0,
x1=1.0,
y0=0.0,
y1=1.5,
),
load_if_exists=True,
)src = sn.simple_config.source.cartesian.VectorPoint2D(
x=0.33, y=0.0, fx=0.0, fy=1.0e9
)
rec = sn.simple_config.receiver.cartesian.Point2D(
x=0.67,
y=1.5,
fields=["displacement"],
network_code="REC",
station_code="000",
)
p += sn.Event(event_name="event", sources=src, receivers=rec)ec = sn.EventConfiguration(
waveform_simulation_configuration=sn.WaveformSimulationConfiguration(
end_time_in_seconds=0.0006
),
wavelet=sn.simple_config.stf.Ricker(center_frequency=10000.0),
)p.viz.nb.domain()vp, vs and rho. Note that the deviations in the parameters have opposite signs and different magnitudes.true_model = sn.model.background.homogeneous.IsotropicElastic(
vp=5800.0, vs=3200.0, rho=2600.0
)
initial_model = sn.model.background.homogeneous.IsotropicElastic(
vp=5600.0, vs=3300.0, rho=2400.0
)for name, model in zip(["true", "init"], [true_model, initial_model]):
p.add_to_project(
sn.SimulationConfiguration(
name=name,
elements_per_wavelength=2,
tensor_order=1,
max_frequency_in_hertz=20000.0,
model_configuration=sn.ModelConfiguration(background_model=model),
event_configuration=ec,
),
overwrite=True,
)
p.simulations.launch(
simulation_configuration=name,
events=p.events.list(),
site_name=SALVUS_FLOW_SITE_NAME,
ranks_per_job=1,
)[2026-05-01 15:01:26,656] INFO: Creating mesh. Hang on. [2026-05-01 15:01:26,692] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2605011501765588_9a9a9d65d5@local [2026-05-01 15:01:26,815] INFO: Creating mesh. Hang on. [2026-05-01 15:01:26,843] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2605011501847183_b3b96a8c5e@local
p.simulations.query(block=True)True
p.viz.nb.waveforms(data=["true", "init"], receiver_field="displacement")scaling="homogeneous" in the mapping function, which enforces a homogeneous medium in every iteration. Note that a smoothing preconditioner is not necessary here, because the mapped gradient is already homogeneous.p += sn.MisfitConfiguration(
name="L2",
observed_data="true",
misfit_function="L2",
receiver_field="displacement",
)p += sn.InverseProblemConfiguration(
name="inversion",
prior_model="init",
events=p.events.list(),
mapping=sn.Mapping(
scaling="homogeneous",
inversion_parameters=["VP", "VS", "RHO"],
),
method=sn.TrustRegion(initial_trust_region_linf=100.0),
misfit_configuration="L2",
job_submission=sn.SiteConfig(
site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=1
),
)for i in range(10):
p.inversions.iterate(
inverse_problem_configuration="inversion",
timeout_in_seconds=360,
ping_interval_in_seconds=1,
)[2026-05-01 15:01:27,545] INFO: Adding new iteration #0. [2026-05-01 15:01:27,551] INFO: Resuming iteration #0. [2026-05-01 15:01:27,552] INFO: 1 new tasks have been issued. [2026-05-01 15:01:27,552] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:01:27,559] INFO: The following events have been simulated before, but checkpoints are not available for this combination of `site_name` and `ranks_per_job` and wavefield compression settings. They will be run again: ['event'] [2026-05-01 15:01:27,569] INFO: Submitting job ... [2026-05-01 15:01:27,610] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:27,611] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:01:28,612] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:01:28,768] INFO: Submitting job ... [2026-05-01 15:01:28,807] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:28,807] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:01:29,809] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:01:29,981] INFO: Iteration 0: Number of events: 1 chi = 3.7205959825215416e-10 ||g|| = 3.3917093639661965e-12 pred = --- ared = --- norm_update = --- tr_radius = --- [2026-05-01 15:01:29,985] INFO: 1 new tasks have been issued. [2026-05-01 15:01:29,985] INFO: Processing task `misfit` [2026-05-01 15:01:30,006] INFO: Submitting job ... [2026-05-01 15:01:30,050] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:30,051] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:01:31,059] INFO: Processing task `misfit` [2026-05-01 15:01:31,189] INFO: old misfit control group: 3.7205959825215416e-10 new misfit control group: 1.076045212643669e-10 predicted reduction control group: -2.166098899097739e-10 actual reduction control group: -2.6445507698778725e-10 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:31,189] INFO: Model update accepted. [2026-05-01 15:01:31,189] INFO: 1 new tasks have been issued. [2026-05-01 15:01:31,189] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:31,206] INFO: Successfully completed iteration #0. [2026-05-01 15:01:31,207] INFO: Adding new iteration #1. [2026-05-01 15:01:31,210] INFO: Resuming iteration #1. [2026-05-01 15:01:31,211] INFO: 1 new tasks have been issued. [2026-05-01 15:01:31,214] INFO: Processing task `gradient` [2026-05-01 15:01:31,237] INFO: Submitting job ... [2026-05-01 15:01:31,276] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:31,276] INFO: Some tasks of iteration #1 are still running. Please check again later. [2026-05-01 15:01:32,278] INFO: Processing task `gradient` [2026-05-01 15:01:32,397] INFO: Iteration 1: Number of events: 1 chi = 1.076045212643669e-10 ||g|| = 1.0378109074386243e-12 pred = -2.166098899097739e-10 ared = -2.6445507698778725e-10 norm_update = 127.72906648856653 tr_radius = 127.72904473898676 [2026-05-01 15:01:32,405] INFO: 1 new tasks have been issued. [2026-05-01 15:01:32,405] INFO: Processing task `misfit` [2026-05-01 15:01:32,424] INFO: Submitting job ... [2026-05-01 15:01:32,464] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:32,464] INFO: Some tasks of iteration #1 are still running. Please check again later. [2026-05-01 15:01:33,473] INFO: Processing task `misfit` [2026-05-01 15:01:33,587] INFO: old misfit control group: 1.076045212643669e-10 new misfit control group: 7.302850724013198e-11 predicted reduction control group: -1.8959662615933293e-11 actual reduction control group: -3.4576014024234917e-11 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:33,587] INFO: Model update accepted. [2026-05-01 15:01:33,588] INFO: 1 new tasks have been issued. [2026-05-01 15:01:33,588] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:33,602] INFO: Successfully completed iteration #1. [2026-05-01 15:01:33,603] INFO: Adding new iteration #2. [2026-05-01 15:01:33,606] INFO: Resuming iteration #2. [2026-05-01 15:01:33,607] INFO: 1 new tasks have been issued. [2026-05-01 15:01:33,607] INFO: Processing task `gradient` [2026-05-01 15:01:33,631] INFO: Submitting job ... [2026-05-01 15:01:33,669] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:33,670] INFO: Some tasks of iteration #2 are still running. Please check again later. [2026-05-01 15:01:34,671] INFO: Processing task `gradient` [2026-05-01 15:01:34,815] INFO: Iteration 2: Number of events: 1 chi = 7.302850724013198e-11 ||g|| = 8.865559007326891e-13 pred = -1.8959662615933293e-11 ared = -3.4576014024234917e-11 norm_update = 38.230054884872935 tr_radius = 255.45808947797352 [2026-05-01 15:01:34,828] INFO: 1 new tasks have been issued. [2026-05-01 15:01:34,829] INFO: Processing task `misfit` [2026-05-01 15:01:34,848] INFO: Submitting job ... [2026-05-01 15:01:34,887] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:34,887] INFO: Some tasks of iteration #2 are still running. Please check again later. [2026-05-01 15:01:35,897] INFO: Processing task `misfit` [2026-05-01 15:01:36,027] INFO: old misfit control group: 7.302850724013198e-11 new misfit control group: 7.241710397550178e-12 predicted reduction control group: -5.408398932155688e-11 actual reduction control group: -6.578679684258181e-11 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:36,027] INFO: Model update accepted. [2026-05-01 15:01:36,028] INFO: 1 new tasks have been issued. [2026-05-01 15:01:36,028] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:36,043] INFO: Successfully completed iteration #2. [2026-05-01 15:01:36,044] INFO: Adding new iteration #3. [2026-05-01 15:01:36,050] INFO: Resuming iteration #3. [2026-05-01 15:01:36,051] INFO: 1 new tasks have been issued. [2026-05-01 15:01:36,051] INFO: Processing task `gradient` [2026-05-01 15:01:36,073] INFO: Submitting job ... [2026-05-01 15:01:36,111] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:36,111] INFO: Some tasks of iteration #3 are still running. Please check again later. [2026-05-01 15:01:37,113] INFO: Processing task `gradient` [2026-05-01 15:01:37,249] INFO: Iteration 3: Number of events: 1 chi = 7.241710397550178e-12 ||g|| = 2.1714889063681053e-13 pred = -5.408398932155688e-11 ared = -6.578679684258181e-11 norm_update = 127.72910906934997 tr_radius = 127.72904473898676 [2026-05-01 15:01:37,267] INFO: 1 new tasks have been issued. [2026-05-01 15:01:37,268] INFO: Processing task `misfit` [2026-05-01 15:01:37,292] INFO: Submitting job ... [2026-05-01 15:01:37,337] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:37,337] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2026-05-01 15:01:38,346] INFO: Processing task `misfit` [2026-05-01 15:01:38,466] INFO: old misfit control group: 7.241710397550178e-12 new misfit control group: 3.735632237592794e-12 predicted reduction control group: -3.703996792169938e-12 actual reduction control group: -3.5060781599573842e-12 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:38,466] INFO: Model update accepted. [2026-05-01 15:01:38,466] INFO: 1 new tasks have been issued. [2026-05-01 15:01:38,466] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:38,484] INFO: Successfully completed iteration #3. [2026-05-01 15:01:38,487] INFO: Adding new iteration #4. [2026-05-01 15:01:38,493] INFO: Resuming iteration #4. [2026-05-01 15:01:38,494] INFO: 1 new tasks have been issued. [2026-05-01 15:01:38,494] INFO: Processing task `gradient` [2026-05-01 15:01:38,519] INFO: Submitting job ... [2026-05-01 15:01:38,558] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:38,558] INFO: Some tasks of iteration #4 are still running. Please check again later. [2026-05-01 15:01:39,560] INFO: Processing task `gradient` [2026-05-01 15:01:39,724] INFO: Iteration 4: Number of events: 1 chi = 3.735632237592794e-12 ||g|| = 5.6465329403926735e-14 pred = -3.703996792169938e-12 ared = -3.5060781599573842e-12 norm_update = 37.89899789698217 tr_radius = 255.45808947797352 [2026-05-01 15:01:39,750] INFO: 1 new tasks have been issued. [2026-05-01 15:01:39,751] INFO: Processing task `misfit` [2026-05-01 15:01:39,769] INFO: Submitting job ... [2026-05-01 15:01:39,808] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:39,808] INFO: Some tasks of iteration #4 are still running. Please check again later. [2026-05-01 15:01:40,817] INFO: Processing task `misfit` [2026-05-01 15:01:40,941] INFO: old misfit control group: 3.735632237592794e-12 new misfit control group: 3.5501140247409006e-12 predicted reduction control group: -1.1112888070074128e-13 actual reduction control group: -1.8551821285189303e-13 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:40,942] INFO: Model update accepted. [2026-05-01 15:01:40,942] INFO: 1 new tasks have been issued. [2026-05-01 15:01:40,942] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:40,963] INFO: Successfully completed iteration #4. [2026-05-01 15:01:40,966] INFO: Adding new iteration #5. [2026-05-01 15:01:40,978] INFO: Resuming iteration #5. [2026-05-01 15:01:40,979] INFO: 1 new tasks have been issued. [2026-05-01 15:01:40,979] INFO: Processing task `gradient` [2026-05-01 15:01:41,006] INFO: Submitting job ... [2026-05-01 15:01:41,045] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:41,045] INFO: Some tasks of iteration #5 are still running. Please check again later. [2026-05-01 15:01:42,048] INFO: Processing task `gradient` [2026-05-01 15:01:42,199] INFO: Iteration 5: Number of events: 1 chi = 3.5501140247409006e-12 ||g|| = 3.653900046074735e-14 pred = -1.1112888070074128e-13 ared = -1.8551821285189303e-13 norm_update = 4.751473853028537 tr_radius = 127.72904473898676 [2026-05-01 15:01:42,226] INFO: 1 new tasks have been issued. [2026-05-01 15:01:42,227] INFO: Processing task `misfit` [2026-05-01 15:01:42,243] INFO: Submitting job ... [2026-05-01 15:01:42,284] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:42,284] INFO: Some tasks of iteration #5 are still running. Please check again later. [2026-05-01 15:01:43,294] INFO: Processing task `misfit` [2026-05-01 15:01:43,413] INFO: old misfit control group: 3.5501140247409006e-12 new misfit control group: 2.974722012848408e-12 predicted reduction control group: -3.72819107620411e-13 actual reduction control group: -5.753920118924928e-13 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:43,414] INFO: Model update accepted. [2026-05-01 15:01:43,414] INFO: 1 new tasks have been issued. [2026-05-01 15:01:43,414] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:43,430] INFO: Successfully completed iteration #5. [2026-05-01 15:01:43,433] INFO: Adding new iteration #6. [2026-05-01 15:01:43,442] INFO: Resuming iteration #6. [2026-05-01 15:01:43,446] INFO: 1 new tasks have been issued. [2026-05-01 15:01:43,447] INFO: Processing task `gradient` [2026-05-01 15:01:43,468] INFO: Submitting job ... [2026-05-01 15:01:43,509] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:43,509] INFO: Some tasks of iteration #6 are still running. Please check again later. [2026-05-01 15:01:44,512] INFO: Processing task `gradient` [2026-05-01 15:01:44,662] INFO: Iteration 6: Number of events: 1 chi = 2.974722012848408e-12 ||g|| = 1.0651363585516546e-13 pred = -3.72819107620411e-13 ared = -5.753920118924928e-13 norm_update = 21.937566197395977 tr_radius = 63.86452236949338 [2026-05-01 15:01:44,702] INFO: 1 new tasks have been issued. [2026-05-01 15:01:44,702] INFO: Processing task `misfit` [2026-05-01 15:01:44,722] INFO: Submitting job ... [2026-05-01 15:01:44,762] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:44,762] INFO: Some tasks of iteration #6 are still running. Please check again later. [2026-05-01 15:01:45,771] INFO: Processing task `misfit` [2026-05-01 15:01:45,898] INFO: old misfit control group: 2.974722012848408e-12 new misfit control group: 2.081249480680253e-12 predicted reduction control group: -5.685075150393315e-13 actual reduction control group: -8.93472532168155e-13 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:45,898] INFO: Model update accepted. [2026-05-01 15:01:45,898] INFO: 1 new tasks have been issued. [2026-05-01 15:01:45,899] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:45,920] INFO: Successfully completed iteration #6. [2026-05-01 15:01:45,924] INFO: Adding new iteration #7. [2026-05-01 15:01:45,938] INFO: Resuming iteration #7. [2026-05-01 15:01:45,939] INFO: 1 new tasks have been issued. [2026-05-01 15:01:45,939] INFO: Processing task `gradient` [2026-05-01 15:01:45,968] INFO: Submitting job ... [2026-05-01 15:01:46,007] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:46,008] INFO: Some tasks of iteration #7 are still running. Please check again later. [2026-05-01 15:01:47,010] INFO: Processing task `gradient` [2026-05-01 15:01:47,155] INFO: Iteration 7: Number of events: 1 chi = 2.081249480680253e-12 ||g|| = 1.738942928956662e-13 pred = -5.685075150393315e-13 ared = -8.93472532168155e-13 norm_update = 43.87518718611967 tr_radius = 43.875132394791954 [2026-05-01 15:01:47,195] INFO: 1 new tasks have been issued. [2026-05-01 15:01:47,195] INFO: Processing task `misfit` [2026-05-01 15:01:47,213] INFO: Submitting job ... [2026-05-01 15:01:47,253] INFO: Launched simulations for 1 events. Please check again to see if they are finished.
[2026-05-01 15:01:47,253] INFO: Some tasks of iteration #7 are still running. Please check again later. [2026-05-01 15:01:48,263] INFO: Processing task `misfit` [2026-05-01 15:01:48,382] INFO: old misfit control group: 2.081249480680253e-12 new misfit control group: 8.064264663646178e-13 predicted reduction control group: -9.096217109752372e-13 actual reduction control group: -1.274823014315635e-12 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:48,383] INFO: Model update accepted. [2026-05-01 15:01:48,383] INFO: 1 new tasks have been issued. [2026-05-01 15:01:48,383] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:48,401] INFO: Successfully completed iteration #7. [2026-05-01 15:01:48,405] INFO: Adding new iteration #8. [2026-05-01 15:01:48,416] INFO: Resuming iteration #8. [2026-05-01 15:01:48,417] INFO: 1 new tasks have been issued. [2026-05-01 15:01:48,417] INFO: Processing task `gradient` [2026-05-01 15:01:48,447] INFO: Submitting job ... [2026-05-01 15:01:48,484] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:48,485] INFO: Some tasks of iteration #8 are still running. Please check again later. [2026-05-01 15:01:49,487] INFO: Processing task `gradient` [2026-05-01 15:01:49,640] INFO: Iteration 8: Number of events: 1 chi = 8.064264663646178e-13 ||g|| = 1.7954928627055263e-13 pred = -9.096217109752372e-13 ared = -1.274823014315635e-12 norm_update = 82.3862594648483 tr_radius = 87.75026478958391 [2026-05-01 15:01:49,681] INFO: 1 new tasks have been issued. [2026-05-01 15:01:49,681] INFO: Processing task `misfit` [2026-05-01 15:01:49,697] INFO: Submitting job ... [2026-05-01 15:01:49,737] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:49,737] INFO: Some tasks of iteration #8 are still running. Please check again later. [2026-05-01 15:01:50,746] INFO: Processing task `misfit` [2026-05-01 15:01:50,869] INFO: old misfit control group: 8.064264663646178e-13 new misfit control group: 1.6453472698879645e-14 predicted reduction control group: -6.99819454501923e-13 actual reduction control group: -7.899729936657382e-13 1 out of 1 event(s) improved the misfit. [2026-05-01 15:01:50,870] INFO: Model update accepted. [2026-05-01 15:01:50,870] INFO: 1 new tasks have been issued. [2026-05-01 15:01:50,870] INFO: Processing task `finalize_iteration` [2026-05-01 15:01:50,889] INFO: Successfully completed iteration #8. [2026-05-01 15:01:50,893] INFO: Adding new iteration #9. [2026-05-01 15:01:50,906] INFO: Resuming iteration #9. [2026-05-01 15:01:50,907] INFO: The total number of iterations in this inversion tree has been reached and no new iteration will be added. If you want to continue with this inversion, you need to adjust `max_iterations_global` using `set_stopping_criteria`.
p.viz.nb.inversion(inverse_problem_configuration="inversion")solution = p.simulations.get_mesh(
p.inversions.get_simulation_name("inversion", 9)
)
np.testing.assert_allclose(solution.elemental_fields["VP"], 5800.0, 1e-3)
np.testing.assert_allclose(solution.elemental_fields["VS"], 3200.0, 1e-3)
np.testing.assert_allclose(solution.elemental_fields["RHO"], 2600.0, 4e-3)block with integer IDs labeling the different parts of the model. For some meshing routines, this field is automatically added. In this example, we manually assign different IDs to distinguish a small square at [0.4, 0.6] x [0.5, 0.7] from the background media.mesh = p.simulations.get_mesh("true")
blocks = np.zeros(mesh.nelem, dtype=int)
mask1 = mesh.get_element_centroid()[:, 0] > 0.4
mask2 = mesh.get_element_centroid()[:, 0] < 0.6
mask3 = mesh.get_element_centroid()[:, 1] > 0.5
mask4 = mesh.get_element_centroid()[:, 1] < 0.7
mask = mask1 & mask2 & mask3 & mask4
blocks[mask] = 1
mesh.attach_field("block", blocks)
mesh<unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x73cd420fd590>
p.add_to_project(
sn.UnstructuredMeshSimulationConfiguration(
name="two_blocks_initial",
unstructured_mesh=mesh,
event_configuration=ec,
),
)
mesh.elemental_fields["VP"][blocks == 1] *= 1.1
mesh.elemental_fields["VS"][blocks == 1] *= 1.1
mesh.elemental_fields["RHO"][blocks == 1] *= 1.1
p.add_to_project(
sn.UnstructuredMeshSimulationConfiguration(
name="two_blocks",
unstructured_mesh=mesh,
event_configuration=ec,
),
)for name in ["two_blocks_initial", "two_blocks"]:
p.simulations.launch(
simulation_configuration=name,
events=p.events.list(),
site_name=SALVUS_FLOW_SITE_NAME,
ranks_per_job=1,
)
p.simulations.query(block=True)[2026-05-01 15:01:53,908] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2605011501910833_eb83f3db83@local
[2026-05-01 15:01:54,203] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2605011501205798_7f7feaa398@local
p += sn.MisfitConfiguration(
name="L2-block",
observed_data="two_blocks",
misfit_function="L2",
receiver_field="displacement",
)discontinuous_model_blocks, which refers to the values defined in the field block and indicates the piece-wise constant regions of the model.
In this example, only the area with block = 1 will be updated. The background model is kept constant. Note that in this example no region of interest or preconditioner is required.p += sn.InverseProblemConfiguration(
name="inversion_two",
prior_model="two_blocks_initial",
events=p.events.list(),
mapping=sn.Mapping(
scaling="homogeneous",
discontinuous_model_blocks=[[1]],
inversion_parameters=["VP", "VS", "RHO"],
),
method=sn.TrustRegion(initial_trust_region_linf=100.0),
misfit_configuration="L2-block",
job_submission=sn.SiteConfig(
site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=1
),
)p.inversions.iterate(
inverse_problem_configuration="inversion_two",
timeout_in_seconds=360,
ping_interval_in_seconds=5,
)[2026-05-01 15:01:54,602] INFO: Adding new iteration #0. [2026-05-01 15:01:54,613] INFO: Resuming iteration #0. [2026-05-01 15:01:54,614] INFO: 1 new tasks have been issued. [2026-05-01 15:01:54,614] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:01:54,620] INFO: The following events have been simulated before, but checkpoints are not available for this combination of `site_name` and `ranks_per_job` and wavefield compression settings. They will be run again: ['event'] [2026-05-01 15:01:54,630] INFO: Submitting job ... [2026-05-01 15:01:54,668] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:54,669] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:01:59,670] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:01:59,801] INFO: Submitting job ... [2026-05-01 15:01:59,840] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:01:59,840] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:02:04,841] INFO: Processing task `misfit_and_gradient` [2026-05-01 15:02:04,986] INFO: Iteration 0: Number of events: 1 chi = 1.802223072632871e-11 ||g|| = 3.4619982938242124e-13 pred = --- ared = --- norm_update = --- tr_radius = --- [2026-05-01 15:02:04,989] INFO: 1 new tasks have been issued. [2026-05-01 15:02:04,990] INFO: Processing task `misfit` [2026-05-01 15:02:05,005] INFO: Submitting job ... [2026-05-01 15:02:05,046] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2026-05-01 15:02:05,047] INFO: Some tasks of iteration #0 are still running. Please check again later. [2026-05-01 15:02:10,055] INFO: Processing task `misfit` [2026-05-01 15:02:10,184] INFO: old misfit control group: 1.802223072632871e-11 new misfit control group: 1.0954331266342636e-11 predicted reduction control group: -4.164361660427456e-12 actual reduction control group: -7.067899459986075e-12 1 out of 1 event(s) improved the misfit. [2026-05-01 15:02:10,185] INFO: Model update accepted. [2026-05-01 15:02:10,185] INFO: 1 new tasks have been issued. [2026-05-01 15:02:10,185] INFO: Processing task `finalize_iteration` [2026-05-01 15:02:10,200] INFO: Successfully completed iteration #0. [2026-05-01 15:02:10,201] INFO: Adding new iteration #1.
p.simulations.get_mesh(p.inversions.get_simulation_name("inversion_two", 1))<unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x73cd41e82490>