From ea2991bde16d7c818c1e6beb28d57e429bb93729 Mon Sep 17 00:00:00 2001 From: Aaron Kaw Date: Thu, 15 Aug 2024 06:41:44 +1000 Subject: [PATCH] Implemented nested structures up to Scenario --- demo/fan.jl | 48 +++++++------- demo/interactivity.jl | 18 +++--- ext/OceanSonarGLMakieExt/ray.jl | 4 +- prototyping/sonar_equations.jl | 8 +-- src/00_preliminary/01_general/01_auxiliary.jl | 6 ++ .../02_modelling/02_modelling_types.jl | 4 ++ .../02_modelling/04_spatial_orientation.jl | 10 +-- .../02_modelling/05_generic_behaviour.jl | 9 ++- .../06_modelling_implementations.jl | 13 ++++ .../01_functors/boundary/bathymetry.jl | 1 + .../01_functors/celerity/ocean.jl | 6 +- .../01_functors/reflection_coefficient.jl | 7 ++- .../01_coordinates/01_systems.jl | 6 ++ .../02_containers/02_environment.jl | 0 .../01_interface/00_preliminary.jl | 15 +++++ .../02_environments/01_interface/01_bottom.jl | 24 +++++++ .../01_interface/01_surface.jl | 14 +++++ .../02_media/00_preliminary.jl | 49 +++++++++++++++ .../02_environments/02_media/01_atmosphere.jl | 4 ++ .../02_environments/02_media/01_ocean.jl | 12 ++++ .../02_environments/02_media/01_seabed.jl | 4 ++ .../02_environments/03_environments.jl | 63 +++++++++++++++++++ .../02_containers/03_entity.jl | 35 +++++++++++ .../02_containers/04_scenario.jl | 61 ++++++++++++++++++ .../99_postliminary/precompilation.jl | 10 +-- 25 files changed, 374 insertions(+), 57 deletions(-) delete mode 100644 src/99_postliminary/02_containers/02_environment.jl create mode 100644 src/99_postliminary/02_containers/02_environments/01_interface/00_preliminary.jl create mode 100644 src/99_postliminary/02_containers/02_environments/01_interface/01_bottom.jl create mode 100644 src/99_postliminary/02_containers/02_environments/01_interface/01_surface.jl create mode 100644 src/99_postliminary/02_containers/02_environments/02_media/00_preliminary.jl create mode 100644 src/99_postliminary/02_containers/02_environments/02_media/01_atmosphere.jl create mode 100644 src/99_postliminary/02_containers/02_environments/02_media/01_ocean.jl create mode 100644 src/99_postliminary/02_containers/02_environments/02_media/01_seabed.jl create mode 100644 src/99_postliminary/02_containers/02_environments/03_environments.jl create mode 100644 src/99_postliminary/02_containers/03_entity.jl create mode 100644 src/99_postliminary/02_containers/04_scenario.jl diff --git a/demo/fan.jl b/demo/fan.jl index 8a7834e..c62afc8 100644 --- a/demo/fan.jl +++ b/demo/fan.jl @@ -3,21 +3,18 @@ using OceanSonar using OceanSonar.IntervalArithmetic using CairoMakie -cel = OceanCelerityProfile("Munk") -bty = BathymetryProfile("Flat", z = 5e3) -ati = AltimetryProfile("Flat") - r_min = 0.0 r_max = 100e3 +scen = Scenario("Munk Celerity") fan = Fan("Gaussian", - π/20 * range(-1, 1, 5), - 1e3, r_max, 1e3, - cel, - bty, - ReflectionCoefficientProfile("Reflective"), - ati, - ReflectionCoefficientProfile("Mirror") + π/20 * range(-1, 1, 3), + scen.own.pos.z, 100e3, 1e3, + scen.env.ocn.cel, + scen.env.bot.dpt, + scen.env.bot.rfl, + scen.env.srf.dpt, + scen.env.srf.rfl ) r_ntv = interval(r_min, r_max) @@ -26,9 +23,9 @@ z_max = r_ntv |> bty |> sup fig = Figure() axis = Axis(fig[1, 1], yreversed = true) -celerityheatmap!(axis, cel, r_min, r_max, z_min, z_max) -bathymetryband!(axis, bty, r_min, r_max) -altimetryband!(axis, ati, r_min, r_max) +celerityheatmap!(axis, scen.env.ocn.cel, r_min, r_max, z_min, z_max) +bathymetryband!(axis, scen.env.bot.dpt, r_min, r_max) +altimetryband!(axis, scen.env.srf.dpt, r_min, r_max) raycurves!(axis, fan) display(fig) @@ -38,23 +35,20 @@ using OceanSonar using OceanSonar.IntervalArithmetic using CairoMakie -cel = OceanCelerityProfile("Homogeneous") -bty = BathymetryProfile("Parabolic") -ati = AltimetryProfile("Flat") - r_min = 0.0 r_max = 20e3 z_ref = 5e3 +scen = Scenario("Parabolic Bathymetry") fan = Fan("Gaussian", range(atan(z_ref, r_max), atan(z_ref, r_max/10), 5), - 0.0, r_max, 1e3, - cel, - bty, - ReflectionCoefficientProfile("Reflective"), - ati, - ReflectionCoefficientProfile("Mirror") + scen.own.pos.z, r_max, 1e3, + scen.env.ocn.cel, + scen.env.bot.dpt, + scen.env.bot.rfl, + scen.env.srf.dpt, + scen.env.srf.rfl ) r_ntv = interval(r_min, r_max) @@ -63,9 +57,9 @@ z_max = r_ntv |> bty |> sup fig = Figure() axis = Axis(fig[1, 1], yreversed = true) -celerityheatmap!(axis, cel, r_min, r_max, z_min, z_max) -bathymetryband!(axis, bty, r_min, r_max) -altimetryband!(axis, ati, r_min, r_max) +celerityheatmap!(axis, scen.env.ocn.cel, r_min, r_max, z_min, z_max) +bathymetryband!(axis, scen.env.bot.dpt, r_min, r_max) +altimetryband!(axis, scen.env.srf.dpt, r_min, r_max) raycurves!(axis, fan) display(fig) diff --git a/demo/interactivity.jl b/demo/interactivity.jl index 421f301..0ed07cd 100644 --- a/demo/interactivity.jl +++ b/demo/interactivity.jl @@ -2,9 +2,9 @@ using OceanSonar, GLMakie interactive_raycurves( - OceanCelerityProfile("Munk"), - BathymetryProfile("Flat", z = 5e3), - AltimetryProfile("Flat"); + OceanCelerityProfile(:Munk), + BathymetryProfile(:Flat, z = 5e3), + AltimetryProfile(:Flat); r_max = 100e3, num_rays = 5, min_angle = -π/20, @@ -15,9 +15,9 @@ interactive_raycurves( using OceanSonar, GLMakie interactive_raycurves( - OceanCelerityProfile("Homogeneous"), + OceanCelerityProfile(:Homogeneous), BathymetryProfile("Parabolic"), - AltimetryProfile("Flat"); + AltimetryProfile(:Flat); r_max = 20e3, z_src = 0.0, num_rays = 5, @@ -28,11 +28,11 @@ interactive_raycurves( ## using OceanSonar, GLMakie -cel = OceanCelerityProfile("Homogeneous") -ati = AltimetryProfile("Flat") +cel = OceanCelerityProfile(:Homogeneous) +ati = AltimetryProfile(:Flat) bty = BathymetryProfile("Parabolic") -Rsrf = ReflectionCoefficientProfile("Reflective") -Rbot = ReflectionCoefficientProfile("Mirror") +Rsrf = ReflectionCoefficientProfile(:Reflective) +Rbot = ReflectionCoefficientProfile(:Mirror) r_max = 20e3 z_src = 0.0 diff --git a/ext/OceanSonarGLMakieExt/ray.jl b/ext/OceanSonarGLMakieExt/ray.jl index f702eb4..a48f98b 100644 --- a/ext/OceanSonarGLMakieExt/ray.jl +++ b/ext/OceanSonarGLMakieExt/ray.jl @@ -29,8 +29,8 @@ function interactive_raycurves( range(min_angle, max_angle, num_rays), z₀, r_max, 1e3, cel, - bty, ReflectionCoefficientProfile("Reflective"), - ati, ReflectionCoefficientProfile("Mirror") + bty, ReflectionCoefficientProfile(:Reflective), + ati, ReflectionCoefficientProfile(:Mirror) ) end diff --git a/prototyping/sonar_equations.jl b/prototyping/sonar_equations.jl index 74d0cbb..752c128 100644 --- a/prototyping/sonar_equations.jl +++ b/prototyping/sonar_equations.jl @@ -11,11 +11,11 @@ struct AbsentEntity <: AbstractEntity end mutable struct Entity{ET <: EmissionType} <: AbstractEntity SL::Float64 NL::Float64 - pos::RectangularCoordinate{2} + pos::RectangularCoordinate{DownwardDepth} end function Entity{ETnew <: EmissionType}(ent::Entity{ETold}) where {ETold <: EmissionType} - Entity{ETnew}(field => getpropert(ent, field) for field in fieldnames(Entity)) + Entity{ETnew}(field => getproperty(ent, field) for field in fieldnames(Entity)) end source_level(own::Entity{Signaling}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = own.SL @@ -36,11 +36,11 @@ reverberation_level(env::Environment, prop::SonarPropagation, own::Entity{NoiseO reverberation_level(env::Environment, prop::SonarPropagation, own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::Entity{Signaling} ) = reverberation(env, prop, own, fac) @kwdef struct AcousticConfig - beam_model::ModelName = ModelName("Gaussian") + beam_model::ModelName = ModelName(:Gaussian) end @kwdef struct PropagationConfig - acoustic_config::AcousticConfig = AcousticConfig("BeamTracing") + acoustic_config::AcousticConfig = AcousticConfig(:BeamTracing) end struct SonarPropagation diff --git a/src/00_preliminary/01_general/01_auxiliary.jl b/src/00_preliminary/01_general/01_auxiliary.jl index f34f468..fbf3dd9 100644 --- a/src/00_preliminary/01_general/01_auxiliary.jl +++ b/src/00_preliminary/01_general/01_auxiliary.jl @@ -2,6 +2,12 @@ export uniquesort! export cossin export ⊕ +macro initialise_function() + return quote + function anon end + end +end + const uniquesort! = unique! ∘ sort! const cossin = reverse ∘ sincos diff --git a/src/00_preliminary/02_modelling/02_modelling_types.jl b/src/00_preliminary/02_modelling/02_modelling_types.jl index 8e8dd68..8e49a6b 100644 --- a/src/00_preliminary/02_modelling/02_modelling_types.jl +++ b/src/00_preliminary/02_modelling/02_modelling_types.jl @@ -6,3 +6,7 @@ abstract type ModellingContainer <: ModellingType end abstract type ModellingComputation <: ModellingType end children(T::Type{<:ModellingType}) = subtypes(T) + +abstract type EnvironmentComponent end + +children(T::Type{<:EnvironmentComponent}) = subtypes(T) diff --git a/src/00_preliminary/02_modelling/04_spatial_orientation.jl b/src/00_preliminary/02_modelling/04_spatial_orientation.jl index 145f6d5..bc25428 100644 --- a/src/00_preliminary/02_modelling/04_spatial_orientation.jl +++ b/src/00_preliminary/02_modelling/04_spatial_orientation.jl @@ -1,7 +1,7 @@ -orienter(::SpatialDimensionSize{2}, r::Real; x₀::Real, y₀::Real, θ::Real) = (x₀, y₀) .+ r .* cossin(θ) -orienter(SDS::SpatialDimensionSize{2}, x::Real, y::Real; x₀::Real, y₀::Real, θ::Real) = orienter(SDS, hypot(x, y); x₀ = x₀, y₀ = y₀, θ = θ) -orienter(::SpatialDimensionSize{3}, z::Real; x₀::Real, y₀::Real, θ::Real) = (x₀, y₀, z) -orienter(SDS::SpatialDimensionSize{3}, r::Real, z::Real; x₀::Real, y₀::Real, θ::Real) = orienter(SDS, z; x₀ = x₀, y₀ = y₀, θ = θ) .+ ((r .* cossin(θ))..., 0.0) -orienter(SDS::SpatialDimensionSize{3}, x::Real, y::Real, z::Real; x₀::Real, y₀::Real, θ::Real) = orienter(SDS, hypot(x, y), z; x₀ = x₀, y₀ = y₀, θ = θ) +orient(::SpatialDimensionSize{2}, r::Real; x₀::Real, y₀::Real, θ::Real) = (x₀, y₀) .+ r .* cossin(θ) +orient(SDS::SpatialDimensionSize{2}, x::Real, y::Real; x₀::Real, y₀::Real, θ::Real) = orient(SDS, hypot(x, y); x₀ = x₀, y₀ = y₀, θ = θ) +orient(::SpatialDimensionSize{3}, z::Real; x₀::Real, y₀::Real, θ::Real) = (x₀, y₀, z) +orient(SDS::SpatialDimensionSize{3}, r::Real, z::Real; x₀::Real, y₀::Real, θ::Real) = orient(SDS, z; x₀ = x₀, y₀ = y₀, θ = θ) .+ ((r .* cossin(θ))..., 0.0) +orient(SDS::SpatialDimensionSize{3}, x::Real, y::Real, z::Real; x₀::Real, y₀::Real, θ::Real) = orient(SDS, hypot(x, y), z; x₀ = x₀, y₀ = y₀, θ = θ) # TODO: Let SpatialDimensionSize{3} call SpatialDimensionSize{2} where appropriate diff --git a/src/00_preliminary/02_modelling/05_generic_behaviour.jl b/src/00_preliminary/02_modelling/05_generic_behaviour.jl index 1054d5e..5129d83 100644 --- a/src/00_preliminary/02_modelling/05_generic_behaviour.jl +++ b/src/00_preliminary/02_modelling/05_generic_behaviour.jl @@ -23,10 +23,17 @@ function (FunctorType::Type{<:ModellingFunctor})( pars... ) where {M} modelling_function = ModellingFunction(FunctorType) - profile(args::Real...) = modelling_function(model, orienter(SDS, args...; x₀ = x₀, y₀ = y₀, θ = θ)...; pars...) + profile(args::Real...) = modelling_function(model, orient(SDS, args...; x₀ = x₀, y₀ = y₀, θ = θ)...; pars...) FunctorType{profile |> typeof}(profile) end function (functor::ModellingFunctor)(::SpatialDimensionSize, args::Real...; pars...) functor.profile(args...) end + +# function (container::ModellingContainer)(; kw...) +# ( +# haskey(kw, field) ? kw[field] : @initialise_function() +# for field in fieldnames(container) +# ) |> splat(container) +# end diff --git a/src/00_preliminary/02_modelling/06_modelling_implementations.jl b/src/00_preliminary/02_modelling/06_modelling_implementations.jl index dc0b5be..bf84373 100644 --- a/src/00_preliminary/02_modelling/06_modelling_implementations.jl +++ b/src/00_preliminary/02_modelling/06_modelling_implementations.jl @@ -22,3 +22,16 @@ macro implement_spatially_modelled_function_and_functor(functor_name, spatial_di ModellingFunction(::Type{<:$functor_name}) = $function_name end end + +# macro add_container_defaults_method(container_name) +# container = getproperty(OceanSonar, container_name) +# fields = fieldnames(container) +# @eval begin +# function $container_name(; kw...) +# ( +# haskey(kw, field) ? kw[field] : @initialise_function() +# for field in fields +# ) |> splat($container_name) +# end +# end +# end diff --git a/src/99_postliminary/01_functors/boundary/bathymetry.jl b/src/99_postliminary/01_functors/boundary/bathymetry.jl index 1e64894..176c9f5 100644 --- a/src/99_postliminary/01_functors/boundary/bathymetry.jl +++ b/src/99_postliminary/01_functors/boundary/bathymetry.jl @@ -8,6 +8,7 @@ bathymetry_profile(::ModelName{:Flat}, x::Real, y::Real; z::Real) = z bathymetry_profile(::ModelName{:Epipelagic}, x::Real, y::Real) = 100.0 bathymetry_profile(::ModelName{:Mesopelagic}, x::Real, y::Real) = 1e3 bathymetry_profile(::ModelName{:Bathypelagic}, x::Real, y::Real) = 4e3 +bathymetry_profile(::ModelName{:Deep}, x::Real, y::Real) = 5e3 bathymetry_profile(::ModelName{:Abyssopelagic}, x::Real, y::Real) = 6e3 bathymetry_profile(::ModelName{:Bottomless}, x::Real, y::Real) = Inf diff --git a/src/99_postliminary/01_functors/celerity/ocean.jl b/src/99_postliminary/01_functors/celerity/ocean.jl index ee24802..163797b 100644 --- a/src/99_postliminary/01_functors/celerity/ocean.jl +++ b/src/99_postliminary/01_functors/celerity/ocean.jl @@ -12,4 +12,8 @@ function ocean_celerity_profile(::ModelName{:Munk}, x::Real, y::Real, z::Real; z̃ - 1 + exp(-z̃) ) ) -end \ No newline at end of file +end + +function ocean_celerity_profile(::ModelName{:RefractionSquared}, x::Real, y::Real, z::Real; c₀ = 1550) + c₀ / sqrt(1 + 2.4z / c₀) +end diff --git a/src/99_postliminary/01_functors/reflection_coefficient.jl b/src/99_postliminary/01_functors/reflection_coefficient.jl index 6fa102a..c58b8b5 100644 --- a/src/99_postliminary/01_functors/reflection_coefficient.jl +++ b/src/99_postliminary/01_functors/reflection_coefficient.jl @@ -12,12 +12,13 @@ function (FunctorType::Type{<:ReflectionCoefficientProfile})( pars... ) where {M} modelling_function = ModellingFunction(FunctorType) - profile(r::Real, φ::Real) = modelling_function(model, orienter(SDS, r; x₀ = x₀, y₀ = y₀, θ = θ)..., φ; pars...) - profile(x::Real, y::Real, φ::Real) = modelling_function(model, orienter(SDS, x, y; x₀ = x₀, y₀ = y₀, θ = θ)..., φ; pars...) + profile(r::Real, φ::Real) = modelling_function(model, orient(SDS, r; x₀ = x₀, y₀ = y₀, θ = θ)..., φ; pars...) + profile(x::Real, y::Real, φ::Real) = modelling_function(model, orient(SDS, x, y; x₀ = x₀, y₀ = y₀, θ = θ)..., φ; pars...) FunctorType{profile |> typeof}(profile) end ## Models reflection_coefficient_profile(::ModelName{:Mirror}, x::Real, y::Real, φ::Real) = ComplexF64(-1.0) reflection_coefficient_profile(::ModelName{:Absorbent}, x::Real, y::Real, φ::Real) = ComplexF64(0.0) -reflection_coefficient_profile(::ModelName{:Reflective}, x::Real, y::Real, φ::Real) = ComplexF64(1.0) +reflection_coefficient_profile(::ModelName{:Reflective}, x::Real, y::Real, φ::Real; ϕ::Real = 0.0) = cis(ϕ) +reflection_coefficient_profile(::ModelName{:Translucent}, x::Real, y::Real, φ::Real; ϕ::Real = 0.0) = 0.5cis(ϕ) diff --git a/src/99_postliminary/02_containers/01_coordinates/01_systems.jl b/src/99_postliminary/02_containers/01_coordinates/01_systems.jl index b270f4d..1f08482 100644 --- a/src/99_postliminary/02_containers/01_coordinates/01_systems.jl +++ b/src/99_postliminary/02_containers/01_coordinates/01_systems.jl @@ -11,6 +11,8 @@ struct UpwardDepth <: PositiveDepthDirection end abstract type AbstractCoordinateSystem{DepthDir <: PositiveDepthDirection} end +RectangularCoordinateNaN(DepthDir::Type{<:PositiveDepthDirection}) = RectangularCoordinate{DepthDir}(x = NaN32, y = NaN32, z = NaN32) + @kwdef mutable struct RectangularCoordinate{DepthDir} <: AbstractCoordinateSystem{DepthDir} x::Float32 y::Float32 @@ -28,3 +30,7 @@ end θ::Float32 φ::Float32 end + +# function show(io::IO, ::MIME"text/plain", pos::AbstractCoordinateSystem{DepthDir}) where {DepthDir <: PositiveDepthDirection} + +# end \ No newline at end of file diff --git a/src/99_postliminary/02_containers/02_environment.jl b/src/99_postliminary/02_containers/02_environment.jl deleted file mode 100644 index e69de29..0000000 diff --git a/src/99_postliminary/02_containers/02_environments/01_interface/00_preliminary.jl b/src/99_postliminary/02_containers/02_environments/01_interface/00_preliminary.jl new file mode 100644 index 0000000..08482c7 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/01_interface/00_preliminary.jl @@ -0,0 +1,15 @@ +export Surface +export Bottom + +abstract type InterfaceType <: EnvironmentComponent end + +struct SurfaceInterface <: InterfaceType end +struct BottomInterface <: InterfaceType end + +@kwdef mutable struct AcousticInterface{IT <: InterfaceType} <: ModellingContainer + dpt::Function + rfl::Function +end + +Surface = AcousticInterface{SurfaceInterface} +Bottom = AcousticInterface{BottomInterface} diff --git a/src/99_postliminary/02_containers/02_environments/01_interface/01_bottom.jl b/src/99_postliminary/02_containers/02_environments/01_interface/01_bottom.jl new file mode 100644 index 0000000..d60b3c6 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/01_interface/01_bottom.jl @@ -0,0 +1,24 @@ +AcousticInterface{BottomInterface}(::ModelName{:ReflectiveDeep}) = AcousticInterface{BottomInterface}( + dpt = BathymetryProfile(:Deep), + rfl = ReflectionCoefficientProfile(:Reflective), +) + +AcousticInterface{BottomInterface}(::ModelName{:AbsorbentDeep}) = AcousticInterface{BottomInterface}( + dpt = BathymetryProfile(:Deep), + rfl = ReflectionCoefficientProfile(:Absorbent) +) + +AcousticInterface{BottomInterface}(::ModelName{:TranslucentDeep}) = AcousticInterface{BottomInterface}( + dpt = BathymetryProfile(:Deep), + rfl = ReflectionCoefficientProfile(:Translucent) +) + +AcousticInterface{BottomInterface}(::ModelName{:ParabolicBathymetry}) = AcousticInterface{BottomInterface}( + dpt = BathymetryProfile(:Parabolic), + rfl = ReflectionCoefficientProfile(:Reflective) +) + +AcousticInterface{BottomInterface}(::ModelName{:AbsorbentMesopelagic}) = AcousticInterface{BottomInterface}( + dpt = BathymetryProfile(:Mesopelagic), + rfl = ReflectionCoefficientProfile(:Absorbent) +) diff --git a/src/99_postliminary/02_containers/02_environments/01_interface/01_surface.jl b/src/99_postliminary/02_containers/02_environments/01_interface/01_surface.jl new file mode 100644 index 0000000..ca65f0b --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/01_interface/01_surface.jl @@ -0,0 +1,14 @@ +AcousticInterface{SurfaceInterface}(::ModelName{:Mirror}) = AcousticInterface{SurfaceInterface}( + dpt = AltimetryProfile(:Flat), + rfl = ReflectionCoefficientProfile(:Mirror) +) + +AcousticInterface{SurfaceInterface}(::ModelName{:Absorbent}) = AcousticInterface{SurfaceInterface}( + dpt = AltimetryProfile(:Flat), + rfl = ReflectionCoefficientProfile(:Absorbent) +) + +AcousticInterface{SurfaceInterface}(::ModelName{:Translucent}) = AcousticInterface{SurfaceInterface}( + dpt = AltimetryProfile(:Flat), + rfl = ReflectionCoefficientProfile(:Translucent; ϕ = π) +) diff --git a/src/99_postliminary/02_containers/02_environments/02_media/00_preliminary.jl b/src/99_postliminary/02_containers/02_environments/02_media/00_preliminary.jl new file mode 100644 index 0000000..10acc9f --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/02_media/00_preliminary.jl @@ -0,0 +1,49 @@ +export Atmosphere +export Ocean +export Seabed + +abstract type MediumType <: EnvironmentComponent end + +struct AtmosphereMedium <: MediumType end +struct OceanMedium <: MediumType end +struct SeabedMedium <: MediumType end + +mutable struct AcousticMedium{MT <: MediumType} <: ModellingContainer + den::Function + wnd::Function + cel::Function + shear_cel::Function + atn::Function + shear_atn::Function +end + +Atmosphere = AcousticMedium{AtmosphereMedium} +Ocean = AcousticMedium{OceanMedium} +Seabed = AcousticMedium{SeabedMedium} + +AcousticMedium{AtmosphereMedium}(; + den::Function = AtmosphereDensityProfile(:Homogeneous), + wnd::Function = @initialise_function, + cel::Function = AtmosphereCelerityProfile(:Homogeneous), + shear_cel::Function = @initialise_function, + atn::Function = @initialise_function, + shear_atn::Function = @initialise_function, +) = AcousticMedium{AtmosphereMedium}(den, wnd, cel, shear_cel, atn, shear_atn) + +AcousticMedium{OceanMedium}(; + den::Function = OceanDensityProfile(:Homogeneous), + wnd::Function = @initialise_function, + cel::Function = OceanCelerityProfile(:Munk), + shear_cel::Function = @initialise_function, + atn::Function = @initialise_function, + shear_atn::Function = @initialise_function, +) = AcousticMedium{OceanMedium}(den, wnd, cel, shear_cel, atn, shear_atn) + +AcousticMedium{SeabedMedium}(; + den::Function = SeabedDensityProfile(:Homogeneous), + wnd::Function = @initialise_function, + cel::Function = SeabedCelerityProfile(:Homogeneous), + shear_cel::Function = @initialise_function, + atn::Function = @initialise_function, + shear_atn::Function = @initialise_function, +) = AcousticMedium{SeabedMedium}(den, wnd, cel, shear_cel, atn, shear_atn) diff --git a/src/99_postliminary/02_containers/02_environments/02_media/01_atmosphere.jl b/src/99_postliminary/02_containers/02_environments/02_media/01_atmosphere.jl new file mode 100644 index 0000000..6aba877 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/02_media/01_atmosphere.jl @@ -0,0 +1,4 @@ +AcousticMedium{AtmosphereMedium}(::ModelName{:Calm}) = AcousticMedium{AtmosphereMedium}( + cel = AtmosphereCelerityProfile(:Homogeneous), + den = AtmosphereDensityProfile(:Homogeneous) +) diff --git a/src/99_postliminary/02_containers/02_environments/02_media/01_ocean.jl b/src/99_postliminary/02_containers/02_environments/02_media/01_ocean.jl new file mode 100644 index 0000000..4ff04b5 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/02_media/01_ocean.jl @@ -0,0 +1,12 @@ +AcousticMedium{OceanMedium}(::ModelName{:Homogeneous}) = AcousticMedium{OceanMedium}( + cel = OceanCelerityProfile(:Homogeneous), + den = OceanCelerityProfile(:Homogeneous), +) + +AcousticMedium{OceanMedium}(::ModelName{:MunkCelerity}) = AcousticMedium{OceanMedium}( + cel = OceanCelerityProfile(:Munk), +) + +AcousticMedium{OceanMedium}(::ModelName{:SquaredRefractionProfile}) = AcousticMedium{OceanMedium}( + cel = OceanCelerityProfile(:SquaredRefraction) +) diff --git a/src/99_postliminary/02_containers/02_environments/02_media/01_seabed.jl b/src/99_postliminary/02_containers/02_environments/02_media/01_seabed.jl new file mode 100644 index 0000000..319f931 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/02_media/01_seabed.jl @@ -0,0 +1,4 @@ +AcousticMedium{SeabedMedium}(::ModelName{:Homogeneous}) = AcousticMedium{SeabedMedium}( + cel = SeabedCelerityProfile(:Homogeneous), + den = SeabedDensityProfile(:Homogeneous) +) \ No newline at end of file diff --git a/src/99_postliminary/02_containers/02_environments/03_environments.jl b/src/99_postliminary/02_containers/02_environments/03_environments.jl new file mode 100644 index 0000000..24e6465 --- /dev/null +++ b/src/99_postliminary/02_containers/02_environments/03_environments.jl @@ -0,0 +1,63 @@ +export Environment + +mutable struct Environment <: ModellingContainer + srf::AcousticInterface{SurfaceInterface} + bot::AcousticInterface{BottomInterface} + + atm::AcousticMedium{AtmosphereMedium} + ocn::AcousticMedium{OceanMedium} + sbd::AcousticMedium{SeabedMedium} + + orienter::Function + + function Environment(; + ocn::AcousticMedium{OceanMedium} = AcousticMedium{OceanMedium}(:Homogeneous), + bot::AcousticInterface{BottomInterface} = AcousticInterface{BottomInterface}(:TranslucentDeep), + atm::AcousticMedium{AtmosphereMedium} = AcousticMedium{AtmosphereMedium}(:Calm), + srf::AcousticInterface{SurfaceInterface} = AcousticInterface{SurfaceInterface}(:Translucent), + sbd::AcousticMedium{SeabedMedium} = AcousticMedium{SeabedMedium}(:Homogeneous), + orienter::Function = (args...) -> orient(SpatialDimensionSize{3}, args...; x₀ = 0.0, y₀ = 0.0, θ = 0.0) + ) + new(srf, bot, atm, ocn, sbd, orienter) + end +end + +## Models +Environment(::ModelName{:SphericalSpreading}) = Environment( + ocn = AcousticMedium{OceanMedium}(:Homogeneous), + bot = AcousticInterface{BottomInterface}(:AbsorbentDeep), + srf = AcousticInterface{BottomInterface}(:Absorbent) +) + +Environment(::ModelName{:CylindricalSpreading}) = Environment( + ocn = AcousticMedium{OceanMedium}(:Homogeneous), + bot = AcousticInterface{BottomInterface}(:ReflectiveDeep), + srf = AcousticInterface{BottomInterface}(:Reflective) +) + +Environment(::ModelName{:SurfaceLloydMirror}) = Environment( + ocn = AcousticMedium{OceanMedium}(:Homogeneous), + bot = AcousticInterface{BottomInterface}(:AbsorbentDeep), + srf = AcousticInterface{BottomInterface}(:Reflective) +) + +Environment(::ModelName{:BottomLloydMirror}) = Environment( + ocn = AcousticMedium{OceanMedium}(:Homogeneous), + bot = AcousticInterface{BottomInterface}(:AbsorbentDeep), + srf = AcousticInterface{BottomInterface}(:Reflective) +) + +Environment(::ModelName{:MunkCelerity}) = Environment( + ocn = AcousticMedium{OceanMedium}(:MunkCelerity), + bot = AcousticInterface{BottomInterface}(:ReflectiveDeep) +) + +Environment(::ModelName{:ParabolicBathymetry}) = Environment( + ocn = AcousticMedium{OceanMedium}(:Homogeneous), + bot = AcousticInterface{BottomInterface}(:ParabolicBathymetry) +) + +Environment(::ModelName{:SquaredRefractionCelerity}) = Environment( + ocn = AcousticMedium{OceanMedium}(:SquaredRefractionCelerity), + bot = AcousticInterface{BottomInterface}(:AbsorbentMesopelagic) +) diff --git a/src/99_postliminary/02_containers/03_entity.jl b/src/99_postliminary/02_containers/03_entity.jl new file mode 100644 index 0000000..5e446c3 --- /dev/null +++ b/src/99_postliminary/02_containers/03_entity.jl @@ -0,0 +1,35 @@ +export Entity + +abstract type EmissionType end + +struct NoiseOnly <: EmissionType end +struct Signaling <: EmissionType end + +abstract type AbstractEntity <: ModellingContainer end + +struct AbsentEntity <: AbstractEntity end + +@kwdef mutable struct Entity{ET <: EmissionType} <: AbstractEntity + SL::Float32 = NaN32 + NL::Float32 = NaN32 + pos::RectangularCoordinate{DownwardDepth} = RectangularCoordinate{DownwardDepth}(x = 0, y = 0, z = 0) +end + +# Entity{NoiseOnly}(; +# SL = NaN32, +# NL::Real, +# pos::RectangularCoordinate{DownwardDepth} +# ) = Entity{NoiseOnly}(SL = SL, NL = NL, pos = pos) + +# Entity{Signaling}(; +# SL::Real, +# NL::Real = 0, +# pos::RectangularCoordinate{DownwardDepth} +# ) = Entity{Signaling}(SL = SL, NL = NL, pos = pos) + +# function Entity{ETnew <: EmissionType}(ent::Entity{ETold}) where {ETold <: EmissionType} +# Entity{ETnew}( +# field => getproperty(ent, field) +# for field in fieldnames(Entity) +# ) +# end diff --git a/src/99_postliminary/02_containers/04_scenario.jl b/src/99_postliminary/02_containers/04_scenario.jl new file mode 100644 index 0000000..0a73259 --- /dev/null +++ b/src/99_postliminary/02_containers/04_scenario.jl @@ -0,0 +1,61 @@ +export Scenario + +@kwdef mutable struct Scenario <: ModellingContainer + env::Environment + own::AbstractEntity + tgt::AbstractEntity + fac::AbstractEntity = AbsentEntity() +end + +Scenario(::ModelName{:SphericalSpreading}) = Scenario( + env = Environment(:SphericalSpreading), + own = Entity{NoiseOnly}( + NL = 3, + pos = RectangularCoordinate{DownwardDepth}( + x = 0, + y = 0, + z = env.bot.dpt(0, 0) / 2 + ) + ), + tgt = Entity{Signaling}(SL = 100.0) +) + +Scenario(::ModelName{:CylindricalSpreading}) = Scenario( + env = Environment(:CylindricalSpreading), + own = Entity{NoiseOnly}( + NL = 3, + pos = RectangularCoordinate{DownwardDepth}( + x = 0, + y = 0, + z = env.bot.dpt(0, 0) / 2 + ) + ), + tgt = Entity{Signaling}(SL = 100.0) +) + +Scenario(::ModelName{:MunkCelerity}) = Scenario( + env = Environment(:MunkCelerity), + own = Entity{NoiseOnly}( + NL = 3, + pos = RectangularCoordinate{DownwardDepth}(x = 0, y = 0, z = 1e3) + ), + tgt = Entity{Signaling}(SL = 100.0) +) + +Scenario(::ModelName{:ParabolicBathymetry}) = Scenario( + env = Environment(:ParabolicBathymetry), + own = Entity{NoiseOnly}( + NL = 3, + pos = RectangularCoordinate{DownwardDepth}(x = 0, y = 0, z = 0) + ), + tgt = Entity{Signaling}(SL = 100.0) +) + +Scenario(::ModelName{:SquaredRefractionCelerity}) = Scenario( + env = Environment(:SquaredRefractionCelerity), + own = Entity{NoiseOnly}( + NL = 3, + pos = RectangularCoordinate{DownwardDepth}(x = 0, y = 0, z = 0) + ), + tgt = Entity{Signaling}(SL = 100.0) +) diff --git a/src/99_postliminary/99_postliminary/precompilation.jl b/src/99_postliminary/99_postliminary/precompilation.jl index 92c0ecf..71ec06a 100644 --- a/src/99_postliminary/99_postliminary/precompilation.jl +++ b/src/99_postliminary/99_postliminary/precompilation.jl @@ -1,9 +1,9 @@ @setup_workload begin - cel = OceanCelerityProfile("Munk") - bty = BathymetryProfile("Flat", z = 5e3) - Rbot = ReflectionCoefficientProfile("Reflective") - ati = AltimetryProfile("Flat") - Rsrf = ReflectionCoefficientProfile("Mirror") + cel = OceanCelerityProfile(:Munk) + bty = BathymetryProfile(:Flat, z = 5e3) + Rbot = ReflectionCoefficientProfile(:Reflective) + ati = AltimetryProfile(:Flat) + Rsrf = ReflectionCoefficientProfile(:Mirror) @compile_workload begin fan = Fan(