Base
Shape
Shape types and functions.
MultipleScattering.Shape
— TypeAbstract idea which defines the external boundary of object.
MultipleScattering.origin
— Functionorigin(shape::Shape)::SVector
Origin of shape, typically the center
MultipleScattering.iscongruent
— Methodiscongruent(p1::Shape, p2::Shape)::Bool
≅(p1::Shape, p2::Shape)::Bool
True if shapes are the same but in different positions (origins), standard mathematical definition.
MultipleScattering.congruent
— Functioncongruent(s::Shape, x)::Shape
Create shape congruent to s
but with origin at x
MultipleScattering.bounding_box
— FunctionReturns box which completely encloses the shapes
MultipleScattering.boundary_functions
— Functionvolume(shape::Shape)::NTuple{Function,Dim)
Returns Tuple of Dim Functions which define outer boundary of shape when given boundary coordinate t∈[0,1]
MultipleScattering.name
— Functionname(shape::Shape)::String
Name of a shape
MultipleScattering.outer_radius
— Functionouter_radius(shape::Shape{T})::T
The radius of a circle which completely contains the shape
MultipleScattering.volume
— Functionvolume(shape::Shape{T})::T
Volume of a shape
MultipleScattering.Sphere
— TypeSphere([origin=zeros(),] radius)
A Shape
where boundary is a fixed distance from the origin. In 2D this is a circle, in 3D the usual sphere, and in higher dimensions if difficult to visualise.
MultipleScattering.Box
— TypeBox([origin::AbstractVector{T}=zeros(),] dimensions::AbstractVector{T})
A Box
for 2D and 3D with axis aligned sides, defined by dimensions and origin (at the center).
MultipleScattering.TimeOfFlightFromPoint
— TypeA shape where anything inside could cause a disturbance at the listener position from a point source wavefront starting at the listener. Also everything inside has a positive x
coordinate. It is equivalent to a segment of a circle.
More precisely, if the listener is at (lx,ly) then the interior of the shape is defined as sqrt((x-lx)^2+(y-ly)^2)<time and x>0
MultipleScattering.TimeOfFlight
— TypeA shape where anything inside could cause a disturbance at the listener position from a planar wavefront parallel to the y axis starting at the listener. Also everything inside has a positive x
coordinate.
More precisely, if the listener is at (lx,ly) then the interior of the shape is defined as x-lx+sqrt((x-lx)^2+(y-l_y)^2)<time and x>0
Physical property
Physical properties types and functions.
MultipleScattering.PhysicalMedium
— TypePhysicalMedium{T<:AbstractFloat,Dim,FieldDim}
An abstract type used to represent the physical medium, the dimension of the field, and the number of spatial dimensions.
MultipleScattering.field_dimension
— FunctionExtract the dimension of the field of this physical property
Extract the dimension of the field of this type of physical property
MultipleScattering.spatial_dimension
— FunctionExtract the dimension of the space that this physical property lives in
Extract the dimension of the space that this type of physical property lives in
MultipleScattering.outgoing_basis_function
— FunctionBasis of outgoing wave. A series expansion in this basis should converge to any scattered field outside of a ball which contains the scatterer.
MultipleScattering.regular_basis_function
— FunctionA basis for regular functions, that is, smooth functions. A series expansion in this basis should converge to any regular function within a ball.
MultipleScattering.internal_field
— Functionthe field inside an AbstractParticle a some given point x.
MultipleScattering.boundary_data
— FunctionA tuples of vectors of the field close to the boundary of the shape. The field is calculated from sim::FrequencySimulation, but the PhysicalMedium inside and outside of the shape are assumed to be given by insidemedium and outsidemedium.
Particle
Particle types and functions.
MultipleScattering.AbstractParticle
— TypeObject we can scatter waves off
Subtypes will contain information about shape and material properties. Most crucially, they will implement the t_matrix
function
MultipleScattering.Particle
— TypeParticle(medium::PhysicalMedium, shape::Shape)
Create particle with inner medium and shape (types and dimension must agree).
MultipleScattering.CapsuleParticle
— TypeCapsuleParticle(outer::Particle, inner::Particle)
A particle within another particle, both with the same shape type and origin.
MultipleScattering.iscongruent
— Methodiscongruent(p1::AbstractParticle, p2::AbstractParticle)::Bool
≅(p1::AbstractParticle, p2::AbstractParticle)::Bool
Returns true if medium and shape of particles are the same, ignoring origin, false otherwise.
Source
Source types and functions.
MultipleScattering.AbstractSource
— TypeRepresent any source (incident) wave
Subtypes may have a symmetry (such as PlaneSource
) and will contain information about physical medium.
MultipleScattering.PlaneSource
— TypePlaneSource(medium::P, amplitude::SVector, direction::SVector)
Is a struct type which describes a plane-wave source that drives/forces the whole system. It has three fields: a physical medium
, an amplitude
of the source, and the direction the propagate in direction
.
For any given angular frequency ω, the PlaneSource has the value $e^{i ω/c \mathbf v \cdot \mathbf x }$ at the point $\mathbf x$, where $c$ is the medium wavespeed and $\mathbf v$ is the direction.
MultipleScattering.Source
— TypeSource(medium::P, field::Function, coef::Function)
Is a struct type which describes the source field that drives/forces the whole system. It is also described as an incident wave. It has three fields Source.medium
, Source.field
, and Source.coef
.
The source field at the position 'x' and angular frequency 'ω' is given by
x = [1.0,0.0]
ω = 1.0
Source.field(x,ω)
The field Source.coef
regularbasisfunction(medium::Acoustic{T,2}, ω::T)
MultipleScattering.regular_spherical_coefficients
— Methodregular_spherical_coefficients(source::Source)
return a function which can calculate the coefficients of a regular spherical wave basis.
MultipleScattering.self_test
— MethodCheck that the source functions return the correct types
MultipleScattering.source_expand
— Methodsource_expand(Source, centre; basis_order = 4)
Returns a function of (x,ω)
which approximates the value of the source at (x,ω)
. That is, the source is written in terms of a regular basis expansion centred at centre
.
Impulse
Impulse types and functions.
MultipleScattering.ContinuousImpulse
— TypeSee also: DiscreteImpulse
, frequency_to_time
ContinuousImpulse{T<:AbstractFloat}
A struct used to represent an analytic impulse function. Has two fields: in_time
a function of time t
, and in_freq
a function of the angular frequency ω
. in_freq
should be the Fourier transform of in_time
, though this is not enforced.
We use the Fourier transform convention: F(ω) = ∫ f(t)exp(imωt) dt, f(t) = (2π)^(-1) * ∫ F(ω)exp(-imωt) dω.
An impluse f(t) is convoluted in time with the field u(t), however we avoid the convolution by working with the fourier transform F(ω) of the impulse f(t), which results in
frequency to time: (2π)^(-1) * ∫ F(ω)U(ω)exp(-imωt) dω
MultipleScattering.DiscreteImpulse
— TypeSee also: ContinuousImpulse
, frequency_to_time
, DiscreteGaussianImpulse
DiscreteImpulse{T<:AbstractFloat}
A struct used to represent a numerical impulse. Only the fields: in_freq
which is the frequency response vector, and the frequency vector ω
are required to use this struct to use in the function frequency_to_time
.
MultipleScattering.DiscreteGaussianImpulse
— MethodSee also: ContinuousImpulse
, TimeDiracImpulse
DiscreteGaussianImpulse(t_vec[, ω_vec])
Returns a discretised gaussian impulse.
MultipleScattering.FreqDiracImpulse
— MethodDirac Delta function of unit area in the frequency domain centred at ω=ω0.
Warning: in frequency space this is a singuarity and so may lead to unexpected behaviour.
MultipleScattering.GaussianImpulse
— MethodSee also: ContinuousImpulse
, TimeDiracImpulse
GaussianImpulse(maxω[; σ = 3.0/maxω^2])
Returns a gaussian impulse function, which in the frequency domain is exp(-σ*ω^2)*(2sqrt(σ*pi))
.
MultipleScattering.TimeDiracImpulse
— MethodTimeDiracImpulse(t0::T)
Dirac Delta function of unit area in the time domain centred at t=t0.
Warning: in the time domain this is a singuarity and so may lead to unexpected behaviour.
MultipleScattering.continuous_to_discrete_impulse
— Methodcontinuous_to_discrete_impulse(impulse::ContinuousImpulse, t_vec, ω_vec = t_to_ω(t_vec); t_shift = 0.0, ω_shift = 0.0)
Returns a DiscreteImpulse
by sampling impulse
. The signal can be shifted in time and frequency by choosing t_shit
and ω_shift
.
MultipleScattering.self_test
— MethodCheck that the continuous impulse functions return the correct types
MultipleScattering.self_test
— MethodCheck that the discrete impulse vectors are the right sizes
MultipleScattering.firstnonzero
— MethodReturns the first element of array which isn't zero (assumes elements are increasing and distinct)
MultipleScattering.frequency_to_time
— MethodConvert a FrequencySimulationResult into a TimeSimulationResult by using the inverse fourier transform. Assumes only positive frequencies and a real time signal
MultipleScattering.frequency_to_time
— MethodSee also: DiscreteImpulse
, ContinuousImpulse
Calculates the time response from the frequency response by approximating an inverse Fourier transform. The time signal is assumed to be real and the frequenices ω_vec are assumed to be positive (can include zero) and sorted. The result is convoluted in time ωith the user specified impulse.
We use the Fourier transform convention: F(ω) = ∫ f(t)exp(imωt) dt f(t) = (2π)^(-1) * ∫ F(ω)exp(-imωt) dt
To easily sample any time, the default is not FFT, but a discrete version of the transform above.
MultipleScattering.t_to_ω
— MethodThe inverse of ωtot if ω_vec[1] == 0
MultipleScattering.time_to_frequency
— MethodConvert a TimeSimulationResult into a FrequencySimulationResult by using the fourier transform. Assumes only positive frequencies and a real time signal
MultipleScattering.time_to_frequency
— MethodThe inverse of the function frequencytotime (only an exact inverse when using :dft integration). We use the Fourier transform convention: F(ω) = ∫ f(t)exp(imω*t) dt
MultipleScattering.ω_to_t
— Methodreturns an array of time from the frequency array ωvec. Uses the same convention for sampling the time as the discrete Fourier transfrom. Assumes ωvec is ordered and non-negative.
Simulation
Simulation types and functions.
MultipleScattering.FrequencySimulation
— TypeFrequencySimulation([particles::AbstractParticles=[],]
source::AbstractSource)
Build a FrequencySimulation. If particles are not provided, an empty array is used.
After building, you can run
the simulation to get a FrequencySimulationResult
.
Base.run
— Methodrun(sim::FrequencySimulation, x, ω; basis_order=5)
Run the simulation sim
for the position x
and angular frequency ω
.
Position can be an SVector or Vector{SVector} and frequency can be a float or vector of floats.
Base.run
— Methodrun(sim::FrequencySimulation, region::Shape;
res=20, xres=res, yres=res, basis_order=5)
Run the simulation sim
for a grid of positions in region and for angular frequency ω
.
Frequency can be a float or vector of floats. The resolution of the grid points is defined by xres and yres.
MultipleScattering.FrequencySimulationResult
— TypeStruct to hold results of a FrequencySimulation
MultipleScattering.basis_coefficients
— Functionbasis_coefficients(sim::FrequencySimulation, ω::AbstractFloat; basis_order::Int=5)::Matrix{Complex}
Return coefficients for bases around each particle for a given simulation and angular frequency (ω).
MultipleScattering.field
— Functionfield(result::SimulationResult, [i::Integer, j::Integer])
Get field from result, optionally specifying indices.
Returns single value of/matrix of complex SVectors() if vector field, and complex float if scalar field.
MultipleScattering.scattering_matrix
— FunctionCreate the matrix S which will be inverted to find the scattering coefficients.
MultipleScattering.t_matrix
— Functiont_matrix(particle, medium, ω, order)
Returns a finite T-matrix, with size depending on order
, for a specific particle
within a medium
with specific physical properties.
t_matrix(Particle{T,2,Acoustic{T,2},Sphere{T,2}}, Acoustic{T,2}, ω, order)
The T-matrix for a 2D circlular acoustic particle in a 2D acoustic medium.
t_matrix(CapsuleParticle{T,2,Acoustic{T,2},Sphere{T,2}}, Acoustic{T,2}, ω, order)
The T-matrix for a 2D circlular capsule particle in an acoustic medium.
t_matrix(Particle{T,3,Acoustic{T,3},Sphere{T,3}}, Acoustic{T,3}, ω, order)
The T-matrix for a 3D spherical acoustic particle in a 3D acoustic medium.
MultipleScattering.get_t_matrices
— Functionget_t_matrices(PhysicalMedium, Vector{Particles}, ω, basis_order::Integer)
Returns vector of T-matrices from a vector of particles in a specific domain. Can save computation if multiple of the same kind of particle are present in the vector.