11# ## A Pluto.jl notebook ###
2- # v0.20.4
2+ # v0.20.13
33
44# > [frontmatter]
55# > title = "Born Approximation"
@@ -13,7 +13,7 @@ using InteractiveUtils
1313# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
1414macro bind (def, element)
1515 # ! format: off
16- quote
16+ return quote
1717 local iv = try Base. loaded_modules[Base. PkgId (Base. UUID (" 6e696c72-6542-2067-7265-42206c756150" ), " AbstractPlutoDingetjes" )]. Bonds. initial_value catch ; b -> missing ; end
1818 local el = $ (esc (element))
1919 global $ (esc (def)) = Core. applicable (Base. get, el) ? Base. get (el) : iv (el)
@@ -31,11 +31,11 @@ begin
3131 using PlutoPlotly
3232 using PlutoUI
3333 using PlutoTeachingTools
34- using SpecialFunctions
3534 using Einsum
36- using Tullio
3735 using MLUtils
3836 using PlutoLinks, PlutoHooks
37+ using SpecialFunctions
38+ using Tullio
3939end
4040
4141# ╔═╡ c0e6e258-7fcb-4bd8-9931-be0203c1adc9
@@ -344,10 +344,10 @@ plot(scatter(x=freqgrid, y=Fsource), Layout(width=400, height=200, title="Source
344344begin
345345 nxUI = 200
346346 nzUI = 100
347- δxUI = 4.0 # spatial sampling interval
348- xgridUI = range (0 , step= δxUI, length= nxUI)
349- zgridUI = range (0 , step= δxUI, length= nzUI)
350- end
347+ δxUI = 4f0 # spatial sampling interval
348+ xgridUI = Float32 .( collect ( range (0.0 , step= δxUI, length= nxUI)) )
349+ zgridUI = Float32 .( collect ( range (0 , step= δxUI, length= nzUI)) )
350+ end ;
351351
352352# ╔═╡ acba3f10-975b-423d-9ab8-ead6d9f9774b
353353begin
@@ -362,9 +362,9 @@ paUI = (; tgrid, vp0, rho0, freqgrid, kgrid, Fsource, xgrid=xgridUI, zgrid=zgrid
362362
363363# ╔═╡ 33a221fe-ab5d-4a41-80bd-105746f949fb
364364begin
365- δxplot = 11.0
366- xgrid = range (first (xgridUI), stop= last (xgridUI), step= δxplot)
367- zgrid = range (first (xgridUI), stop= last (zgridUI), step= δxplot)
365+ δxplot = 11f0
366+ xgrid = Float32 .( collect ( range (first (xgridUI), stop= last (xgridUI), step= δxplot)) )
367+ zgrid = Float32 .( collect ( range (first (xgridUI), stop= last (zgridUI), step= δxplot)) )
368368 nxgrid = length (xgrid)
369369 nzgrid = length (zgrid)
370370end ;
@@ -388,16 +388,10 @@ function get_xlocation(I, δ)
388388end
389389
390390# ╔═╡ 453fcb4f-1cc6-4c57-9bec-2e1d7c76244a
391- function get_zlocation (I, δ)
391+ function get_zlocation (I, δ, nzUI )
392392 Float32 .((nzUI - I[2 ] + 1 ) * δ)
393393end
394394
395- # ╔═╡ baeaecf7-ad9c-42d5-8946-3c336d28fb8b
396- slocs_x = 0.0 # source location(s)
397-
398- # ╔═╡ 049206ed-3f9e-45c6-9280-2aa80636a630
399- slocs_z = - 100.0
400-
401395# ╔═╡ 2ac0ea94-aa5d-43da-a240-db4a57dda204
402396nr = 50 ;
403397
@@ -411,12 +405,26 @@ The seismic source is located near the surface at (x, z)=(0,0),
411405and $(length(rUI)) receivers on the surface (z=0).
412406"""
413407
408+ # ╔═╡ 97b3eaf7-c528-4693-8b89-bd33bdd9184c
409+ ns = 5 ;
410+
411+ # ╔═╡ ffd19316-d2ba-4bec-abde-19cf05994ecf
412+ md " Select Sources $(@bind sUI MultiCheckBox(1:ns, select_all=true, default=collect(1:ns)))"
413+
414414# ╔═╡ 4389a492-2096-4e2a-b05f-91e9820e15a4
415415rlocs_x = [rx for rx in range (0 , stop= last (xgridUI), length= nr)] # receiver locations
416416
417+ # ╔═╡ 912a031d-ebed-44b4-a350-2c72fb7623de
418+ # source x location(s)
419+ slocs_x = [sx for sx in range (0 , stop= last (xgridUI), length= ns)] # source locations
420+
417421# ╔═╡ 55631892-919f-4950-acfe-d08bf0a691fc
418422rlocs_z = fill (- 10.0 , length (rlocs_x));
419423
424+ # ╔═╡ 0c74076a-a3a1-4b9b-9592-0e67077d2f83
425+ # source z location(s)
426+ slocs_z = fill (- 20.0 , length (slocs_x));
427+
420428# ╔═╡ 5ffccf58-7f01-49fc-a6c8-8e284a05b2dc
421429acq = map ((; rlocs_x, rlocs_z, slocs_x, slocs_z)) do x
422430 Float32 .(x)
463471md " ### Modeling"
464472
465473# ╔═╡ 7b46eac4-193a-4c25-99b3-b25009ba1260
466- function get_forward_operator_with_scatterer_locations (pa, acq, scatterer_locations)
474+ function get_forward_operator_with_scatterer_locations (pa, acq, scatterer_locations, δxUI, nzUI )
467475 if (isempty (scatterer_locations))
468476 return 0.0
469477 else
@@ -475,24 +483,24 @@ function get_forward_operator_with_scatterer_locations(pa, acq, scatterer_locati
475483 get_xlocation (l, δxUI)
476484 end
477485 scat_z = map (scatterer_locations) do l
478- get_zlocation (l, δxUI)
486+ get_zlocation (l, δxUI, nzUI )
479487 end
480488 nr = length (acq. rlocs_x)
481489 nω = length (pa. freqgrid)
482490 @tullio F[iω] := freqgrid[iω] * freqgrid[iω] * Fsource[iω] * 4.0 * pi * pi
483- @tullio G[iω, ir, iS] := G0 (scat_x[iS], scat_z[iS], acq. slocs_x, acq. slocs_z, kgrid[iω], rho0) * G0 (acq. rlocs_x[ir], acq. rlocs_z[ir], scat_x[ix], scat_z[iz], kgrid[iω], rho0) * F[iω]
491+ @tullio G[iω, ir, iS] := G0 (scat_x[iS], scat_z[iS], acq. slocs_x[ 1 ] , acq. slocs_z[ 1 ] , kgrid[iω], rho0) * G0 (acq. rlocs_x[ir], acq. rlocs_z[ir], scat_x[ix], scat_z[iz], kgrid[iω], rho0) * F[iω]
484492 # remove zero frequencies
485493 @tullio G[1 , i, j] = complex (0.0 )
486494 return reshape (G, nr * nω, :)
487495end
488496
489497# ╔═╡ 8218676f-0d09-4beb-bd17-8ae5b692c56d
490498forward_grid = @use_memo ([reset_anim]) do
491- get_forward_operator_with_scatterer_locations (pagrid, acqgrid, slowness_pert_draw_input)
499+ get_forward_operator_with_scatterer_locations (pagrid, acqgrid, slowness_pert_draw_input, δxUI, nzUI )
492500end ;
493501
494502# ╔═╡ 173adc88-5366-49e7-a1af-6478404e082e
495- function get_forward_operator (pa, acq)
503+ function get_forward_operator (pa, acq, sloc_x, sloc_z )
496504 (; xgrid, zgrid, freqgrid, kgrid, Fsource, vp0, rho0) = pa
497505
498506 X = Float32 .(collect (xgrid))
@@ -502,17 +510,19 @@ function get_forward_operator(pa, acq)
502510 nr = length (acq. rlocs_x)
503511 nω = length (pa. freqgrid)
504512 @tullio F[iω] := freqgrid[iω] * freqgrid[iω] * Fsource[iω] * 4.0 * pi * pi
505- @tullio G[iω, ir, iz, ix] := G0 (X[ix], Z[iz], acq . slocs_x, acq . slocs_z , kgrid[iω], rho0) * G0 (acq. rlocs_x[ir], acq. rlocs_z[ir], X[ix], Z[iz], kgrid[iω], rho0) * F[iω]
513+ @tullio G[iω, ir, iz, ix] := G0 (X[ix], Z[iz], sloc_x, sloc_z , kgrid[iω], rho0) * G0 (acq. rlocs_x[ir], acq. rlocs_z[ir], X[ix], Z[iz], kgrid[iω], rho0) * F[iω]
506514 # remove zero frequencies
507515 @tullio G[1 , i, j, k] = complex (0.0 )
508516 return reshape (G, nr * nω, nx * nz)
509517end
510518
511519# ╔═╡ 9ce0b88a-4e39-4c95-83fb-1758ee661b45
512- forward_UI = get_forward_operator (paUI, acq);
520+ forward_UI = map (slocs_x, slocs_z) do sx, sz
521+ get_forward_operator (paUI, acq, sx, sz);
522+ end
513523
514524# ╔═╡ e5a6e125-c700-4471-9781-abbd0b1c49c7
515- function get_reference_wavefield (pa, acq)
525+ function get_reference_wavefield (pa, acq, tgrid )
516526 (; xgrid, zgrid, freqgrid, kgrid, Fsource, vp0, rho0) = pa
517527 @tullio D[iω, ir, is] := G0 (acq. rlocs_x[ir], acq. rlocs_z[ir], acq. slocs_x[is], acq. slocs_z[is], kgrid[iω], rho0) * Fsource[iω]
518528 # remove zero frequencies
@@ -522,10 +532,10 @@ function get_reference_wavefield(pa, acq)
522532end
523533
524534# ╔═╡ 887cc848-e97e-451d-8bb4-3f0eebb20723
525- d = get_reference_wavefield (paUI, acq);
535+ d = get_reference_wavefield (paUI, acq, tgrid );
526536
527537# ╔═╡ 9f05fce9-9c03-49b4-abeb-70977dcb9892
528- dgrid = reshape (get_reference_wavefield (pagrid, acqgrid) , :, nzgrid, nxgrid);
538+ dgrid = reshape (get_reference_wavefield (pagrid, acqgrid, tgrid)[:, :, 1 ] , :, nzgrid, nxgrid);
529539
530540# ╔═╡ 04669a0d-9bb8-4106-ab87-7afd3ac86597
531541function get_scattered_wavefield (slowness, G, acq, pa)
540550
541551# ╔═╡ 68d92a09-8fc6-485c-aeac-c392a21951e4
542552begin
543- δd = get_scattered_wavefield (slowness_grid_input, forward_UI, acq, paUI)
544- δd[:, filter (x -> x ∉ rUI, 1 : nr)] .= 0.0f0
553+ δd = map (forward_UI) do Gmat
554+ d = get_scattered_wavefield (slowness_grid_input, Gmat, acq, paUI)
555+ d[:, filter (x -> x ∉ rUI, 1 : nr)] .= 0.0f0
556+ d
557+ end
545558end ;
546559
547560# ╔═╡ 2bf0042b-f9b3-4ea3-b3d8-46d89a1ce2fe
@@ -564,14 +577,19 @@ function get_migration_image(δd, G, acq, pa)
564577end
565578
566579# ╔═╡ d8fc5b82-84a7-4f86-88f0-55b09b355a25
567- image = get_migration_image (δd, forward_UI, acq, paUI);
580+ images = map (forward_UI, δd) do Gmat, d
581+ get_migration_image (d, Gmat, acq, paUI)
582+ end ;
583+
584+ # ╔═╡ 98d344f7-3ee2-42b7-aefe-d88604abdc8b
585+ image = sum (images[sUI]);
568586
569587# ╔═╡ 3c23a484-0b9a-4044-bcec-fec447509991
570588md " ### Plots"
571589
572590# ╔═╡ a6f59c95-2271-4f2f-894f-b574401cd545
573591function plot_data (d, δd, d1max)
574- fig = Plot (Layout (title= " Measured Wavefield" , yaxis_autorange= " reversed" , height= 400 , width= 500 , yaxis_title= " time [s]" , Subplots (shared_xaxes= true , shared_yaxes= true , rows= 1 , cols= 2 , subplot_titles= [" Reference" " Scattered" ], x_title= " # Receiver" )))
592+ fig = Plot (Layout (title= " Measured Wavefield (Source # $( first (sUI)) ) " , yaxis_autorange= " reversed" , height= 400 , width= 500 , yaxis_title= " time [s]" , Subplots (shared_xaxes= true , shared_yaxes= true , rows= 1 , cols= 2 , subplot_titles= [" Reference" " Scattered" ], x_title= " # Receiver" )))
575593
576594
577595 add_trace! (fig, heatmap (y= tgrid, z= d, zmin= - d1max, zmax= d1max, showscale= false , colorscale= " jet" ), row= 1 , col= 1 )
@@ -582,7 +600,7 @@ function plot_data(d, δd, d1max)
582600end
583601
584602# ╔═╡ 56d75f42-6a38-4e79-a0a9-e9f005996ac6
585- plot_data (d[:, :, 1 ], δd[:, :, 1 ], maximum (abs,d[:,:,1 ])/ 2 )
603+ plot_data (d[:, :, first (sUI) ], δd[:, :, 1 ][ first (sUI)] , maximum (abs,d[:,:,1 ][ first (sUI) ])/ 2 )
586604
587605# ╔═╡ 44dfa401-7f1d-467f-99e9-beab9ec52427
588606function add_ageom! (fig, ageom, row= 1 , col= 1 )
@@ -616,7 +634,7 @@ plot_image(image)
616634# ╔═╡ 1c95eb36-adc8-44f1-867b-eb3521684eb9
617635function plot_animations (d1, d2, d1max)
618636
619- fig = Plot (Layout (title= " Wavefield" , yaxis_autorange= " reversed" , xaxis= attr (range= extrema (xgridUI) .+ [- 20 , 20 ]),
637+ fig = Plot (Layout (title= " Wavefield (Source # $( first (sUI)) ) " , yaxis_autorange= " reversed" , xaxis= attr (range= extrema (xgridUI) .+ [- 20 , 20 ]),
620638 yaxis= attr (range= extrema (zgridUI) .+ [- 10 , 10 ]),
621639 height= 225 , width= 700 , yaxis_title= " Depth" , xaxis_title= " Distance" , Subplots (shared_xaxes= true , shared_yaxes= true , rows= 1 , cols= 2 , subplot_titles= [" Reference" " Scattered" ])))
622640 add_trace! (fig, heatmap (x= xgrid, y= zgrid, z= d1, zmin= - d1max, zmax= d1max, showscale= false , colorscale= " Greys" ), row= 1 , col= 1 )
@@ -687,7 +705,7 @@ Tullio = "~0.3.7"
687705PLUTO_MANIFEST_TOML_CONTENTS = """
688706# This file is machine-generated - editing it directly is not advised
689707
690- julia_version = "1.11.3 "
708+ julia_version = "1.11.6 "
691709manifest_format = "2.0"
692710project_hash = "f22ec49e2aaf38de5e39a3ab73387f41bea3dcad"
693711
@@ -1518,7 +1536,7 @@ version = "0.3.27+1"
15181536[[deps.OpenLibm_jll]]
15191537deps = ["Artifacts", "Libdl"]
15201538uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1521- version = "0.8.1+2 "
1539+ version = "0.8.5+0 "
15221540
15231541[[deps.OpenSpecFun_jll]]
15241542deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl"]
@@ -2100,8 +2118,9 @@ version = "17.4.0+2"
21002118# ╟─99d5ad02-2897-4f2c-9a80-a146f90e38dd
21012119# ╟─3d88f8c4-ba31-4d99-8966-3ddf617e5b5f
21022120# ╟─3786bd54-105a-46d7-8232-b93835b01129
2103- # ╟─56d75f42-6a38-4e79-a0a9-e9f005996ac6
2121+ # ╟─ffd19316-d2ba-4bec-abde-19cf05994ecf
21042122# ╟─6e74479f-96ce-4af7-ae7d-603fe32ba88f
2123+ # ╟─56d75f42-6a38-4e79-a0a9-e9f005996ac6
21052124# ╟─4972f23b-88a8-49d9-acad-75a65bdbe101
21062125# ╟─9d498284-f702-4f6b-aace-54743c7df206
21072126# ╟─cff433fb-e1c4-42ae-a310-db85f48d09e3
@@ -2153,6 +2172,7 @@ version = "17.4.0+2"
21532172# ╠═68d92a09-8fc6-485c-aeac-c392a21951e4
21542173# ╠═2bf0042b-f9b3-4ea3-b3d8-46d89a1ce2fe
21552174# ╠═d8fc5b82-84a7-4f86-88f0-55b09b355a25
2175+ # ╠═98d344f7-3ee2-42b7-aefe-d88604abdc8b
21562176# ╟─b48cf5ec-a033-46e3-aec8-da5864b2386a
21572177# ╠═8acbffaf-1811-4592-a2d1-a8f561242d85
21582178# ╠═094b0ad6-1ec0-407a-884f-7147d8a2ec9f
@@ -2172,11 +2192,12 @@ version = "17.4.0+2"
21722192# ╠═d856645d-39bc-4603-837f-3c39d9df64af
21732193# ╠═2aa9168a-cadb-4060-9eac-d93a1cf3bf0b
21742194# ╠═453fcb4f-1cc6-4c57-9bec-2e1d7c76244a
2175- # ╠═baeaecf7-ad9c-42d5-8946-3c336d28fb8b
2176- # ╠═049206ed-3f9e-45c6-9280-2aa80636a630
21772195# ╠═2ac0ea94-aa5d-43da-a240-db4a57dda204
2196+ # ╠═97b3eaf7-c528-4693-8b89-bd33bdd9184c
21782197# ╠═4389a492-2096-4e2a-b05f-91e9820e15a4
2198+ # ╠═912a031d-ebed-44b4-a350-2c72fb7623de
21792199# ╠═55631892-919f-4950-acfe-d08bf0a691fc
2200+ # ╠═0c74076a-a3a1-4b9b-9592-0e67077d2f83
21802201# ╠═5ffccf58-7f01-49fc-a6c8-8e284a05b2dc
21812202# ╠═3cf87a6e-d244-494b-8675-aaaaac6fbf00
21822203# ╟─9404b52d-c571-4e23-8dda-d20d10de0457
0 commit comments