Skip to content

Commit 40eccb7

Browse files
committed
Merge branch 'revise/embeddingAPI'
2 parents 330075e + ab56913 commit 40eccb7

File tree

13 files changed

+71
-120
lines changed

13 files changed

+71
-120
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SphericalScattering"
22
uuid = "1a9ea918-b599-4f1f-bd9a-d681e8bb5b3e"
33
authors = ["Bernd Hofmann <Bernd.Hofmann@tum.de> and contributors"]
4-
version = "0.6.0"
4+
version = "0.7.0"
55

66
[deps]
77
LegendrePolynomials = "3db4a2ba-fc88-11e8-3e01-49c72059a882"

docs/src/scatterer.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Sphere Dimensions
33

44
!!! note
5-
In all of the following setups the sphere is embedded in a homogeneous background medium with permeability ``\mu`` and permittivity ``\varepsilon`` defined by [`Medium(ε, μ)`](@ref). The values [`μ0`](@ref) and [`ε0`](@ref) are provided containing the free space values.
5+
In all of the following setups the sphere is embedded in a homogeneous background medium with permeability ``\mu`` and permittivity ``\varepsilon``.
6+
This medium is defined only by the chosen excitation as a [`Medium(ε, μ)`](@ref).
67

78

89
---
@@ -26,7 +27,7 @@ PECSphere
2627
---
2728
## Dielectric Sphere
2829

29-
The dielectric sphere has radius ``r`` and is assumed to be located in the origin. It is defined by [`DielectricSphere`](@ref). In addition to the embedding [`Medium(ε, μ)`](@ref) a filling [`Medium(εᵢ, μᵢ)`](@ref) with permeability ``\mu_\mathrm{i}`` and permittivity ``\varepsilon_\mathrm{i}`` has to be defined.
30+
The dielectric sphere has radius ``r`` and is assumed to be located in the origin. It is defined by [`DielectricSphere`](@ref), where the filling [`Medium(εᵢ, μᵢ)`](@ref) with permeability ``\mu_\mathrm{i}`` and permittivity ``\varepsilon_\mathrm{i}`` has to be defined.
3031
```@raw html
3132
<div align="center">
3233
<img src="../assets/DielectricSphere.svg" width="300"/>
@@ -39,13 +40,13 @@ The dielectric sphere has radius ``r`` and is assumed to be located in the origi
3940
```@docs
4041
DielectricSphere
4142
```
42-
Here `radius` is a Float and `filling` of type [`Medium(εᵢ, μᵢ)`](@ref).
43+
Here `radius` is a Float and `filling` is of type [`Medium(εᵢ, μᵢ)`](@ref).
4344

4445

4546
---
4647
## Layered Dielectric Sphere
4748

48-
The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_N]`` and is assumed to be located in the origin. It is defined by [`LayeredSphere`](@ref). In addition to the embedding [`Medium(ε, μ)`](@ref) a vector of fillings [[`Medium(ε₁, μ₁)`](@ref), [`Medium(ε₂, μ₂)`](@ref), ..., [`Medium(εN, μN)`](@ref)] with permeability ``\mu_n`` and permittivity ``\varepsilon_n`` has to be defined.
49+
The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_N]`` and is assumed to be located in the origin. It is defined by [`LayeredSphere`](@ref), where the vector of fillings [[`Medium(ε₁, μ₁)`](@ref), [`Medium(ε₂, μ₂)`](@ref), ..., [`Medium(εN, μN)`](@ref)] with permeability ``\mu_n`` and permittivity ``\varepsilon_n`` has to be defined.
4950
```@raw html
5051
<div align="center">
5152
<img src="../assets/LayeredSphere.svg" width="300"/>
@@ -58,13 +59,13 @@ The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_N]`` and is assume
5859
```@docs
5960
LayeredSphere
6061
```
61-
with, e.g., `radii = SVector(0.25, 0.5, 1.0)` and `radii = SVector(Medium(ε1, μ1), Medium(ε2, μ2), Medium(ε3, μ3))`.
62+
with, e.g., `radii = SVector(0.25, 0.5, 1.0)` and `filling = SVector(Medium(ε1, μ1), Medium(ε2, μ2), Medium(ε3, μ3))`.
6263

6364

6465
---
6566
## Layered Dielectric Sphere with PEC Core
6667

67-
The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_{N+1}]`` and is assumed to be located in the origin. It is defined by [`LayeredSpherePEC`](@ref). In addition to the embedding [`Medium(ε, μ)`](@ref) a vector of fillings [[`Medium(ε₁, μ₁)`](@ref), [`Medium(ε₂, μ₂)`](@ref), ..., [`Medium(εN, μN)`](@ref)] with permeability ``\mu_n`` and permittivity ``\varepsilon_n`` has to be defined.
68+
The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_{N+1}]`` and is assumed to be located in the origin. It is defined by [`LayeredSpherePEC`](@ref), where the vector of fillings [[`Medium(ε₁, μ₁)`](@ref), [`Medium(ε₂, μ₂)`](@ref), ..., [`Medium(εN, μN)`](@ref)] with permeability ``\mu_n`` and permittivity ``\varepsilon_n`` has to be defined.
6869
```@raw html
6970
<div align="center">
7071
<img src="../assets/LayeredSpherePEC.svg" width="300"/>
@@ -76,13 +77,13 @@ The layered dielectric sphere has radii ``[r_1, r_2, \dots, r_{N+1}]`` and is as
7677
```@docs
7778
LayeredSpherePEC
7879
```
79-
with, e.g., `radii = SVector(0.25, 0.5, 1.0)` and `radii = SVector(Medium(ε1, μ1), Medium(ε2, μ2))`.
80+
with, e.g., `radii = SVector(0.25, 0.5, 1.0)` and `filling = SVector(Medium(ε1, μ1), Medium(ε2, μ2))`.
8081

8182

8283
---
8384
## [Dielectric Sphere with Thin Impedance Layer](@id dielecimped)
8485

85-
The dielectric sphere with a thin impedance layer of thickness ``t`` has radius ``r`` and is assumed to be located in the origin. It is defined by [`DielectricSphereThinImpedanceLayer`](@ref). Unlike the LayeredSphere model, the solution is obtained by using an approximation: it is assumed that the impedance is so high that the displacement field is purely radial (see [[6, pp. 230ff]](@ref refs)). This leads to a potential drop across the thin layer, while the displacement field is constant in radial direction. In addition to the embedding [`Medium(ε, μ)`](@ref) and filling [`Medium(εᵢ, μᵢ)`](@ref), the impedance layer must be specified, both the [`Medium(εₜ, μₜ)`](@ref) and its `thickness`.
86+
The dielectric sphere with a thin impedance layer of thickness ``t`` has radius ``r`` and is assumed to be located in the origin. It is defined by [`DielectricSphereThinImpedanceLayer`](@ref). Unlike the LayeredSphere model, the solution is obtained by using an approximation: it is assumed that the impedance is so high that the displacement field is purely radial (see [[6, pp. 230ff]](@ref refs)). This leads to a potential drop across the thin layer, while the displacement field is constant in radial direction. In addition to the filling [`Medium(εᵢ, μᵢ)`](@ref), the impedance layer must be specified, both the [`Medium(εₜ, μₜ)`](@ref) and its `thickness`.
8687
```@raw html
8788
<div align="center">
8889
<img src="../assets/ImpedanceLayer.svg" width="300"/>
@@ -98,4 +99,4 @@ The dielectric sphere with a thin impedance layer of thickness ``t`` has radius
9899
```@docs
99100
DielectricSphereThinImpedanceLayer
100101
```
101-
Here `radius` and `thickness` are a Floats, `embedding`, `filling` and `thinlayer` are of type [`Medium`](@ref).
102+
Here `radius` and `thickness` are a Floats, `filling` and `thinlayer` are of type [`Medium`](@ref).

src/UniformField/scattered.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Compute the electric field scattered by a sphere, for an incident uniform field.
66
"""
77
function scatteredfield(sphere::Sphere, excitation::UniformField, quantity::Field; parameter::Parameter=Parameter())
88

9-
sphere.embedding == excitation.embedding || error("Excitation and sphere are not in the same medium.") # verify excitation and sphere are in the same medium
10-
119
F = zeros(fieldType(quantity), size(quantity.locations))
1210

1311
# --- compute field in Cartesian representation
@@ -31,7 +29,7 @@ function scatteredfield(
3129
sphere::DielectricSphere, excitation::UniformField, point, quantity::ElectricField; parameter::Parameter=Parameter()
3230
)
3331

34-
ε0 = sphere.embedding.ε
32+
ε0 = excitation.embedding.ε
3533
ε1 = sphere.filling.ε
3634
E0 = field(excitation, point, quantity)
3735

@@ -60,7 +58,7 @@ function scatteredfield(
6058
sphere::DielectricSphere, excitation::UniformField, point, quantity::ScalarPotential; parameter::Parameter=Parameter()
6159
)
6260

63-
ε0 = sphere.embedding.ε
61+
ε0 = excitation.embedding.ε
6462
ε1 = sphere.filling.ε
6563
Φ0 = field(excitation, point, quantity)
6664

@@ -137,7 +135,7 @@ function scatteredfield(
137135
E = scatteredfield(sphere, excitation, point, ElectricField(quantity.locations); parameter=parameter)
138136

139137
if norm(point) > sphere.radius
140-
D = sphere.embedding.ε * E
138+
D = excitation.embedding.ε * E
141139
else
142140
D = sphere.filling.ε * E
143141
end
@@ -217,7 +215,7 @@ function scatterCoeff(sp::DielectricSphereThinImpedanceLayer, ex::UniformField)
217215
R = sp.radius
218216
Δ = sp.thickness
219217
εₘ = sp.thinlayer.ε
220-
εₑ = sp.embedding.ε
218+
εₑ = ex.embedding.ε
221219
εᵢ = sp.filling.ε
222220
E₀ = ex.amplitude
223221

@@ -346,7 +344,7 @@ function scatterCoeff(sphere::LayeredSphere{LN,LR,LC}, excitation::UniformField{
346344

347345
a = reverse(sphere.radii)
348346
n = length(a)
349-
perms = reverse(getfield.(vcat(sphere.filling, sphere.embedding), 1))
347+
perms = reverse(getfield.(vcat(sphere.filling, excitation.embedding), 1))
350348

351349
T = promote_type(LR, LC, FC, FT, FR)
352350

@@ -458,7 +456,7 @@ function scatterCoeff(sphere::LayeredSpherePEC{LN,LD,LR,LC}, excitation::Uniform
458456

459457
a = reverse(sphere.radii)
460458
n = length(a) - 1
461-
perms = reverse(getfield.(vcat(sphere.filling, sphere.embedding), 1))
459+
perms = reverse(getfield.(vcat(sphere.filling, excitation.embedding), 1))
462460

463461
T = promote_type(LR, LC, FC, FT, FR)
464462

src/dipoles/scattered.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function scatteredfield(sphere::PECSphere, excitation::Dipole, quantity::Field;
88

99
T = typeof(excitation.frequency)
1010

11-
sphere.embedding == excitation.embedding || error("Excitation and sphere are not in the same medium.") # verify excitation and sphere are in the same medium
1211
excitation.orientation × excitation.position == SVector{3,T}(0, 0, 0) || error("The dipole is not perpendicular to the sphere.")
1312

1413
F = zeros(SVector{3,Complex{T}}, size(quantity.locations))

src/planeWave/excitation.jl

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,3 @@ planeWave(;
3939
polarization = SVector{3,typeof(frequency)}(1.0, 0.0, 0.0),
4040
) = PlaneWave(embedding, frequency, amplitude, direction, polarization)
4141

42-
43-
"""
44-
ex = planeWave(
45-
sp::Sphere;
46-
frequency = error("missing argument `frequency`"),
47-
amplitude = 1.0,
48-
direction = SVector{3,typeof(frequency)}(0.0, 0.0, 1.0),
49-
polarization = SVector{3,typeof(frequency)}(1.0, 0.0, 0.0),
50-
)
51-
"""
52-
planeWave(
53-
sp::Sphere;
54-
frequency = error("missing argument `frequency`"),
55-
amplitude = 1.0,
56-
direction = SVector{3,typeof(frequency)}(0.0, 0.0, 1.0),
57-
polarization = SVector{3,typeof(frequency)}(1.0, 0.0, 0.0),
58-
) = PlaneWave(sp.embedding, frequency, amplitude, direction, polarization)

src/planeWave/scattered.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Compute the electric field scattered by a PEC sphere, for an incident plane wave
66
"""
77
function scatteredfield(sphere::Sphere, excitation::PlaneWave, quantity::Field; parameter::Parameter=Parameter())
88

9-
sphere.embedding == excitation.embedding || error("Excitation and sphere are not in the same medium.") # verify excitation and sphere are in the same medium
10-
119
T = typeof(excitation.frequency)
1210
F = zeros(SVector{3,Complex{T}}, size(quantity.locations))
1311

@@ -148,7 +146,7 @@ Returns ``H₀/ηᵢ``, where ``H₀`` is the magnetic field of the incident pla
148146
For PEC layers, it returns ``0``.
149147
"""
150148
function amplitude(sphere, excitation::PlaneWave, quantity::MagneticField, r)
151-
η = impedance(sphere, r)
149+
η = impedance(sphere, excitation, r)
152150

153151
if η == 0.0 # PEC case
154152
return η * excitation.amplitude # return zero of correct type
@@ -166,7 +164,7 @@ Returns ``E₀``, where ``E₀`` is the electric field of the incident plane wav
166164
For PEC layers, it returns ``0``.
167165
"""
168166
function amplitude(sphere, excitation::PlaneWave, quantity::ElectricField, r)
169-
η = impedance(sphere, r)
167+
η = impedance(sphere, excitation, r)
170168

171169
if η == 0.0 # PEC case
172170
return η * excitation.amplitude # return zero of correct type
@@ -248,8 +246,8 @@ function scatterCoeff(sphere::DielectricSphere, excitation::PlaneWave, n::Int)
248246
f = excitation.frequency
249247
T = typeof(f)
250248

251-
ε2 = sphere.embedding.ε
252-
μ2 = sphere.embedding.μ
249+
ε2 = excitation.embedding.ε
250+
μ2 = excitation.embedding.μ
253251

254252
ε1 = sphere.filling.ε
255253
μ1 = sphere.filling.μ

src/ringCurrent/scattered.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ function scatteredfield(sphere::PECSphere, excitation::RingCurrent, quantity::Fi
88

99
T = typeof(excitation.frequency)
1010

11-
sphere.embedding == excitation.embedding || error("Excitation and sphere are not in the same medium.") # verify excitation and sphere are in the same medium
1211
excitation.orientation × excitation.center == SVector{3,T}(0, 0, 0) ||
1312
error("The ring current is not perpendicular to the sphere.")
1413

0 commit comments

Comments
 (0)