2D Elastic FWI on Marmousi with Torch¶
Source file:
examples/FWI/2d/elastic/torch/fwi_marmousi.py
What This Example Does¶
This example runs 2D elastic full-waveform inversion on the Marmousi model with one script that supports two propagator backends:
eager: pure PyTorch propagation throughPropTorch(..., backend="eager")cuda: compiled CUDA propagation throughPropTorch(..., backend="cuda")
The script:
- loads the Marmousi true and smooth
vpmodels - derives
vsfromvp / 1.732and uses constantrho - generates observed elastic shot gathers from the true model
- inverts
vpandvsfrom the smooth starting model
Main Components¶
The solver is built from:
equation:Elastic(...)propagator:PropTorch(...)wave: a Ricker wavelet injected intosxxandszzsources: regularly sampled surface sourcesreceivers: regularly sampled surface receiversmodels:vp,vs, andrho
Prepare the Marmousi Model Files¶
This example reads the prepared Marmousi vp files and derives vs and rho
inside the script:
examples/models/marmousi/true.npyexamples/models/marmousi/smooth.npy
Generate the files before running the example:
python3 examples/models/marmousi/download_marmousi.py --extract
python3 examples/models/marmousi/extract_model_segy.py
python3 examples/models/marmousi/convert_segy_to_npy.py
python3 examples/models/marmousi/prepare_fwi_models.py \
--input examples/models/marmousi/npy/vp_1p25m.npy \
--source-dh 1.25 \
--target-dh 25.0 \
--radii 8,8 \
--passes 3
Backend Selection¶
Run the example with:
python3 examples/FWI/2d/elastic/torch/fwi_marmousi.py --backend eager
python3 examples/FWI/2d/elastic/torch/fwi_marmousi.py --backend cuda
Key Configuration¶
Shared configuration comes from examples/_shared/configure_marmousi.py and includes:
nt=2500,dt=0.002dh=25.0spatial_order=8abcn=20src_step=4,rec_step=2source_encoding=Truebatchsize=8
The script uses:
source_type=["sxx", "szz"]receiver_type=["vx", "vz"]- separate learning rates for
vp,vs, andrho
Geometry¶
The final array shapes are:
sources:(nshots, 2)receivers:(nshots, nreceivers, 2)
Outputs¶
The script saves:
ricker.pngobserved_data.pngloss.pngepoch_XXXX.png
Each backend writes into its own output directory:
elastic_fwi_marmousi_torch
elastic_fwi_marmousi_cuda
Example Figures¶
The following figures come from a completed CUDA run of the 2D elastic Marmousi example.
observed_data.png: observed vx and vz shot gathers generated from the
true model.

loss.png: the inversion loss curve across optimization steps.

epoch_0100.png: the saved progress panel at the final shown epoch, including
the true models, current inverted models, and current gradients.

Notes¶
- the Marmousi elastic example defaults to source encoding
cudamode requires a CUDA-capable PyTorch environment and compiled bindings