Skip to content

Commit

Permalink
added conv; medium.mgrid => medium.grid
Browse files Browse the repository at this point in the history
  • Loading branch information
pawbz committed May 24, 2023
1 parent 306532e commit c9fffdc
Show file tree
Hide file tree
Showing 46 changed files with 1,203 additions and 306 deletions.
49 changes: 48 additions & 1 deletion Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.9.0"
manifest_format = "2.0"
project_hash = "70620fb55966412ae45f1ea0867b038884dc39e2"
project_hash = "359e2eba87a07b0630d851b80dd2ce868a3f946c"

[[deps.ASL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand All @@ -20,6 +20,12 @@ weakdeps = ["ChainRulesCore"]
[deps.AbstractFFTs.extensions]
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"

[[deps.AbstractNFFTs]]
deps = ["LinearAlgebra", "Printf"]
git-tree-sha1 = "292e21e99dedb8621c15f185b8fdb4260bb3c429"
uuid = "7f219486-4aa7-41d6-80a7-e08ef20ceed7"
version = "0.8.2"

[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "8eaf9f1b4921132a4cff3f36a1d9ba923b14a481"
Expand Down Expand Up @@ -145,6 +151,12 @@ git-tree-sha1 = "aebf55e6d7795e02ca500a689d326ac979aaf89e"
uuid = "9718e550-a3fa-408a-8086-8db961cd8217"
version = "0.1.1"

[[deps.BasicInterpolators]]
deps = ["LinearAlgebra", "Memoize", "Random"]
git-tree-sha1 = "3f7be532673fc4a22825e7884e9e0e876236b12a"
uuid = "26cce99e-4866-4b6d-ab74-862489e035e0"
version = "0.7.1"

[[deps.BenchmarkTools]]
deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"]
git-tree-sha1 = "d9a9701b899b30332bbcb3e1679c41cce81fb0e8"
Expand Down Expand Up @@ -581,6 +593,12 @@ weakdeps = ["StaticArrays"]
[deps.ForwardDiff.extensions]
ForwardDiffStaticArraysExt = "StaticArrays"

[[deps.FourierTools]]
deps = ["ChainRulesCore", "FFTW", "IndexFunArrays", "LinearAlgebra", "NDTools", "NFFT", "PaddedViews", "Reexport", "ShiftedArrays"]
git-tree-sha1 = "8967a9d259ab1c50e3b3abc6b77d3e3d829d2e6d"
uuid = "b18b359b-aebc-45ac-a139-9c0ccbb2871e"
version = "0.4.2"

[[deps.FreeType2_jll]]
deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "87eb71354d8ec1a96d4a7636bd57a7347dde3ef9"
Expand Down Expand Up @@ -768,6 +786,12 @@ git-tree-sha1 = "c3630289f3591711f5add6ef1347bc20f1bb8d27"
uuid = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
version = "0.7.4"

[[deps.IndexFunArrays]]
deps = ["ChainRulesCore", "LinearAlgebra"]
git-tree-sha1 = "c7e4b47fa1cd2761794b96b3e6ac1d7a0c2133aa"
uuid = "613c443e-d742-454e-bfc6-1d7f8dd76566"
version = "0.2.5"

[[deps.InitialValues]]
git-tree-sha1 = "4da0f88e9a39111c2fa3add390ab15f3a44f3ca3"
uuid = "22cec73e-a1b8-11e9-2c92-598750a2cf9c"
Expand Down Expand Up @@ -1168,6 +1192,12 @@ git-tree-sha1 = "75a54abd10709c01f1b86b84ec225d26e840ed58"
uuid = "e89f7d12-3494-54d1-8411-f7d8b9ae1f27"
version = "0.5.0"

[[deps.Memoize]]
deps = ["MacroTools"]
git-tree-sha1 = "2b1dfcba103de714d31c033b5dacc2e4a12c7caa"
uuid = "c03570c3-d221-55d1-a50c-7939bbd78826"
version = "0.4.4"

[[deps.MicroCollections]]
deps = ["BangBang", "InitialValues", "Setfield"]
git-tree-sha1 = "629afd7d10dbc6935ec59b32daeb33bc4460a42e"
Expand Down Expand Up @@ -1205,6 +1235,18 @@ git-tree-sha1 = "964cb1a7069723727025ae295408747a0b36a854"
uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
version = "1.3.0"

[[deps.NDTools]]
deps = ["LinearAlgebra", "OffsetArrays", "PaddedViews", "Random", "Statistics"]
git-tree-sha1 = "10e35b25261dfd361045e16afa9db5b14a4c1184"
uuid = "98581153-e998-4eef-8d0d-5ec2c052313d"
version = "0.5.2"

[[deps.NFFT]]
deps = ["AbstractNFFTs", "BasicInterpolators", "Distributed", "FFTW", "FLoops", "LinearAlgebra", "Printf", "Random", "Reexport", "SnoopPrecompile", "SparseArrays", "SpecialFunctions"]
git-tree-sha1 = "93a5f32dd6cf09456b0b81afcb8fc29f06535ffd"
uuid = "efe261a4-0d2b-5849-be55-fc731d526b0d"
version = "0.13.3"

[[deps.NLSolversBase]]
deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"]
git-tree-sha1 = "a0b464d183da839699f4c79e7606d9d186ec172c"
Expand Down Expand Up @@ -1650,6 +1692,11 @@ version = "1.1.1"
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[deps.ShiftedArrays]]
git-tree-sha1 = "503688b59397b3307443af35cd953a13e8005c16"
uuid = "1277b4bf-5013-50f5-be3d-901d8477a67a"
version = "2.0.0"

[[deps.ShowCases]]
git-tree-sha1 = "7f534ad62ab2bd48591bdeac81994ea8c445e4a5"
uuid = "605ecd9f-84a6-4c9e-81e2-4798472b76a3"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
FourierTools = "b18b359b-aebc-45ac-a139-9c0ccbb2871e"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/born.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ plot(medium)
medium0=Medium(:acou_homo2D, 40)

# ╔═╡ 0f2d0963-b91a-4b1c-92d5-31f077e28516
ageom = AGeom(medium.mgrid, :surf, SSrcs(1), Recs(100));
ageom = AGeom(medium.grid, :surf, SSrcs(1), Recs(100));

# ╔═╡ d72f7155-b766-46ad-a3af-8390b3cfa1f0
plot(medium0, ageom)
Expand Down Expand Up @@ -239,7 +239,7 @@ g2 = get_gradient(xs)
g1[1] ./g2

# ╔═╡ 0f8685fc-7341-4cd5-a7cb-bf6b5b5d5ab9
nz, nx = length.(pa_acoustic.c.exmedium.mgrid)
nz, nx = length.(pa_acoustic.c.exmedium.grid)

# ╔═╡ 158ef323-b376-46d1-aea8-c26061ee5b56
heatmap(reshape(xtrue[1:nx*nz], nz, nx))
Expand Down
2 changes: 1 addition & 1 deletion notebooks/gallery.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ medium1 = AcousticMedium(Homogeneous(), 5.0)
medium2 = ElasticMedium(Homogeneous(), 5.0)

# ╔═╡ eb5fcc15-c076-4d0f-8f53-b5ba4d826063
medium1.mgrid
medium1.grid

# ╔═╡ d77093ed-e18b-4d4d-b3b4-2011fe0fa465
plot(medium1)
Expand Down
36 changes: 32 additions & 4 deletions notebooks/gradient_finitediff_testing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ end
# ╔═╡ bd68d9b1-633b-4c9b-b759-791581714306
using Statistics, LossFunctions, LinearAlgebra, MLUtils, FiniteDifferences, SparseArrays

# ╔═╡ 1c595ede-34a8-41f3-8067-6fb0b864f7fa
using FourierTools

# ╔═╡ bbfa8c8e-1ef5-459b-b5f5-edb15ff38fa8
TableOfContents()

Expand Down Expand Up @@ -69,8 +72,23 @@ mpara
# ╔═╡ 43fb3211-9ffc-4ea5-a459-539cf55ba009
# pa_inv = SeisInvExpt(pa_mod, dobs, [N, N], [mpara])

# ╔═╡ 5297741a-60dc-45b8-8334-bbbc9a2a96c7
aa=randn(5,4)

# ╔═╡ 802fb101-09f6-44b6-9a46-4fa94724b6f1
vv=[1, 0, 0, 0]

# ╔═╡ 110ee9ed-6e28-4b15-8102-a75e42d26d07
stack([randn(3), randn(3)], dims=2)

# ╔═╡ ef26bf0c-cc19-474e-bcf9-9007547bcc56
pp = plan_conv(randn(3,10), randn(3), 1) |> typeof

# ╔═╡ 11bd4ea4-f4de-4118-b354-02f83cebf47d
conv(aa, vv)

# ╔═╡ 8e9a92dc-dc58-40d7-9a38-df08852a33a0
typeof(pa_mod.c.medium.mgrid)
typeof(pa_mod.c.medium.grid)

# ╔═╡ 9706aa59-0286-43cf-bdb7-a3d040e0e2bc

Expand All @@ -86,7 +104,10 @@ begin
end

# ╔═╡ 26c9f7a1-f18b-4fe3-a607-ad1f6a904bb8
pa_inv = SeisInvExpt(pa_mod, dobs, [range(-100,100,length=N), range(-100,100,length=N)], [mpara])
pa_inv, _ = SeisInvExpt(pa_mod, dobs, [range(-100,100,length=N), range(-100,100,length=N)], [mpara])

# ╔═╡ e6339233-2d9f-45d0-bcb1-2320a4ad28fc
dobs

# ╔═╡ b99b6e7a-d037-4c6f-8043-fdb49102503b
pa_true.c.srcwav[1][1].grid
Expand Down Expand Up @@ -128,7 +149,7 @@ heatmap(Array(deepcopy(pa_mod.c.gradients[mpara])));
mul!

# ╔═╡ 839cf146-639c-4d13-9470-d25882837169
# prod(step.(pa_true.c.medium.mgrid)) #
# prod(step.(pa_true.c.medium.grid)) #
pa_true.c.srcwav[1][1].grid |> step |> abs2

# ╔═╡ d3b4cd08-eca1-4fac-915f-a64dc29b870f
Expand Down Expand Up @@ -177,7 +198,7 @@ end
Js(GeoPhyInv.Data.Array(xs))

# ╔═╡ c6626e0f-4bf1-4e29-a0c3-1e7f23805f61
gm = grad(central_fdm(2, 1, factor=1e7), Js, xs)[1]
gm = grad(central_fdm(2, 1, factor=1e8), Js, xs)[1]

# ╔═╡ 8ec00fb7-fe18-4741-b987-813ec97d73fe
heatmap(Array(reshape(gm, N, N)), c=:seismic)
Expand Down Expand Up @@ -217,6 +238,13 @@ step(pa_mod.c.srcwav[1][1].grid) ./ pa_mod.c.medium[:rho]
# ╠═5582110f-327c-419a-8759-ca11844c0c96
# ╠═26c9f7a1-f18b-4fe3-a607-ad1f6a904bb8
# ╠═43fb3211-9ffc-4ea5-a459-539cf55ba009
# ╠═1c595ede-34a8-41f3-8067-6fb0b864f7fa
# ╠═5297741a-60dc-45b8-8334-bbbc9a2a96c7
# ╠═802fb101-09f6-44b6-9a46-4fa94724b6f1
# ╠═110ee9ed-6e28-4b15-8102-a75e42d26d07
# ╠═ef26bf0c-cc19-474e-bcf9-9007547bcc56
# ╠═11bd4ea4-f4de-4118-b354-02f83cebf47d
# ╠═e6339233-2d9f-45d0-bcb1-2320a4ad28fc
# ╠═8e9a92dc-dc58-40d7-9a38-df08852a33a0
# ╠═9706aa59-0286-43cf-bdb7-a3d040e0e2bc
# ╠═247896d7-6c39-4bf6-856b-7afc6f4d6655
Expand Down
2 changes: 1 addition & 1 deletion notebooks/grid_visualize.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.5
# v0.19.21

using Markdown
using InteractiveUtils
Expand Down
65 changes: 18 additions & 47 deletions notebooks/marmousi-acoustic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,38 @@
using Markdown
using InteractiveUtils

# 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).
macro bind(def, element)
quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
end

# ╔═╡ 19ca0fd6-a97e-47e2-a950-d7e8a6ba8b88
# ╔═╡ 28f0f643-aa80-4f92-a0f1-10cf88be3383
begin
import Pkg
Pkg.add("PlutoLinks")
Pkg.add("PlutoUI")
Pkg.add("PlutoTest")
Pkg.add("Plots")
Pkg.add("CUDA")
using PlutoLinks: @revise
using PlutoUI, PlutoTest, Plots
using PlutoUI, PlutoTest, Plots, CUDA
end

# ╔═╡ 00333dab-a753-4073-ae6a-36aee85b93c9
TableOfContents()

# ╔═╡ 7ceb8cb6-5976-4efd-aed9-d54772968de2
@bind reload_geophyinv Button("using GeoPhyInv")

# ╔═╡ e2ddc23f-99f8-405e-8846-dd074e306630
# ╔═╡ ca53ee61-98ad-436a-bd10-14290c0ca01e
begin
reload_geophyinv
Pkg.activate(Base.current_project())
Pkg.instantiate()
@revise using GeoPhyInv
end

# ╔═╡ d61191f0-4bc4-466b-995c-96a137056ccb
begin
reload_geophyinv
GeoPhyInv.@init_parallel_stencil(2, false, Float32, 2)
using Statistics
end
# ╔═╡ 58ec85a4-792a-4294-9147-e3c9637e466e
@revise using GeoPhyInv

# ╔═╡ 2520f1ee-a102-4b08-9ebd-1b9668346569
TableOfContents()

# ╔═╡ 3b47fd1e-3d24-4346-884d-4e0c0db228cf
md"""
In order to install `GeoPhyInv` enter these package manager commands in the REPL.
```julia
using Pkg
Pkg.add(PackageSpec(name="GeoPhyInv",url="https://github.com/pawbz/GeoPhyInv.jl.git"))
```
It is necessary to configure GeoPhyInv with a macro `@init_parallel_stencil` before using it. If you need to change this configuration, the julia kernel must be restarted.
```julia
using GeoPhyInv; @init_parallel_stencil(⋯)
```
"""
# ╔═╡ df39c4c2-3be8-4675-ad8d-1262c280bbc3
Pkg.activate

# ╔═╡ 6d1c8a37-b872-4041-8544-a3437ebe01a1
marm=Medium(:marmousi2)
marm=ElasticMedium(Marmousi2())

# ╔═╡ b4ba72d6-0916-4738-8d25-c807e636ce2b
ageom = AGeom(marm.mgrid, :surf, SSrcs(1), Recs(100));
ageom = AGeom(marm.grid, :surf, SSrcs(1), Recs(100));

# ╔═╡ 0c8c94c7-c2aa-457f-9ab2-2f80935b1534
plot(marm, ageom, fields=[:vp, :rho])
Expand Down Expand Up @@ -97,12 +69,11 @@ update!(pa_acoustic)
plot(pa_acoustic[:data], 99.9)

# ╔═╡ Cell order:
# ╟─00333dab-a753-4073-ae6a-36aee85b93c9
# ╟─7ceb8cb6-5976-4efd-aed9-d54772968de2
# ╟─3b47fd1e-3d24-4346-884d-4e0c0db228cf
# ╟─19ca0fd6-a97e-47e2-a950-d7e8a6ba8b88
# ╟─e2ddc23f-99f8-405e-8846-dd074e306630
# ╠═d61191f0-4bc4-466b-995c-96a137056ccb
# ╠═2520f1ee-a102-4b08-9ebd-1b9668346569
# ╠═28f0f643-aa80-4f92-a0f1-10cf88be3383
# ╠═df39c4c2-3be8-4675-ad8d-1262c280bbc3
# ╠═ca53ee61-98ad-436a-bd10-14290c0ca01e
# ╠═58ec85a4-792a-4294-9147-e3c9637e466e
# ╠═6d1c8a37-b872-4041-8544-a3437ebe01a1
# ╠═b4ba72d6-0916-4738-8d25-c807e636ce2b
# ╠═0c8c94c7-c2aa-457f-9ab2-2f80935b1534
Expand Down
2 changes: 1 addition & 1 deletion notebooks/reusing-seisforwexpt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ medium = ElasticMedium(Homogeneous(), 5)

# ╔═╡ ded21d43-99d6-453b-a858-e32f3f82e605
# surface seismic acquisition with 3 supersources and 100 receivers
ageom = AGeom(medium.mgrid, :surf, SSrcs(1), Recs(100))
ageom = AGeom(medium.grid, :surf, SSrcs(1), Recs(100))

# ╔═╡ a47b1e5d-a08c-4750-b1f3-f8a62225a19f
# lets choose a time grid
Expand Down
Loading

0 comments on commit c9fffdc

Please sign in to comment.