Skip to content

Commit

Permalink
Some major prototyping
Browse files Browse the repository at this point in the history
  • Loading branch information
kapple19 committed Aug 18, 2024
1 parent 15ad326 commit dcb6d8e
Show file tree
Hide file tree
Showing 4 changed files with 420 additions and 0 deletions.
51 changes: 51 additions & 0 deletions prototyping/coordinate_systems.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

abstract type Handedness end
struct NotHanded <: Handedness end
abstract type HasHanded end
struct RHand <: HasHanded end
struct LHand <: HasHanded end

abstract type CoordinateType end

@kwdef struct Rectangular3D{H <: HasHanded} <: CoordinateType
x::Float64 = 0.0
y::Float64 = 0.0
z::Float64 = 0.0
end

struct Cylindrical3D{H <: HasHanded} <: CoordinateType
r::Float64 = 0.0
θ::Float64 = 0.0
z::Float64 = 0.0
end

struct Spherical3D{H <: HasHanded} <: CoordinateType
ρ::Float64 = 0.0
θ::Float64 = 0.0
φ::Float64 = 0.0
end

struct HorizontalPolar2D{H <: HasHanded} <: CoordinateType
r::Float64 = 0.0
θ::Float64 = 0.0
end

struct VerticalPolar2D{H <: HasHanded} <: CoordinateType
r::Float64 = 0.0
φ::Float64 = 0.0
end

struct Spherical2D{H <: HasHanded} <: CoordinateType
θ::Float64 = 0.0
φ::Float64 = 0.0
end

struct Vertical{H <: HasHanded} <: CoordinateType
z = 0.0
end

struct Horizontal{H <: NotHanded} <: CoordinateType
r = 0.0
end

CoordinateType(::Function) = Rectangular3D{LHand}()
85 changes: 85 additions & 0 deletions prototyping/environmental_profiles.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## Coordinate Handedness
abstract type Handedness end

struct UnHanded <: Handedness end

abstract type IsHanded <: Handedness end

struct RHand <: IsHanded end
struct LHand <: IsHanded end

## Coordinate System
abstract type CoordinateSystem end

struct Rectangular3D{H <: IsHanded} <: CoordinateSystem end
struct Cylindrical3D{H <: IsHanded} <: CoordinateSystem end
struct Spherical3D{H <: IsHanded} <: CoordinateSystem end

struct HorizontalPolar2D{H <: IsHanded} <: CoordinateSystem end
struct VerticalPolar2D{H <: IsHanded} <: CoordinateSystem end
struct Spherical2D{H <: IsHanded} <: CoordinateSystem end

struct Vertical{H <: IsHanded} <: CoordinateSystem end
struct Horizontal{H <: UnHanded} <: CoordinateSystem end

struct Constant{H <: UnHanded} <: CoordinateSystem end

## Coordinate Transformations


## Modelling Abstractions
struct Model{M} end
Model(M::Symbol) = Model{M}()

abstract type OceanSonarModel <: Function end

(OSM where {OSM <: OceanSonarModel})(M::Symbol, args...; kw...) = OSM(M |> Model, args...; kw...)

abstract type ProfileFunction <: OceanSonarModel end

abstract type ProfileFunctor <: OceanSonarModel end

function (profile_functor::ProfileFunctor)(M |> Model, centre::Real...; pars::Real...)
profile_functor
end

## Model Definition
struct SoundSpeedFunctionType <: ProfileFunction end

const sound_speed = SoundSpeedFunctionType()

sound_speed(::Model{:Homogeneous}; c::Real) = c

CoordinateSystem(::SoundSpeedFunctionType, ::Model{:Homogeneous}) = Constant{UnHanded}()

function sound_speed(::Model{:Munk}, z::Real; ϵ::Real = 7.37e-3)
= 2(z/1300 - 1)
return 1500(
1 + ϵ * (
- 1 + exp(-z̃)
)
)
end

CoordinateSystem(::SoundSpeedFunctionType, ::Model{:Munk}) = Vertical{LHand}()

## Model Type
struct SoundSpeed{M, ProfileFunctionType} <: ProfileFunctor
model::Model{M}
profile::ProfileFunctionType

function SoundSpeed(model::Model{M}, centre) where {M}
profile()
end
end

function (cel::SoundSpeed)(::Type{<:CoordinateSystem}, args...)

end

## Model Instantiation
sound_speed = SoundSpeed(:Munk, centre)

## Model Usage

sound_speed()
222 changes: 222 additions & 0 deletions prototyping/sonar_modelling.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
## Symbols
(
c = ("Sound Speed", )
)

## Modelling
struct Model{M} end
Model(M::Symbol) = Model{M}()

abstract type ModellingType <: Function end

(mt::ModellingType)(M::Symbol, args...; kw...) = mt(M |> Model, args...; kw...)

abstract type ProfileFunctor <: ModellingType end

(PF where {PF <: ProfileFunctor})(M::Symbol, args...; kw...) = PF{M |> Model}(args...; kw...)

## Traits
abstract type Handedness end
struct NotHanded <: Handedness end
abstract type HasHanded end
struct RHand <: HasHanded end
struct LHand <: HasHanded end

abstract type CoordinateType end

### 3D
struct Rectangular3D{H <: HasHanded} <: CoordinateType end

struct Cylindrical3D{H <: HasHanded} <: CoordinateType end

struct Spherical3D{H <: HasHanded} <: CoordinateType end

### 2D
struct HorizontalPolar2D{H <: HasHanded} <: CoordinateType end

struct VerticalPolar2D{H <: HasHanded} <: CoordinateType end

struct Spherical2D{H <: HasHanded} <: CoordinateType end

### 1D
struct Vertical{H <: HasHanded} <: CoordinateType end

struct Horizontal{H <: NotHanded} <: CoordinateType end

### 0D
struct Constant{H <: NotHanded} <: CoordinateType end

CoordinateType(::Function) = Rectangular3D{LHand}()

verticalsignchange(OldHand::H, NewHand::H) where {H <: HasHanded} = 1
verticalsignchange(OldHand::OH, NewHand::NH) where {OH <: HasHanded, NH <: HasHanded} = -1

function convertcoordinates(::VerticalPolar2D{OldHand}, ::Vertical{NewHand}, r::Real, z::Real) where {OldHand <: HasHanded, NewHand <: HasHanded}
return (
verticalsignchange(OldHand, NewHands) * z,
)
end

## Profiles
abstract type ProfileFunction <: ModellingType end

struct SoundSpeedProfileFunction{M} <: ProfileFunction end

const sound_speed_profile{M <: Model} = SoundSpeedProfileFunction{M}()

function sound_speed{Model{:Munk}}(::Vertical{LHand}, z::Real; ϵ::Real = 7.37e-3)
= 2(z/1300 - 1)
return 1500(
1 + ϵ * (
- 1 + exp(-z̃)
)
)
end

##
struct SoundSpeed{M} <: ProfileFunctor
model::Model{M}
profile::Function

function SoundSpeed(model::Model{M}; pars...) where {M}
profile
new{M}(model, profile)
end
end

CoordinateType(::SoundSpeed{:Munk}) = Vertical{LHand}()

function (c::SoundSpeed{M} where {M})(input_coordinate_type::CoordinateType, coords...; pars...)
c.profile(
CoordinateType(c),
convertcoordinates(
input_coordinate_type,
CoordinateType(c),
coords...
)...;
pars...
)
end

function sound_speed(::Model{:Munk}, ::Vertical{LHand}, z::Real; ϵ::Real = 7.37e-3)
= 2(z/1300 - 1)
return 1500(
1 + ϵ * (
- 1 + exp(-z̃)
)
)
end

struct ReflectionCoefficient{M} <: Function
model::Model{M}
end

## Containers
mutable struct Medium
c::SoundSpeed
end

mutable struct Interface
z::Depth
R::ReflectionCoefficient
end

mutable struct Environment
surface::Interface
bottom::Interface

atmosphere::Medium
ocean::Medium
seabed::Medium
end

mutable struct Scenario2D

end

mutable struct Scenario3D

end

## Computations
abstract type Config end

struct BeamConfig <: Config

end

struct Beam
path
pressure

Beam(::Model{:Ray})
Beam(::Model{:Hat})
Beam(::Model{:Gaussian})
end

struct Trace2D <: AbstractVector
beams::Vector{<:Beam}

Trace2D(::Model{:})
end

struct Trace3D <: AbstractArray
beams::Vector{<:Beam}

Trace3D(::Model{:})
end

struct Propagation2D <: AbstractMatrix
positions
pressure

Propagation2D(::Model{:Trace2D}) = new()
Propagation2D(::Model{:Parabolic}) = new()
end

struct Propagation3D
r
z
θ
p

Propagation3D(::Model{:Trace2D}) = new()
Propagation3D(::Model{:Trace3D}) = new()
end

struct Performance2D
r
z

SL
PL
TS
NL
AG
RL
SNR
DT
SE
POD

Performance2D() = new()
end

struct Performance3D
r
z
θ

SL
PL
TS
NL
AG
RL
SNR
DT
SE
POD

Performance3D() = new()
end
Loading

0 comments on commit dcb6d8e

Please sign in to comment.