Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Jan 8, 2024
1 parent 29f4b8a commit 3a1581a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 81 deletions.
64 changes: 0 additions & 64 deletions examples/Scalable_Angular_Spectrum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ end
# ╔═╡ aafab549-c977-48f4-9dba-9d693e439b44
using WaveOpticsPropagation, CUDA, IndexFunArrays, NDTools, ImageShow, FileIO, Zygote, Optim, Plots, PlutoUI, FourierTools, NDTools

# ╔═╡ fa7a9fad-978c-4ad1-b563-312d373762d9
using FiniteDifferences

# ╔═╡ 4aabd650-792c-407c-9590-e4960ac776d6
md"# Setup Environment and packages"

Expand Down Expand Up @@ -147,51 +144,6 @@ The Fresnel number is $(round((D_box)^2 / z_box / λ, digits=3))
# ╔═╡ 9e762dfc-4873-4fe3-b785-f6c4808417a6
simshow(Array(abs2.(U_box_p)), γ=0.13, cmap=:inferno)

# ╔═╡ 6f56e9aa-94c0-4276-ad5a-993c7e56f4f8
field = zeros(ComplexF64, (32, 32))

# ╔═╡ 646dd8d2-e882-4df3-ab86-58026142e4b4
field[14:16, 14:16] .= 1

# ╔═╡ 10efbf3e-d114-4360-b06a-f4d06c41b2ef
ss = ScalableAngularSpectrum(cis.(field), 10e-6, 633e-9, 100e-6)

# ╔═╡ 6c077e89-80ea-4e88-bb5c-c6dc4b0f3ad5
gg(x) = sum(abs2.(x .- ss(cis.(x))[1]))

# ╔═╡ 0f6a4efe-2412-423e-ab9f-49805edea0fa
out2 = FiniteDifferences.grad(central_fdm(5, 1), gg, field)[1]

# ╔═╡ 56919f31-0f57-479c-a02a-074e4c9cc5b8
out1 = gradient(gg, field)[1]

# ╔═╡ 904dec8e-2fbd-48fe-a19c-44a748cc597a
Zygote.refresh()

# ╔═╡ 8d6ea849-80f3-4070-a54b-7411478a64af
sum(out1)

# ╔═╡ 16f60370-3738-405a-97ae-7acd9723d540
out1 .+ cis(1) out2 .+ cis(1)

# ╔═╡ 792dd3ec-d6fd-45db-9717-2a99282c7c9a
simshow(out2)

# ╔═╡ 98f43db0-fa7c-4b63-bada-d4ee1329bd4d
simshow(out1)

# ╔═╡ 0f26ce9c-ba97-459a-856d-08ea20aef1c9
ifftshift(out1, out1)

# ╔═╡ 28852634-d347-4a35-afa8-73ea9529ef06
x = [1 2 3; 4.1 5 6; 7 8 9]

# ╔═╡ 6fa5a0d5-3c7c-45f4-aefc-e22430a5b080
ifftshift(x)

# ╔═╡ 83293c34-25bc-4605-aa0e-77c37c71b4e8
ifftshift(x, x)

# ╔═╡ Cell order:
# ╟─4aabd650-792c-407c-9590-e4960ac776d6
# ╠═1ea0729c-ad94-11ee-3b52-bb21d59e9509
Expand Down Expand Up @@ -228,19 +180,3 @@ ifftshift(x, x)
# ╠═38bc91ff-3188-4129-aa6b-2af458cf59b1
# ╠═2b11c87d-4746-4be6-81f6-f004d30beae4
# ╠═9e762dfc-4873-4fe3-b785-f6c4808417a6
# ╠═fa7a9fad-978c-4ad1-b563-312d373762d9
# ╠═6f56e9aa-94c0-4276-ad5a-993c7e56f4f8
# ╠═646dd8d2-e882-4df3-ab86-58026142e4b4
# ╠═10efbf3e-d114-4360-b06a-f4d06c41b2ef
# ╠═6c077e89-80ea-4e88-bb5c-c6dc4b0f3ad5
# ╠═0f6a4efe-2412-423e-ab9f-49805edea0fa
# ╠═56919f31-0f57-479c-a02a-074e4c9cc5b8
# ╠═904dec8e-2fbd-48fe-a19c-44a748cc597a
# ╠═8d6ea849-80f3-4070-a54b-7411478a64af
# ╠═16f60370-3738-405a-97ae-7acd9723d540
# ╠═792dd3ec-d6fd-45db-9717-2a99282c7c9a
# ╠═98f43db0-fa7c-4b63-bada-d4ee1329bd4d
# ╠═0f26ce9c-ba97-459a-856d-08ea20aef1c9
# ╠═28852634-d347-4a35-afa8-73ea9529ef06
# ╠═6fa5a0d5-3c7c-45f4-aefc-e22430a5b080
# ╠═83293c34-25bc-4605-aa0e-77c37c71b4e8
12 changes: 6 additions & 6 deletions examples/double_slit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ L = 100f-3
# ╔═╡ 9facb2bf-f279-41de-8858-81dac7a032b5
z = 1

# ╔═╡ e714ec1e-cceb-4e43-aa22-fa1f69d6c816
L_new

# ╔═╡ 3cde3fbe-9641-4ffd-9630-9c7bf167ec34
N = 256

Expand Down Expand Up @@ -91,17 +94,14 @@ W = x[1 + ΔW * 2 + 1] - x[1]
md"# Propagate with Fraunhofer Diffraction"

# ╔═╡ 7e797b20-77ee-4888-9b23-74bb2713912f
@time output, L_new = fraunhofer(slit, z, λ, L)

# ╔═╡ e714ec1e-cceb-4e43-aa22-fa1f69d6c816
L_new
@time output, t = fraunhofer(slit, z, λ, L)

# ╔═╡ 0c74a49c-e4de-4172-ac75-4c2692c505fb
# creating this function is more efficient!
efficient_fraunhofer = Fraunhofer(slit, z, λ, L);

# ╔═╡ 0e6f74f1-8723-4596-b754-973b253443a4
@time output2, t = efficient_fraunhofer(slit)
@time output2, t2 = efficient_fraunhofer(slit)

# ╔═╡ 5c0486d2-5fbd-4cd7-9fc5-583a8e188b2e
begin
Expand All @@ -119,7 +119,7 @@ md"# Compare to analytical solution"
I_analytical(x) = sinc(W * x / λ / z)^2 * cos* S * x / λ / z)^2

# ╔═╡ 42e1a449-0e5c-4d67-a90c-10a54f479c8a
xpos_out = WaveOpticsPropagation.fftpos(L_new, N, NDTools.CenterFT)
xpos_out = WaveOpticsPropagation.fftpos(t.L, N, NDTools.CenterFT)

# ╔═╡ 5d36ba4d-e9fe-4b1b-b45d-c82b598dfe7a
begin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.22
# v0.19.30

using Markdown
using InteractiveUtils
Expand All @@ -16,12 +16,14 @@ end

# ╔═╡ 97891d2b-facd-4f51-9774-5afde6a874e9
begin
using Pkg, Revise
using Pkg
Pkg.activate(".")
Pkg.instantiate()
using Revise
end

# ╔═╡ 034e96b2-c88a-11ed-35f3-9fbfcefa62df
using WaveOpticsPropagation, Napari, ImageShow, FFTW, CUDA, FourierTools, NDTools, Plots, Colors
using WaveOpticsPropagation, ImageShow, FFTW, CUDA, FourierTools, NDTools, Plots, Colors

# ╔═╡ 8082f7f3-3f47-4479-b3fa-20b2eb43ee78
using LinearAlgebra
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### A Pluto.jl notebook ###
# v0.19.22
# v0.19.30

using Markdown
using InteractiveUtils
Expand All @@ -23,7 +23,7 @@ begin
end

# ╔═╡ cba50443-4d13-4c05-b413-6a6f3d3ff1c2
using WaveOpticsPropagation, Napari, ImageShow, FFTW, CUDA, FourierTools, NDTools, Plots, Colors, PlutoUI
using WaveOpticsPropagation, ImageShow, FFTW, CUDA, FourierTools, NDTools, Plots, Colors, PlutoUI

# ╔═╡ f07896d0-808a-470d-8dd8-ed5770a333db
using LinearAlgebra, IndexFunArrays
Expand Down Expand Up @@ -176,15 +176,9 @@ NDTools.expand_dims
# ╠═f9837f4a-e134-4d92-8984-51836bb89f74
# ╠═ddbe7f52-57dc-42d5-9edc-6377eb0bf31d
# ╠═4218847d-9a0c-4e4e-a8b6-6c76e0c3564e
# ╠═0d275418-1393-41c4-b29a-6b56cb25f728
# ╠═5fb47911-28b4-456c-b647-eed4af09f5e3
# ╠═a7325c95-d653-4e7e-ad9c-736a50ba9ea8
# ╠═a8fb4cfa-61c1-4477-a4e8-af6f8e631a7e
# ╠═4f585a19-fd50-40d3-8e60-27ebf080bce6
# ╠═03002431-9a33-4a6b-bb1a-d30f47c3bb45
# ╠═94e1e172-a807-44cf-8f3f-b98262f3f895
# ╠═6dc5b732-f121-465a-9dd9-fdf27fb73e90
# ╠═09954458-5659-46e2-9711-cae7dfac8e36
# ╠═5bb71ea0-cf7d-4be9-8df3-4d8bdab830d3
# ╠═9cd1b7fd-d262-4ccc-8a2c-b82f0368ce35
# ╠═1b1144fe-b732-40bc-8382-727381f69b85
Expand Down
1 change: 1 addition & 0 deletions examples/optimize_phase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ end
begin
using Pkg
Pkg.activate(".")
Pkg.instantiate()
using Revise
end

Expand Down

0 comments on commit 3a1581a

Please sign in to comment.