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 sn
p = 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,
)
[2025-04-15 20:08:23,632] INFO: Creating mesh. Hang on. [2025-04-15 20:08:23,679] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008781170_637d4492d9@local [2025-04-15 20:08:23,849] INFO: Creating mesh. Hang on. [2025-04-15 20:08:23,883] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008886673_da31518618@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,
)
[2025-04-15 20:08:26,377] INFO: Adding new iteration #0. [2025-04-15 20:08:26,406] INFO: Resuming iteration #0. [2025-04-15 20:08:26,406] INFO: 1 new tasks have been issued. [2025-04-15 20:08:26,407] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:26,420] 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'] [2025-04-15 20:08:26,429] INFO: Submitting job ... [2025-04-15 20:08:26,477] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:26,477] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:27,479] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:27,521] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:28,523] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:28,567] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:29,569] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:29,619] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:30,620] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:30,664] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:31,666] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:31,709] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:32,710] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:32,754] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:33,755] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:33,955] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008957242_bf5917f227@local [2025-04-15 20:08:33,998] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:33,999] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:35,000] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:08:35,228] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:35,337] INFO: Iteration 0: Number of events: 1 chi = 3.7156536966723097e-10 ||g|| = 3.3910359372571976e-12 pred = --- ared = --- norm_update = --- tr_radius = --- [2025-04-15 20:08:35,340] INFO: 1 new tasks have been issued. [2025-04-15 20:08:35,340] INFO: Processing task `misfit` [2025-04-15 20:08:35,367] INFO: Submitting job ... [2025-04-15 20:08:35,415] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:35,415] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:08:36,429] INFO: Processing task `misfit` [2025-04-15 20:08:36,523] INFO: old misfit control group: 3.7156536966723097e-10 new misfit control group: 1.073889989952079e-10 predicted reduction control group: -2.1653942143243586e-10 actual reduction control group: -2.6417637067202306e-10 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:36,523] INFO: Model update accepted. [2025-04-15 20:08:36,523] INFO: 1 new tasks have been issued. [2025-04-15 20:08:36,524] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:36,547] INFO: Succesfully completed iteration #0. [2025-04-15 20:08:36,548] INFO: Adding new iteration #1. [2025-04-15 20:08:36,552] INFO: Resuming iteration #1. [2025-04-15 20:08:36,553] INFO: 1 new tasks have been issued. [2025-04-15 20:08:36,553] INFO: Processing task `gradient` [2025-04-15 20:08:36,607] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008609615_b8ca2bfa5b@local [2025-04-15 20:08:36,666] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:36,667] INFO: Some tasks of iteration #1 are still running. Please check again later. [2025-04-15 20:08:37,669] INFO: Processing task `gradient` [2025-04-15 20:08:37,701] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:37,818] INFO: Iteration 1: Number of events: 1 chi = 1.073889989952079e-10 ||g|| = 1.037229670389857e-12 pred = -2.1653942143243586e-10 ared = -2.6417637067202306e-10 norm_update = 127.71284376748982 tr_radius = 127.71284376748997 [2025-04-15 20:08:37,826] INFO: 1 new tasks have been issued. [2025-04-15 20:08:37,826] INFO: Processing task `misfit` [2025-04-15 20:08:37,852] INFO: Submitting job ... [2025-04-15 20:08:37,898] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:37,899] INFO: Some tasks of iteration #1 are still running. Please check again later. [2025-04-15 20:08:38,909] INFO: Processing task `misfit` [2025-04-15 20:08:39,004] INFO: old misfit control group: 1.073889989952079e-10 new misfit control group: 7.296709075757565e-11 predicted reduction control group: -1.886436638060351e-11 actual reduction control group: -3.442190823763225e-11 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:39,005] INFO: Model update accepted. [2025-04-15 20:08:39,005] INFO: 1 new tasks have been issued. [2025-04-15 20:08:39,005] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:39,028] INFO: Succesfully completed iteration #1. [2025-04-15 20:08:39,031] INFO: Adding new iteration #2. [2025-04-15 20:08:39,037] INFO: Resuming iteration #2. [2025-04-15 20:08:39,037] INFO: 1 new tasks have been issued. [2025-04-15 20:08:39,037] INFO: Processing task `gradient` [2025-04-15 20:08:39,087] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008089199_e3fbfc594a@local [2025-04-15 20:08:39,132] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:39,133] INFO: Some tasks of iteration #2 are still running. Please check again later. [2025-04-15 20:08:40,136] INFO: Processing task `gradient` [2025-04-15 20:08:40,165] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:40,279] INFO: Iteration 2: Number of events: 1 chi = 7.296709075757565e-11 ||g|| = 8.841255720378636e-13 pred = -1.886436638060351e-11 ared = -3.442190823763225e-11 norm_update = 38.055155588990125 tr_radius = 255.42568753497994 [2025-04-15 20:08:40,291] INFO: 1 new tasks have been issued. [2025-04-15 20:08:40,292] INFO: Processing task `misfit` [2025-04-15 20:08:40,313] INFO: Submitting job ... [2025-04-15 20:08:40,368] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:40,369] INFO: Some tasks of iteration #2 are still running. Please check again later. [2025-04-15 20:08:41,381] INFO: Processing task `misfit` [2025-04-15 20:08:41,417] INFO: Some tasks of iteration #2 are still running. Please check again later. [2025-04-15 20:08:42,432] INFO: Processing task `misfit`
[2025-04-15 20:08:42,527] INFO: old misfit control group: 7.296709075757565e-11 new misfit control group: 7.29921706188182e-12 predicted reduction control group: -5.3947833613705984e-11 actual reduction control group: -6.566787369569383e-11 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:42,528] INFO: Model update accepted. [2025-04-15 20:08:42,528] INFO: 1 new tasks have been issued. [2025-04-15 20:08:42,528] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:42,553] INFO: Succesfully completed iteration #2. [2025-04-15 20:08:42,559] INFO: Adding new iteration #3. [2025-04-15 20:08:42,567] INFO: Resuming iteration #3. [2025-04-15 20:08:42,568] INFO: 1 new tasks have been issued. [2025-04-15 20:08:42,568] INFO: Processing task `gradient` [2025-04-15 20:08:42,621] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008623790_f28c6983a7@local [2025-04-15 20:08:42,669] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:42,669] INFO: Some tasks of iteration #3 are still running. Please check again later. [2025-04-15 20:08:43,671] INFO: Processing task `gradient` [2025-04-15 20:08:43,703] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:43,739] INFO: Some simulations are still running. Please check again to see if they are finished. [2025-04-15 20:08:43,740] INFO: Some tasks of iteration #3 are still running. Please check again later. [2025-04-15 20:08:44,742] INFO: Processing task `gradient` [2025-04-15 20:08:44,776] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:44,885] INFO: Iteration 3: Number of events: 1 chi = 7.29921706188182e-12 ||g|| = 2.1080709923504721e-13 pred = -5.3947833613705984e-11 ared = -6.566787369569383e-11 norm_update = 127.71284376748984 tr_radius = 127.71284376748997 [2025-04-15 20:08:44,905] INFO: 1 new tasks have been issued. [2025-04-15 20:08:44,905] INFO: Processing task `misfit` [2025-04-15 20:08:44,928] INFO: Submitting job ... [2025-04-15 20:08:44,976] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:44,977] INFO: Some tasks of iteration #3 are still running. Please check again later. [2025-04-15 20:08:45,989] INFO: Processing task `misfit` [2025-04-15 20:08:46,082] INFO: old misfit control group: 7.29921706188182e-12 new misfit control group: 3.853990185690102e-12 predicted reduction control group: -3.625527296947774e-12 actual reduction control group: -3.4452268761917177e-12 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:46,082] INFO: Model update accepted. [2025-04-15 20:08:46,082] INFO: 1 new tasks have been issued. [2025-04-15 20:08:46,083] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:46,107] INFO: Succesfully completed iteration #3. [2025-04-15 20:08:46,113] INFO: Adding new iteration #4. [2025-04-15 20:08:46,121] INFO: Resuming iteration #4. [2025-04-15 20:08:46,121] INFO: 1 new tasks have been issued. [2025-04-15 20:08:46,121] INFO: Processing task `gradient` [2025-04-15 20:08:46,174] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008176387_0383c642ae@local [2025-04-15 20:08:46,222] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:46,222] INFO: Some tasks of iteration #4 are still running. Please check again later. [2025-04-15 20:08:47,225] INFO: Processing task `gradient` [2025-04-15 20:08:47,256] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:47,373] INFO: Iteration 4: Number of events: 1 chi = 3.853990185690102e-12 ||g|| = 5.491251362114438e-14 pred = -3.625527296947774e-12 ared = -3.4452268761917177e-12 norm_update = 37.634593986576924 tr_radius = 255.42568753497994 [2025-04-15 20:08:47,397] INFO: 1 new tasks have been issued. [2025-04-15 20:08:47,398] INFO: Processing task `misfit` [2025-04-15 20:08:47,427] INFO: Submitting job ... [2025-04-15 20:08:47,476] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:47,476] INFO: Some tasks of iteration #4 are still running. Please check again later. [2025-04-15 20:08:48,494] INFO: Processing task `misfit` [2025-04-15 20:08:48,527] INFO: Some tasks of iteration #4 are still running. Please check again later. [2025-04-15 20:08:49,537] INFO: Processing task `misfit` [2025-04-15 20:08:49,634] INFO: old misfit control group: 3.853990185690102e-12 new misfit control group: 3.660798440136839e-12 predicted reduction control group: -1.1394903979292904e-13 actual reduction control group: -1.9319174555326333e-13 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:49,634] INFO: Model update accepted. [2025-04-15 20:08:49,635] INFO: 1 new tasks have been issued. [2025-04-15 20:08:49,635] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:49,655] INFO: Succesfully completed iteration #4. [2025-04-15 20:08:49,657] INFO: Adding new iteration #5. [2025-04-15 20:08:49,670] INFO: Resuming iteration #5. [2025-04-15 20:08:49,670] INFO: 1 new tasks have been issued. [2025-04-15 20:08:49,671] INFO: Processing task `gradient` [2025-04-15 20:08:49,722] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008724419_b8e6cd4278@local [2025-04-15 20:08:49,767] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:49,768] INFO: Some tasks of iteration #5 are still running. Please check again later. [2025-04-15 20:08:50,771] INFO: Processing task `gradient` [2025-04-15 20:08:50,802] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:50,913] INFO: Iteration 5: Number of events: 1 chi = 3.660798440136839e-12 ||g|| = 3.682525298193585e-14 pred = -1.1394903979292904e-13 ared = -1.9319174555326333e-13 norm_update = 4.998974676234866 tr_radius = 127.71284376748997 [2025-04-15 20:08:50,941] INFO: 1 new tasks have been issued. [2025-04-15 20:08:50,941] INFO: Processing task `misfit` [2025-04-15 20:08:50,964] INFO: Submitting job ... [2025-04-15 20:08:51,012] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:51,012] INFO: Some tasks of iteration #5 are still running. Please check again later. [2025-04-15 20:08:52,024] INFO: Processing task `misfit` [2025-04-15 20:08:52,119] INFO: old misfit control group: 3.660798440136839e-12 new misfit control group: 2.9810284223434555e-12 predicted reduction control group: -4.4323683818356934e-13 actual reduction control group: -6.797700177933832e-13 1 out of 1 event(s) improved the misfit. [2025-04-15 20:08:52,119] INFO: Model update accepted. [2025-04-15 20:08:52,120] INFO: 1 new tasks have been issued. [2025-04-15 20:08:52,120] INFO: Processing task `finalize_iteration` [2025-04-15 20:08:52,151] INFO: Succesfully completed iteration #5. [2025-04-15 20:08:52,156] INFO: Adding new iteration #6. [2025-04-15 20:08:52,167] INFO: Resuming iteration #6.
[2025-04-15 20:08:52,168] INFO: 1 new tasks have been issued. [2025-04-15 20:08:52,168] INFO: Processing task `gradient` [2025-04-15 20:08:52,222] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152008224187_c32434486d@local [2025-04-15 20:08:52,267] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:52,267] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:53,270] INFO: Processing task `gradient` [2025-04-15 20:08:53,308] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:53,334] INFO: Some simulations are still running. Please check again to see if they are finished. [2025-04-15 20:08:53,334] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:54,337] INFO: Processing task `gradient` [2025-04-15 20:08:54,375] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:08:54,487] INFO: Iteration 6: Number of events: 1 chi = 2.9810284223434555e-12 ||g|| = 1.1334072418867954e-13 pred = -4.4323683818356934e-13 ared = -6.797700177933832e-13 norm_update = 25.945609247270596 tr_radius = 63.856421883744986 [2025-04-15 20:08:54,521] INFO: 1 new tasks have been issued. [2025-04-15 20:08:54,522] INFO: Processing task `misfit` [2025-04-15 20:08:54,545] INFO: Submitting job ... [2025-04-15 20:08:54,589] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:08:54,590] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:55,604] INFO: Processing task `misfit` [2025-04-15 20:08:55,638] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:56,651] INFO: Processing task `misfit` [2025-04-15 20:08:56,686] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:57,697] INFO: Processing task `misfit` [2025-04-15 20:08:57,733] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:58,745] INFO: Processing task `misfit` [2025-04-15 20:08:58,782] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:08:59,794] INFO: Processing task `misfit` [2025-04-15 20:08:59,828] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:09:00,844] INFO: Processing task `misfit` [2025-04-15 20:09:00,879] INFO: Some tasks of iteration #6 are still running. Please check again later. [2025-04-15 20:09:01,891] INFO: Processing task `misfit` [2025-04-15 20:09:01,990] INFO: old misfit control group: 2.9810284223434555e-12 new misfit control group: 1.9555860418200896e-12 predicted reduction control group: -6.673080610254194e-13 actual reduction control group: -1.025442380523366e-12 1 out of 1 event(s) improved the misfit. [2025-04-15 20:09:01,990] INFO: Model update accepted. [2025-04-15 20:09:01,991] INFO: 1 new tasks have been issued. [2025-04-15 20:09:01,991] INFO: Processing task `finalize_iteration` [2025-04-15 20:09:02,013] INFO: Succesfully completed iteration #6. [2025-04-15 20:09:02,021] INFO: Adding new iteration #7. [2025-04-15 20:09:02,032] INFO: Resuming iteration #7. [2025-04-15 20:09:02,033] INFO: 1 new tasks have been issued. [2025-04-15 20:09:02,034] INFO: Processing task `gradient` [2025-04-15 20:09:02,088] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152009090388_db06eb8c45@local [2025-04-15 20:09:02,134] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:02,134] INFO: Some tasks of iteration #7 are still running. Please check again later. [2025-04-15 20:09:03,170] INFO: Processing task `gradient` [2025-04-15 20:09:03,208] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:09:03,319] INFO: Iteration 7: Number of events: 1 chi = 1.9555860418200896e-12 ||g|| = 1.8082278362551017e-13 pred = -6.673080610254194e-13 ared = -1.025442380523366e-12 norm_update = 51.891218494541064 tr_radius = 51.89121849454119 [2025-04-15 20:09:03,356] INFO: 1 new tasks have been issued. [2025-04-15 20:09:03,356] INFO: Processing task `misfit` [2025-04-15 20:09:03,378] INFO: Submitting job ... [2025-04-15 20:09:03,428] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:03,428] INFO: Some tasks of iteration #7 are still running. Please check again later. [2025-04-15 20:09:04,442] INFO: Processing task `misfit` [2025-04-15 20:09:04,537] INFO: old misfit control group: 1.9555860418200896e-12 new misfit control group: 7.195492692978477e-13 predicted reduction control group: -8.887018361461577e-13 actual reduction control group: -1.2360367725222419e-12 1 out of 1 event(s) improved the misfit. [2025-04-15 20:09:04,537] INFO: Model update accepted. [2025-04-15 20:09:04,537] INFO: 1 new tasks have been issued. [2025-04-15 20:09:04,538] INFO: Processing task `finalize_iteration` [2025-04-15 20:09:04,570] INFO: Succesfully completed iteration #7. [2025-04-15 20:09:04,574] INFO: Adding new iteration #8. [2025-04-15 20:09:04,591] INFO: Resuming iteration #8. [2025-04-15 20:09:04,593] INFO: 1 new tasks have been issued. [2025-04-15 20:09:04,593] INFO: Processing task `gradient` [2025-04-15 20:09:04,646] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152009648517_dcc520b5ee@local [2025-04-15 20:09:04,689] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:04,690] INFO: Some tasks of iteration #8 are still running. Please check again later. [2025-04-15 20:09:05,693] INFO: Processing task `gradient` [2025-04-15 20:09:05,725] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:09:05,840] INFO: Iteration 8: Number of events: 1 chi = 7.195492692978477e-13 ||g|| = 1.668305656509431e-13 pred = -8.887018361461577e-13 ared = -1.2360367725222419e-12 norm_update = 83.04605740553336 tr_radius = 103.78243698908238 [2025-04-15 20:09:05,884] INFO: 1 new tasks have been issued. [2025-04-15 20:09:05,884] INFO: Processing task `misfit` [2025-04-15 20:09:05,905] INFO: Submitting job ... [2025-04-15 20:09:05,967] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:05,968] INFO: Some tasks of iteration #8 are still running. Please check again later. [2025-04-15 20:09:06,980] INFO: Processing task `misfit` [2025-04-15 20:09:07,075] INFO: old misfit control group: 7.195492692978477e-13 new misfit control group: 3.428681080907987e-14 predicted reduction control group: -5.160693460554207e-13 actual reduction control group: -6.852624584887678e-13 1 out of 1 event(s) improved the misfit. [2025-04-15 20:09:07,076] INFO: Model update accepted. [2025-04-15 20:09:07,076] INFO: 1 new tasks have been issued. [2025-04-15 20:09:07,076] INFO: Processing task `finalize_iteration`
[2025-04-15 20:09:07,101] INFO: Succesfully completed iteration #8. [2025-04-15 20:09:07,105] INFO: Adding new iteration #9. [2025-04-15 20:09:07,118] INFO: Resuming iteration #9. [2025-04-15 20:09:07,118] 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
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x75f611177650>
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)
[2025-04-15 20:09:08,570] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152009573325_1b252998b7@local
[2025-04-15 20:09:09,392] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152009397594_1516b810db@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,
)
[2025-04-15 20:09:10,729] INFO: Adding new iteration #0. [2025-04-15 20:09:10,738] INFO: Resuming iteration #0. [2025-04-15 20:09:10,742] INFO: 1 new tasks have been issued. [2025-04-15 20:09:10,744] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:09:10,761] 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'] [2025-04-15 20:09:10,773] INFO: Submitting job ... [2025-04-15 20:09:10,820] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:10,821] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:09:15,822] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:09:15,984] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2504152009986255_83520afbdd@local [2025-04-15 20:09:16,028] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:16,028] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:09:21,029] INFO: Processing task `misfit_and_gradient` [2025-04-15 20:09:21,088] INFO: 1 events have already been submitted. They will not be submitted again. [2025-04-15 20:09:21,206] INFO: Iteration 0: Number of events: 1 chi = 1.8063817169917176e-11 ||g|| = 3.4633490526471955e-13 pred = --- ared = --- norm_update = --- tr_radius = --- [2025-04-15 20:09:21,210] INFO: 1 new tasks have been issued. [2025-04-15 20:09:21,211] INFO: Processing task `misfit` [2025-04-15 20:09:21,233] INFO: Submitting job ... [2025-04-15 20:09:21,280] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2025-04-15 20:09:21,281] INFO: Some tasks of iteration #0 are still running. Please check again later. [2025-04-15 20:09:26,292] INFO: Processing task `misfit` [2025-04-15 20:09:26,389] INFO: old misfit control group: 1.8063817169917176e-11 new misfit control group: 1.0995271385440556e-11 predicted reduction control group: -4.165941036285124e-12 actual reduction control group: -7.06854578447662e-12 1 out of 1 event(s) improved the misfit. [2025-04-15 20:09:26,390] INFO: Model update accepted. [2025-04-15 20:09:26,390] INFO: 1 new tasks have been issued. [2025-04-15 20:09:26,391] INFO: Processing task `finalize_iteration` [2025-04-15 20:09:26,416] INFO: Succesfully completed iteration #0. [2025-04-15 20:09:26,418] INFO: Adding new iteration #1.
p.simulations.get_mesh(p.inversions.get_simulation_name("inversion_two", 1))
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x75f61075de90>