Skip to content

Commit 30fa94f

Browse files
committed
fix unintuitive behavior for scatterd + total fields for diel. sphere
1 parent c262a25 commit 30fa94f

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

src/planeWave/scattered.jl

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ function scatteredfield(sphere::Sphere, excitation::PlaneWave, point, quantity::
4646

4747
eps = parameter.relativeAccuracy
4848

49-
ST = SVector{3,Complex{T}}
50-
F = ST(0.0, 0.0, 0.0)
49+
F = SVector{3,Complex{T}}(0.0, 0.0, 0.0)
5150

52-
A₀ = amplitude(sphere, excitation::PlaneWave, quantity, r)
51+
A₀ = amplitude(sphere, excitation, quantity, r)
5352

5453
A₀ == 0.0 && return F # Inside of PEC return zero field
5554

@@ -84,7 +83,30 @@ function scatteredfield(sphere::Sphere, excitation::PlaneWave, point, quantity::
8483

8584
end
8685

87-
return convertSpherical2Cartesian(A₀ .* F, point_sph)
86+
Fin = inside(sphere, excitation, point, quantity; parameter=parameter)
87+
88+
return convertSpherical2Cartesian(A₀ .* F, point_sph) + Fin
89+
end
90+
91+
92+
function inside(sphere::Sphere, excitation::PlaneWave{T,R,C}, point, quantity::Field; parameter) where {T,R,C}
93+
94+
return SVector{3,Complex{R}}(0.0, 0.0, 0.0) # no correction needed
95+
end
96+
97+
function inside(sphere::DielectricSphere, excitation::PlaneWave{T,R,C}, point, quantity::FarField; parameter) where {T,R,C}
98+
99+
return SVector{3,Complex{R}}(0.0, 0.0, 0.0) # no correction needed
100+
end
101+
102+
function inside(sphere::DielectricSphere, excitation::PlaneWave{T,R,C}, point, quantity::Field; parameter) where {T,R,C}
103+
104+
# inside the sphere the incident field has to be substracted to get only the scattered part
105+
if norm(point) < sphere.radius
106+
return -field(excitation, point, quantity; parameter=parameter)
107+
end
108+
109+
return SVector{3,Complex{R}}(0.0, 0.0, 0.0)
88110
end
89111

90112

src/totalFields.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
inside(sphere::Sphere) = 0.0
33
inside(sphere::PECSphere) = sphere.radius
4-
# inside(sphere::DielectricSphere) = sphere.radius
54

65

76
"""

test/planeWave_dielectric.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
# E-Field
7979
EF₂ = scatteredfield(sp, ex, ElectricField(points_cartNF))
80-
EF₁ = scatteredfield(sp, ex, ElectricField(points_cartNF_inside))
80+
EF₁ = field(sp, ex, ElectricField(points_cartNF_inside))
8181

8282
diff_EF₂ = norm.(EF₂ - EF₂MoM) ./ maximum(norm.(EF₂)) # worst case error
8383
diff_EF₁ = norm.(EF₁ - EF₁MoM) ./ maximum(norm.(EF₁)) # worst case error
@@ -90,7 +90,7 @@
9090
HF₁MoM = hfield(𝓣k1, -(1 / η1)^2 .* m, RT, 𝓚k1, -j, RT, points_cartNF_inside)
9191

9292
HF₂ = scatteredfield(sp, ex, MagneticField(points_cartNF))
93-
HF₁ = scatteredfield(sp, ex, MagneticField(points_cartNF_inside))
93+
HF₁ = field(sp, ex, MagneticField(points_cartNF_inside))
9494

9595
diff_HF₂ = norm.(HF₂ - HF₂MoM) ./ maximum(norm.(HF₂)) # worst case error
9696
diff_HF₁ = norm.(HF₁ - HF₁MoM) ./ maximum(norm.(HF₁)) # worst case error

0 commit comments

Comments
 (0)