Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
paulxshen committed Mar 31, 2024
1 parent 9092bb7 commit 6a95723
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Binary file added antennapattern.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 17 additions & 11 deletions examples/quarter_wavelength_antenna/quarter_wavelength_antenna.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
We simulate a quarter wavelength antenna above conductor ground plane and compute its nearfield radiation pattern
=#

using UnPack, LinearAlgebra, GLMakie, CoordinateTransformations
using UnPack, LinearAlgebra, GLMakie, CoordinateTransformations, NearestNeighbors
using GLMakie: volume
using Luminescent, LuminescentVisualization
# using Luminescent, LuminescentVisualization

# if running directly without module # hide
# include("$(pwd())/src/main.jl") # hide
# include("$(pwd())/../LuminescentVisualization.jl/src/main.jl") # hide
include("$(pwd())/src/main.jl") # hide
include("$(pwd())/../LuminescentVisualization.jl/src/main.jl") # hide

name = "quarter_wavelength_antenna"
F = Float32
Expand Down Expand Up @@ -64,18 +64,24 @@ if dogpu
end

#=
Plot nearfield Poynting flux thru our Spherical monitor integrated for 1 period
Compute nearfield Poynting flux integrated for 1 period thru our Spherical monitor consisting of points on sphere
=#
nt = round(Int, 1 / dt)
r = dt * sum(flux.(u[end-nt+1:end], (monitor_instances[1],),))

_, θ, ϕ = eachrow(sphcoords(monitors[1])[:, inbounds(monitor_instances[1])])
cfs = CartesianFromSpherical()
rvecs = cfs.(splat(Spherical).(zip(r, F.(θ), F.(ϕ))))

fig = Figure()
ax = Axis3(fig[1, 1])
plot!(ax, getindex.(rvecs, 1), getindex.(rvecs, 2), getindex.(rvecs, 3),)
#=
Interpolate onto regular grid for Plot
=#
tree = KDTree(hcat(θ, ϕ)')
θ = 0:15°:360°
ϕ = 0:15°:180°
n = length(ϕ)
m = length(θ)
i, = nn(tree, stack(vec(collect.(Base.product(θ, ϕ)))),)
cfs = CartesianFromSpherical()
rvecs = reshape(cfs.(splat(Spherical).(zip(r[i], θ * ones(n)', ones(m) * ϕ'))), m, n)
fig = surface(getindex.(rvecs, 1), getindex.(rvecs, 2), getindex.(rvecs, 3),)
display(fig)
save("antennapattern.png", fig)

Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Pkg
# ]add UnPack, BSON,DataStructures, StatsBase, Documenter,ImageTransformations,Interpolations, Zygote, Optim,ArrayPadding, Porcupine, Jello, GLMakie, Functors, CoordinateTransformations,Lazy,AbbreviatedStackTraces,ReverseStackTraces,CUDA,Flux
# ]add UnPack, BSON,DataStructures, StatsBase, Documenter,ImageTransformations,Interpolations, Zygote, Optim,ArrayPadding, Porcupine,NearestNeighbors, Jello, GLMakie, Functors, CoordinateTransformations,Lazy,AbbreviatedStackTraces,ReverseStackTraces,CUDA,Flux
# Pkg.add(url="https://github.com/paulxshen/ArrayPadding.jl")
# Pkg.add(url="https://github.com/paulxshen/Jello.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/Luminescent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export maxwell_update!, maxwell_update!, maxwell_update
# stepTM, step1, , stepTE
export Periodic, PML, PEC, PMC, InPad, OutPad
export PlaneWave, GaussianBeam, Source, place, place!
export Monitor, power, flux, field, support, sphcoords, inbounds
export Monitor, SphereMonitor, power, flux, field, support, sphcoords, inbounds
export maxwell_setup, apply, apply!, °
end

Expand Down

0 comments on commit 6a95723

Please sign in to comment.