Scatterers and Boundary Conditions
A scatterer is the combination of a geometry and a condition on its surface. The geometry is the type, the condition its type parameter: a PEC sphere is a Sphere{PEC}, a sound-hard oblate spheroid an OblateSpheroid{SoundHard}. All of them are subtypes of Scatterer{BC}, where BC is the boundary condition.
The two are independent of each other, so that either can be addressed alone:
| addressed by | example | holds for |
|---|---|---|
| geometry | Sphere | spheres with any condition |
| geometry and condition | Sphere{SoundHard} | sound-hard spheres |
| physics | Scatterer{<:AcousticBoundary} | all acoustic scatterers |
Type Hierarchy
The scatterers:
Scatterer{BC}
├── Sphere{BC} centered in the origin
└── Spheroid{BC} acoustic conditions only (so far)
├── OblateSpheroid{BC} including the disc
└── ProlateSpheroid{BC}The boundary conditions, split by physics:
Boundary
├── ElectromagneticBoundary
│ ├── PEC
│ ├── Dielectric
│ ├── Layered
│ └── ThinImpedanceLayer
└── AcousticBoundary
├── SoundHard
└── SoundSoftSee Sphere, Spheroid, OblateSpheroid, ProlateSpheroid, Boundary, ElectromagneticBoundary, AcousticBoundary, PEC, Dielectric, Layered, ThinImpedanceLayer, SoundHard, and SoundSoft.
A condition which requires data, such as the filling of a Dielectric, is stored as a value besides being the type parameter, sp.boundary, whereas a parameter-free one, such as PEC or SoundHard, occupies no memory.
Constructors
Every scatterer is defined by a constructor with keyword arguments:
| scatterer | constructor | type | details |
|---|---|---|---|
| PEC sphere | PECSphere(; radius) | Sphere{PEC} | PEC sphere |
| dielectric sphere | DielectricSphere(; radius, filling) | Sphere{<:Dielectric} | dielectric sphere |
| layered dielectric sphere | LayeredSphere(; radii, filling) | Sphere{<:Layered{<:Dielectric}} | layered sphere |
| layered dielectric sphere with PEC core | LayeredSpherePEC(; radii, filling) | Sphere{<:Layered{PEC}} | layered sphere with PEC core |
| dielectric sphere with thin impedance layer | DielectricSphereThinImpedanceLayer(; radius, thickness, thinlayer, filling) | Sphere{<:ThinImpedanceLayer} | thin impedance layer |
| sound-hard sphere | HardSphere(; radius) | Sphere{SoundHard} | sound-hard/soft sphere |
| sound-soft sphere | SoftSphere(; radius) | Sphere{SoundSoft} | sound-hard/soft sphere |
| spheroid | Spheroid{BC}(; equatorialRadius, polarRadius, axis) | OblateSpheroid{BC} or ProlateSpheroid{BC} | spheroid and disc |
| disc | Disc(BC; radius, axis) | OblateSpheroid{BC} | spheroid and disc |
The names of the spheres are aliases of the respective Sphere{BC}, so that they can be dispatched on as well. A Spheroid returns the oblate or the prolate shape, depending on which of its radii is the larger one.
Alternatively, a sphere can be defined by its condition directly, which yields the same scatterers:
using SphericalScattering
sp = SphericalScattering.Sphere{SoundHard}(; radius=1.0) # parameter-free condition: the type suffices
sp == HardSphere(; radius=1.0)truesp = SphericalScattering.Sphere(; radius=1.0, boundary=Dielectric(Medium(2.0, 1.0))) # condition requiring data
typeof(sp)DielectricSphere{Float64, Float64} (alias for SphericalScattering.Sphere{Dielectric{Float64}, Float64})Combining Scatterers and Excitations
The physics of the scatterer has to match that of the excitation: an electromagnetic excitation requires a Scatterer{<:ElectromagneticBoundary}, an acoustic one a Scatterer{<:AcousticBoundary}. Otherwise a descriptive error is thrown:
using StaticArrays
ex = planeWave(; frequency=1e8) # electromagnetic
sp = HardSphere(; radius=1.0) # acoustic
try
scatteredfield(sp, ex, ElectricField([SVector(2.0, 0.0, 0.0)]))
catch err
showerror(stdout, err)
endAn electromagnetic excitation requires a scatterer with an electromagnetic boundary condition, such as a `PECSphere`.Which combinations of scatterers and excitations are implemented is summarized in the Feature Overview.
The type parameter can also be used to write methods for all scatterers of one physics:
physics(sp::Scatterer{<:AcousticBoundary}) = "acoustic"
physics(sp::Scatterer{<:ElectromagneticBoundary}) = "electromagnetic"
physics.([PECSphere(; radius=1.0), Disc(SoundSoft; radius=1.0)])2-element Vector{String}:
"electromagnetic"
"acoustic"Geometric Queries
Besides the solutions, the following functions answer questions about the geometry:
| function | scatterers | returns |
|---|---|---|
isinside(sp, point) | spheres and spheroids | whether the point lies inside the scatterer |
equatorialRadius(sp), polarRadius(sp) | spheroids | the radii of the spheroid |
isdisc(sp) | spheroids | whether the spheroid is a disc |
outwardNormal(sp, point), outwardNormals(sp, points) | spheroids | the outward normal at the given surface points |