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,
)
[2024-03-15 09:30:21,068] INFO: Creating mesh. Hang on. [2024-03-15 09:30:21,434] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930536190_46bfa552e7@local [2024-03-15 09:30:21,609] INFO: Creating mesh. Hang on. [2024-03-15 09:30:21,637] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930641576_f277540586@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,
)
[2024-03-15 09:30:22,660] INFO: Adding new iteration #0. [2024-03-15 09:30:22,667] INFO: Resuming iteration #0. [2024-03-15 09:30:22,672] INFO: 1 new tasks have been issued. [2024-03-15 09:30:22,672] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:30:22,690] 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'] [2024-03-15 09:30:22,701] INFO: Submitting job ... [2024-03-15 09:30:22,749] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:22,749] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:30:23,751] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:30:23,977] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930979953_e29a95ac20@local [2024-03-15 09:30:24,020] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:24,020] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:30:25,022] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:30:25,097] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:25,223] INFO: Iteration 0: Number of events: 1 chi = 3.7156536966723097e-10 ||g|| = 3.3910359372571976e-12 pred = --- ared = --- norm_update = --- tr_radius = --- [2024-03-15 09:30:25,226] INFO: 1 new tasks have been issued. [2024-03-15 09:30:25,226] INFO: Processing task `misfit` [2024-03-15 09:30:25,251] INFO: Submitting job ... [2024-03-15 09:30:25,292] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:25,293] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:30:26,308] INFO: Processing task `misfit` [2024-03-15 09:30:26,409] 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. [2024-03-15 09:30:26,409] INFO: Model update accepted. [2024-03-15 09:30:26,410] INFO: 1 new tasks have been issued. [2024-03-15 09:30:26,410] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:26,422] INFO: Succesfully completed iteration #0. [2024-03-15 09:30:26,423] INFO: Adding new iteration #1. [2024-03-15 09:30:26,426] INFO: Resuming iteration #1. [2024-03-15 09:30:26,426] INFO: 1 new tasks have been issued. [2024-03-15 09:30:26,426] INFO: Processing task `gradient` [2024-03-15 09:30:26,491] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930493352_564cfdf2b6@local [2024-03-15 09:30:26,533] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:26,533] INFO: Some tasks of iteration #1 are still running. Please check again later. [2024-03-15 09:30:27,535] INFO: Processing task `gradient` [2024-03-15 09:30:27,580] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:27,705] 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 [2024-03-15 09:30:27,713] INFO: 1 new tasks have been issued. [2024-03-15 09:30:27,713] INFO: Processing task `misfit` [2024-03-15 09:30:27,738] INFO: Submitting job ... [2024-03-15 09:30:27,783] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:27,784] INFO: Some tasks of iteration #1 are still running. Please check again later. [2024-03-15 09:30:28,795] INFO: Processing task `misfit` [2024-03-15 09:30:28,899] 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. [2024-03-15 09:30:28,900] INFO: Model update accepted. [2024-03-15 09:30:28,900] INFO: 1 new tasks have been issued. [2024-03-15 09:30:28,900] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:28,913] INFO: Succesfully completed iteration #1. [2024-03-15 09:30:28,915] INFO: Adding new iteration #2. [2024-03-15 09:30:28,920] INFO: Resuming iteration #2. [2024-03-15 09:30:28,922] INFO: 1 new tasks have been issued. [2024-03-15 09:30:28,923] INFO: Processing task `gradient` [2024-03-15 09:30:28,987] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930989521_d942c9a6e5@local [2024-03-15 09:30:29,029] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:29,030] INFO: Some tasks of iteration #2 are still running. Please check again later. [2024-03-15 09:30:30,033] INFO: Processing task `gradient` [2024-03-15 09:30:30,077] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:30,198] 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 [2024-03-15 09:30:30,211] INFO: 1 new tasks have been issued. [2024-03-15 09:30:30,211] INFO: Processing task `misfit` [2024-03-15 09:30:30,235] INFO: Submitting job ... [2024-03-15 09:30:30,280] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:30,280] INFO: Some tasks of iteration #2 are still running. Please check again later. [2024-03-15 09:30:31,292] INFO: Processing task `misfit` [2024-03-15 09:30:31,395] 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. [2024-03-15 09:30:31,396] INFO: Model update accepted. [2024-03-15 09:30:31,396] INFO: 1 new tasks have been issued. [2024-03-15 09:30:31,396] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:31,408] INFO: Succesfully completed iteration #2. [2024-03-15 09:30:31,410] INFO: Adding new iteration #3. [2024-03-15 09:30:31,416] INFO: Resuming iteration #3. [2024-03-15 09:30:31,416] INFO: 1 new tasks have been issued. [2024-03-15 09:30:31,416] INFO: Processing task `gradient` [2024-03-15 09:30:31,481] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930483469_a7b3bbeb84@local [2024-03-15 09:30:31,519] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:31,519] INFO: Some tasks of iteration #3 are still running. Please check again later. [2024-03-15 09:30:32,522] INFO: Processing task `gradient`
[2024-03-15 09:30:32,568] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:32,692] 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 [2024-03-15 09:30:32,712] INFO: 1 new tasks have been issued. [2024-03-15 09:30:32,713] INFO: Processing task `misfit` [2024-03-15 09:30:32,739] INFO: Submitting job ... [2024-03-15 09:30:32,780] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:32,780] INFO: Some tasks of iteration #3 are still running. Please check again later. [2024-03-15 09:30:33,795] INFO: Processing task `misfit` [2024-03-15 09:30:33,913] 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. [2024-03-15 09:30:33,914] INFO: Model update accepted. [2024-03-15 09:30:33,914] INFO: 1 new tasks have been issued. [2024-03-15 09:30:33,914] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:33,928] INFO: Succesfully completed iteration #3. [2024-03-15 09:30:33,934] INFO: Adding new iteration #4. [2024-03-15 09:30:33,942] INFO: Resuming iteration #4. [2024-03-15 09:30:33,942] INFO: 1 new tasks have been issued. [2024-03-15 09:30:33,942] INFO: Processing task `gradient` [2024-03-15 09:30:34,007] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930009143_8201677e8f@local [2024-03-15 09:30:34,048] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:34,048] INFO: Some tasks of iteration #4 are still running. Please check again later. [2024-03-15 09:30:35,051] INFO: Processing task `gradient` [2024-03-15 09:30:35,097] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:35,220] 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 [2024-03-15 09:30:35,244] INFO: 1 new tasks have been issued. [2024-03-15 09:30:35,244] INFO: Processing task `misfit` [2024-03-15 09:30:35,268] INFO: Submitting job ... [2024-03-15 09:30:35,312] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:35,312] INFO: Some tasks of iteration #4 are still running. Please check again later. [2024-03-15 09:30:36,324] INFO: Processing task `misfit` [2024-03-15 09:30:36,426] 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. [2024-03-15 09:30:36,427] INFO: Model update accepted. [2024-03-15 09:30:36,427] INFO: 1 new tasks have been issued. [2024-03-15 09:30:36,427] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:36,441] INFO: Succesfully completed iteration #4. [2024-03-15 09:30:36,447] INFO: Adding new iteration #5. [2024-03-15 09:30:36,456] INFO: Resuming iteration #5. [2024-03-15 09:30:36,456] INFO: 1 new tasks have been issued. [2024-03-15 09:30:36,456] INFO: Processing task `gradient` [2024-03-15 09:30:36,520] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930521999_36d16a3893@local [2024-03-15 09:30:36,562] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:36,562] INFO: Some tasks of iteration #5 are still running. Please check again later. [2024-03-15 09:30:37,566] INFO: Processing task `gradient` [2024-03-15 09:30:37,609] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:37,641] INFO: Some simulations are still running. Please check again to see if they are finished. [2024-03-15 09:30:37,642] INFO: Some tasks of iteration #5 are still running. Please check again later. [2024-03-15 09:30:38,645] INFO: Processing task `gradient` [2024-03-15 09:30:38,687] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:38,821] 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 [2024-03-15 09:30:38,848] INFO: 1 new tasks have been issued. [2024-03-15 09:30:38,848] INFO: Processing task `misfit` [2024-03-15 09:30:38,871] INFO: Submitting job ... [2024-03-15 09:30:38,915] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:38,915] INFO: Some tasks of iteration #5 are still running. Please check again later. [2024-03-15 09:30:39,928] INFO: Processing task `misfit` [2024-03-15 09:30:40,040] 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. [2024-03-15 09:30:40,041] INFO: Model update accepted. [2024-03-15 09:30:40,041] INFO: 1 new tasks have been issued. [2024-03-15 09:30:40,041] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:40,056] INFO: Succesfully completed iteration #5. [2024-03-15 09:30:40,058] INFO: Adding new iteration #6. [2024-03-15 09:30:40,070] INFO: Resuming iteration #6. [2024-03-15 09:30:40,070] INFO: 1 new tasks have been issued. [2024-03-15 09:30:40,071] INFO: Processing task `gradient` [2024-03-15 09:30:40,134] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930136599_a16b2cdbbc@local [2024-03-15 09:30:40,177] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:40,177] INFO: Some tasks of iteration #6 are still running. Please check again later. [2024-03-15 09:30:41,181] INFO: Processing task `gradient` [2024-03-15 09:30:41,225] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:41,345] 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 [2024-03-15 09:30:41,378] INFO: 1 new tasks have been issued. [2024-03-15 09:30:41,378] INFO: Processing task `misfit` [2024-03-15 09:30:41,401] INFO: Submitting job ... [2024-03-15 09:30:41,445] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:41,445] INFO: Some tasks of iteration #6 are still running. Please check again later. [2024-03-15 09:30:42,458] INFO: Processing task `misfit`
[2024-03-15 09:30:42,555] 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. [2024-03-15 09:30:42,555] INFO: Model update accepted. [2024-03-15 09:30:42,555] INFO: 1 new tasks have been issued. [2024-03-15 09:30:42,556] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:42,573] INFO: Succesfully completed iteration #6. [2024-03-15 09:30:42,576] INFO: Adding new iteration #7. [2024-03-15 09:30:42,589] INFO: Resuming iteration #7. [2024-03-15 09:30:42,589] INFO: 1 new tasks have been issued. [2024-03-15 09:30:42,590] INFO: Processing task `gradient` [2024-03-15 09:30:42,657] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930658941_6cbcfe5680@local [2024-03-15 09:30:42,698] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:42,698] INFO: Some tasks of iteration #7 are still running. Please check again later. [2024-03-15 09:30:43,702] INFO: Processing task `gradient` [2024-03-15 09:30:43,745] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:43,871] 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 [2024-03-15 09:30:43,907] INFO: 1 new tasks have been issued. [2024-03-15 09:30:43,908] INFO: Processing task `misfit` [2024-03-15 09:30:43,932] INFO: Submitting job ... [2024-03-15 09:30:43,971] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:43,972] INFO: Some tasks of iteration #7 are still running. Please check again later. [2024-03-15 09:30:44,985] INFO: Processing task `misfit` [2024-03-15 09:30:45,095] 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. [2024-03-15 09:30:45,095] INFO: Model update accepted. [2024-03-15 09:30:45,095] INFO: 1 new tasks have been issued. [2024-03-15 09:30:45,096] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:45,113] INFO: Succesfully completed iteration #7. [2024-03-15 09:30:45,117] INFO: Adding new iteration #8. [2024-03-15 09:30:45,130] INFO: Resuming iteration #8. [2024-03-15 09:30:45,131] INFO: 1 new tasks have been issued. [2024-03-15 09:30:45,131] INFO: Processing task `gradient` [2024-03-15 09:30:45,195] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930197120_ca3f02113f@local [2024-03-15 09:30:45,236] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:45,237] INFO: Some tasks of iteration #8 are still running. Please check again later. [2024-03-15 09:30:46,240] INFO: Processing task `gradient` [2024-03-15 09:30:46,287] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:30:46,409] 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 [2024-03-15 09:30:46,451] INFO: 1 new tasks have been issued. [2024-03-15 09:30:46,451] INFO: Processing task `misfit` [2024-03-15 09:30:46,474] INFO: Submitting job ... [2024-03-15 09:30:46,517] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:46,518] INFO: Some tasks of iteration #8 are still running. Please check again later. [2024-03-15 09:30:47,530] INFO: Processing task `misfit` [2024-03-15 09:30:47,644] 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. [2024-03-15 09:30:47,644] INFO: Model update accepted. [2024-03-15 09:30:47,645] INFO: 1 new tasks have been issued. [2024-03-15 09:30:47,645] INFO: Processing task `finalize_iteration` [2024-03-15 09:30:47,660] INFO: Succesfully completed iteration #8. [2024-03-15 09:30:47,664] INFO: Adding new iteration #9. [2024-03-15 09:30:47,678] INFO: Resuming iteration #9. [2024-03-15 09:30:47,679] 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, 2e-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.unstructured_mesh.UnstructuredMesh at 0x7fa932013c50>
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)
[2024-03-15 09:30:49,139] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930142542_4e9fbe5c2e@local
[2024-03-15 09:30:49,690] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930693053_2887145696@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,
)
[2024-03-15 09:30:50,461] INFO: Adding new iteration #0. [2024-03-15 09:30:50,468] INFO: Resuming iteration #0. [2024-03-15 09:30:50,469] INFO: 1 new tasks have been issued. [2024-03-15 09:30:50,469] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:30:50,483] 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'] [2024-03-15 09:30:50,492] INFO: Submitting job ... [2024-03-15 09:30:50,535] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:50,536] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:30:55,537] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:30:55,705] INFO: Submitting job ... Uploading 1 files... 🚀 Submitted job_2403150930707464_6c8aeb8fda@local [2024-03-15 09:30:55,746] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:30:55,747] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:31:00,748] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:31:00,816] INFO: 1 events have already been submitted. They will not be submitted again. [2024-03-15 09:31:00,939] INFO: Iteration 0: Number of events: 1 chi = 1.8063817169917176e-11 ||g|| = 3.4633490526471955e-13 pred = --- ared = --- norm_update = --- tr_radius = --- [2024-03-15 09:31:00,942] INFO: 1 new tasks have been issued. [2024-03-15 09:31:00,942] INFO: Processing task `misfit` [2024-03-15 09:31:00,967] INFO: Submitting job ... [2024-03-15 09:31:01,008] INFO: Launched simulations for 1 events. Please check again to see if they are finished. [2024-03-15 09:31:01,008] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:31:06,020] INFO: Processing task `misfit` [2024-03-15 09:31:06,119] 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. [2024-03-15 09:31:06,119] INFO: Model update accepted. [2024-03-15 09:31:06,120] INFO: 1 new tasks have been issued. [2024-03-15 09:31:06,120] INFO: Processing task `finalize_iteration` [2024-03-15 09:31:06,131] INFO: Succesfully completed iteration #0. [2024-03-15 09:31:06,132] INFO: Adding new iteration #1.
p.simulations.get_mesh(p.inversions.get_simulation_name("inversion_two", 1))
<salvus.mesh.unstructured_mesh.UnstructuredMesh at 0x7fa946184dd0>