Photonic crystal
As usual, import relevant libraries.
using LinearAlgebra
using StaticArrays: SVector
using SpecialFunctions
# using GLMakie; GLMakie.activate!(inline=false, float=true)
using CairoMakie
import BoundaryWall as BWM
Now we can define our constants for the problem.
# CONSTANTS
= 9 # number of points per element
N = 1.0
HBAR = 0.5
MASS = 1.0
HBAR = (2*MASS/HBAR^2)*(1/4*im)
SIGMA= 100
NDOM = 13.3237
zero = 1.0
R = LinRange(0, 2pi, N+1)
θ = 180
TH = SVector(cosd(TH), sind(TH))
KVEC = -100.0
POTENTIAL_STRENGTH = 3 BANDED
…and the geometry of such problem.
= 2.0R + R/2 # diameter + constant
STEP = (10,7)
N_CIRCLES = [-(N_CIRCLES[1]-1)*STEP/2:STEP:(N_CIRCLES[1]-1)*STEP/2,-(N_CIRCLES[2]-1)*STEP/2:STEP:(N_CIRCLES[2]-1)*STEP/2]
RANGES =length(RANGES)
N_STEPS = vec([(i, j) for i in RANGES[1], j in RANGES[2]])
CENTERS
= sort([31,32,33,43,44,45,46,47,48,38,39, 40, 23, 24, 25, 26, 27, 28])
INDICES
deleteat!(CENTERS, INDICES)
# POTENTIAL_STRENGTH = repeat(STRENGTH, inner=N)
= [BWM.createCircle(R, θ, SVector(cen)) for cen in CENTERS]
CIRCLES = vcat(getindex.(CIRCLES, 1)...)
x = vcat(getindex.(CIRCLES, 2)...)
y = vcat(getindex.(CIRCLES, 3)...)
xm= vcat(getindex.(CIRCLES, 4)...)
ym= vcat(getindex.(CIRCLES, 5)...)
ds= BWM.calcDistances(xm,ym) rij
Plotting this results in the following diagram,
The core of the library is the ability to have any superposition of plane waves impinge on the geometry. In this example, we focus a gaussian beam with certain waist parameters into the photonic cavity. One can observe that for different frequencies defined in ur FREQS
vector, the system repsonds differently, allowing (or not) the wave to pass through, like a filter.
# domain
= (-15.,15.)
x0, xf = (-10.,10.)
y0, yf = LinRange(x0, xf, NDOM)
xdom = LinRange(y0, yf, NDOM)
ydom = [(_x,_y) for _x in xdom, _y in ydom]
COORDS = first.(COORDS)[:], last.(COORDS)[:]
XDOM, YDOM
@inline function wave_function(_freq::Float64, _kvec::SVector{2, Float64}, _width::Float64)
return abs2.(reshape(
boundaryWallWave(_freq * _kvec, (k,r)->BWM.gaussianWave(k,r - SVector(-10.25, 0.0), _width; abstol=1e-3), x, y, xm, ym, XDOM, YDOM, SIGMA, ds, rij, length(ds), N, BANDED, POTENTIAL_STRENGTH),
BWM.
NDOM, NDOM
)
)end
= [1.35, 1.55, 1.65]
FREQS
= [wave_function(f, KVEC, 4.0) for f in FREQS] waves
We can analyze the flow of the field using the BWM.gradient(xdom, ydom, psi)
function, which returns
\[\mathrm{Im} \left(\psi^\dagger\nabla\psi\right)\]