Skip to content

Commit

Permalink
switch to pure Julia HCubature without splitting into real/imag
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbrahms committed Aug 14, 2022
1 parent ee53a13 commit 7054a11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions src/Fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Fields
import Luna: Grid, Maths, PhysData, Modes
import Luna.PhysData: wlfreq, ε_0, μ_0
import StaticArrays: SVector
import Cubature: hcubature
import HCubature: hcubature
import NumericalIntegration: integrate, SimpsonEven
import Random: AbstractRNG, GLOBAL_RNG
import Statistics: mean
Expand Down Expand Up @@ -428,13 +428,10 @@ end

function int2D(field1, field2, lowerlim, upperlim)
Ifunc(xs) = 0.5*sqrt(ε_0/μ_0)*dot(field1(xs), field2(xs))*xs[1]
rval, _ = hcubature(lowerlim, upperlim) do xs
val, _ = hcubature(lowerlim, upperlim) do xs
real(Ifunc(xs))
end
ival, _ = hcubature(lowerlim, upperlim) do xs
imag(Ifunc(xs))
end
abs(rval + 1im*ival)
val
end

function normalised_field(fieldfunc, rmax)
Expand Down
11 changes: 4 additions & 7 deletions src/Modes.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Modes
import Roots: find_zero, Order2
import Cubature: hcubature, hquadrature
import HCubature: hcubature, hquadrature
import LinearAlgebra: dot, norm
import NumericalIntegration: integrate, Trapezoidal
import Luna: Maths, Grid
Expand Down Expand Up @@ -322,13 +322,10 @@ coordinates `xs = (r,θ)`.
"""
function overlap(m::AbstractMode, E)
dl = dimlimits(m)
rval, _ = hcubature(dl[2], dl[3]; maxevals=1000) do xs
real(0.5*sqrt(ε_0/μ_0)*dot(Exy(m, xs), E(xs))*xs[1])
val, _ = hcubature(dl[2], dl[3]; maxevals=1000) do xs
0.5*sqrt(ε_0/μ_0)*dot(Exy(m, xs), E(xs))*xs[1]
end
ival, _ = hcubature(dl[2], dl[3]; maxevals=1000) do xs
imag(0.5*sqrt(ε_0/μ_0)*dot(Exy(m, xs), E(xs))*xs[1])
end
rval + 1im*ival
val
end

"""
Expand Down

0 comments on commit 7054a11

Please sign in to comment.