Skip to content

Commit

Permalink
Adjust (sub)types
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-petersen committed Jun 10, 2024
1 parent 6ec4872 commit 02075b4
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 103 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DistributionFunctions"
uuid = "c869f47d-2815-40f9-b874-25ebe83f43af"
version = "0.0.8dev"
version = "0.0.9dev"

[deps]
OrbitalElements = "a3b07092-bde3-4843-b84f-c597d614ec7b"
Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/RazorThinDiscs/mestel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
MestelDistribution(EL::Tuple{Float64,Float64},df::MestelDisc)
Mestel distribution function.
"""
function Distribution(EL::Tuple{Float64,Float64},df::MestelDisc)::Float64
function DistributionFunction(EL::Tuple{Float64,Float64},df::MestelDisc)::Float64

return MestelDistribution(EL,df)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/RazorThinDiscs/miyamoto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using HypergeometricFunctions
Miyamoto distribution function for Kuzmin-Toomre disc.
"""
function Distribution(E::Float64, L::Float64; mM::Int64=1)
function DistributionFunction(E::Float64, L::Float64; mM::Int64=1)
return (
(2mM + 3)
* (-E)^(2mM + 2)
Expand Down
24 changes: 12 additions & 12 deletions src/Analytic/RazorThinDiscs/razorthindiscs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ const IntorFloat = Union{Int64,Float64}
#####################################
# Disc distribution functions (analytic)
#####################################
abstract type DiscDistributionFunction <: DistributionFunction end
abstract type MestelPotentialDistributionFunction <: DiscDistributionFunction end
abstract type ZangDistributionFunction <: MestelPotentialDistributionFunction end
abstract type DiscDF <: DiscEnergyAngularMomentumDF end
abstract type MestelPotentialDF <: DiscDF end
abstract type ZangDF <: MestelPotentialDF end

const MestelPotentials = Union{MestelPotential,TaperedMestel}


# @IMPROVE, these potentials are not specific at all: but need to be either MestelPotential or TaperedMestel
struct MestelDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: MestelPotentialDistributionFunction
struct MestelDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: MestelPotentialDF
potential::modelT # potential model
q::qT # velocity dispersion parameter
G::Float64 # gravitational constant (not in MestelPotential or TaperedMestel, so needed here)
end

struct ZangDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: ZangDistributionFunction
struct ZangDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: ZangDF
potential::modelT # potential model
q::qT # velocity dispersion parameter
ν::Int64 # inner taper
Expand All @@ -32,7 +32,7 @@ struct ZangDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: ZangDistributionFunc
G::Float64 # gravitational constant (not in MestelPotential or TaperedMestel, so needed here)
end

struct TruncatedZangDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: ZangDistributionFunction
struct TruncatedZangDisc{modelT<:MestelPotentials,qT<:IntorFloat} <: ZangDF
potential::modelT # potential model
q::qT # velocity dispersion parameter
ν::Int64 # inner taper
Expand All @@ -48,7 +48,7 @@ end
radial velocity dispersion of the tapered Mestel DF
"""
function σMestelDistribution(df::MestelPotentialDistributionFunction)::Float64
function σMestelDistribution(df::MestelPotentialDF)::Float64
return df.potential.V0 / sqrt(df.q+1)
end

Expand All @@ -57,7 +57,7 @@ end
normalization constant of the tapered Mestel DF.
"""
function NormConstMestelDistribution(df::MestelPotentialDistributionFunction)::Float64
function NormConstMestelDistribution(df::MestelPotentialDF)::Float64
σ = σMestelDistribution(df)
return (df.potential.V0)^(2) / ( 2^(df.q/2+1) * (pi)^(3/2) * df.G * gamma(0.5+0.5*df.q) * (σ)^(df.q+2) * (df.potential.R0)^(df.q+1) )
end
Expand All @@ -66,7 +66,7 @@ end
MestelDistribution(EL::Tuple{Float64,Float64},df::MestelDisc)
Mestel distribution function.
"""
function MestelDistribution(EL::Tuple{Float64,Float64},df::MestelPotentialDistributionFunction)::Float64
function MestelDistribution(EL::Tuple{Float64,Float64},df::MestelPotentialDF)::Float64

E,L = EL
σ = σMestelDistribution(df)
Expand All @@ -79,17 +79,17 @@ end
MesteldFdE(EL::Tuple{Float64,Float64},df::MestelDisc)
Mestel DF derivative w.r.t. E.
"""
function MesteldFdE(EL::Tuple{Float64,Float64},df::MestelPotentialDistributionFunction)::Float64
function MesteldFdE(EL::Tuple{Float64,Float64},df::MestelPotentialDF)::Float64

σ = σMestelDistribution(df)
return - Distribution(EL,df) /^2)
return - DistributionFunction(EL,df) /^2)
end

"""
MesteldFdL(E, L[, C, q, sigma])
Mestel DF derivative w.r.t. E.
"""
function MesteldFdL(EL::Tuple{Float64,Float64},df::MestelPotentialDistributionFunction)::Float64
function MesteldFdL(EL::Tuple{Float64,Float64},df::MestelPotentialDF)::Float64

E,L = EL
σ = σMestelDistribution(df)
Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/RazorThinDiscs/truncatedzang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
Zang star distribution function enforcing ra <= Rmax.
"""
function Distribution(EL::Tuple{Float64,Float64},df::TruncatedZangDisc)::Float64
function DistributionFunction(EL::Tuple{Float64,Float64},df::TruncatedZangDisc)::Float64

# will return zero if outside truncated region
result = truncationcriteria(EL::Tuple{Float64,Float64},df::TruncatedZangDisc)
Expand Down
14 changes: 7 additions & 7 deletions src/Analytic/RazorThinDiscs/zang.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
ZangInnerTaper(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang inner tapering.
"""
function ZangInnerTaper(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function ZangInnerTaper(EL::Tuple{Float64,Float64},df::ZangDF)::Float64

E,L = EL
return (L^df.ν) / ( (df.Rin*df.potential.V0)^(df.ν) + (L^df.ν) )
Expand All @@ -27,7 +27,7 @@ end
ZangInnerTaperdL(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang inner tapering derivative.
"""
function ZangInnerTaperdL(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function ZangInnerTaperdL(EL::Tuple{Float64,Float64},df::ZangDF)::Float64

E,L = EL
return (df.Rin*df.potential.V0)^(df.ν) * df.ν * (L)^(df.ν-1) / ( (df.Rin*df.potential.V0)^(df.ν) + (L)^(df.ν) )^(2)
Expand All @@ -37,7 +37,7 @@ end
Zang_outer_tapering(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang outer tapering.
"""
function ZangOuterTaper(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function ZangOuterTaper(EL::Tuple{Float64,Float64},df::ZangDF)::Float64

E,L = EL
return (df.Rout*df.potential.V0)^(df.μ) / ( (df.Rout*df.potential.V0)^(df.μ) + (L^df.μ) )
Expand All @@ -46,7 +46,7 @@ end
Zang_outer_tapering_dL(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang outer tapering derivative.
"""
function ZangOuterTaperdL(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function ZangOuterTaperdL(EL::Tuple{Float64,Float64},df::ZangDF)::Float64

E,L = EL
return - (df.Rout*df.potential.V0)^(df.μ) * df.μ * (L)^(df.μ-1) / ( (df.Rout*df.potential.V0)^(df.μ) + (L)^(df.μ) )^(2)
Expand All @@ -60,23 +60,23 @@ end
F(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang star distribution function.
"""
function Distribution(EL::Tuple{Float64,Float64},df::ZangDisc)::Float64
function DistributionFunction(EL::Tuple{Float64,Float64},df::ZangDisc)::Float64
return MestelDistribution(EL,df) * ZangOuterTaper(EL,df) * ZangInnerTaper(EL,df)
end

"""
dFdE(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang star DF derivative w.r.t. E.
"""
function DFDE(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function DFDE(EL::Tuple{Float64,Float64},df::ZangDF)::Float64
return MesteldFdE(EL,df) * ZangOuterTaper(EL,df) * ZangInnerTaper(EL,df)
end

"""
dFdL(EL::Tuple{Float64,Float64},df::ZangDisc)
Zang star DF derivative w.r.t. L.
"""
function DFDL(EL::Tuple{Float64,Float64},df::ZangDistributionFunction)::Float64
function DFDL(EL::Tuple{Float64,Float64},df::ZangDF)::Float64

mesDF = MestelDistribution(EL,df)
intap = ZangInnerTaper(EL,df)
Expand Down
10 changes: 5 additions & 5 deletions src/Analytic/Spheres/Isochrone/isochrone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
# Isochrone distribution functions (analytic)
#####################################

struct IsotropicIsochrone{modelT<:IsochronePotential} <: EnergyOnlyDistributionFunction
struct IsotropicIsochrone{modelT<:IsochronePotential} <: ErgodicDF
potential::modelT # Potential model
end
struct OsipkovMerrittIsochroneEL{modelT<:IsochronePotential} <: SphericalEnergyAngularMomentumDistributionFunction
struct OsipkovMerrittIsochroneEL{modelT<:IsochronePotential} <: SphericalEnergyAngularMomentumDF
ra::Float64 # Anisotropy radius
potential::modelT # Potential model
end
struct OsipkovMerrittIsochroneJL{modelT<:IsochronePotential} <: SphericalEnergyAngularMomentumDistributionFunction
struct OsipkovMerrittIsochroneJL{modelT<:IsochronePotential} <: SphericalEnergyAngularMomentumDF
ra::Float64 # Anisotropy radius
potential::modelT # Potential model
end

# create a type union for all isochrone distribution functions
const IsochroneDistributionFunction = Union{IsotropicIsochrone,OsipkovMerrittIsochroneEL,OsipkovMerrittIsochroneJL}
const IsochroneDF = Union{IsotropicIsochrone,OsipkovMerrittIsochroneEL,OsipkovMerrittIsochroneJL}

# unify the osipkov-merritt models
const OsipkovMerrittIsochrone = Union{OsipkovMerrittIsochroneEL,OsipkovMerrittIsochroneJL}

"""
the Isochrone distribution function scale
"""
function dfscale(df::IsochroneDistributionFunction)
function dfscale(df::IsochroneDF)
return (df.potential.G*df.potential.M*df.potential.bc)^(-3/2)
end

Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/Spheres/Isochrone/isotropic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
"""Distribution(E[,bc,M,G])
the isotropic DF
"""
function Distribution(EL::Tuple{Float64,Float64}, df::IsotropicIsochrone)
function DistributionFunction(EL::Tuple{Float64,Float64}, df::IsotropicIsochrone)
E,L = EL

scaleEnergy = - df.potential.G * df.potential.M / df.potential.bc
Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/Spheres/Isochrone/osipkovmerritt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ end
Saha distribution function
ra is the anisotropy radius
"""
function Distribution(EL::Tuple{Float64,Float64}, df::OsipkovMerrittIsochrone)::Float64
function DistributionFunction(EL::Tuple{Float64,Float64}, df::OsipkovMerrittIsochrone)::Float64

Q = osipkovmerritt_Q(EL, df)
scaleDF = dfscale(df)
Expand Down
2 changes: 1 addition & 1 deletion src/Analytic/Spheres/Plummer/isotropic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
"""
The distribution function for the isotropic Plummer model
"""
function Distribution(EL::Tuple{Float64,Float64}, df::IsotropicPlummer)
function DistributionFunction(EL::Tuple{Float64,Float64}, df::IsotropicPlummer)
E,L = EL

scaleEnergy = - df.potential.G * df.potential.M / df.potential.bc
Expand Down
3 changes: 2 additions & 1 deletion src/Analytic/Spheres/Plummer/osipkovmerrit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function OsipkovMerrittPlummerEL(ra::Float64; potential::PlummerPotential=Numeri
return OsipkovMerrittPlummerEL(ra,potential)
end
function OsipkovMerrittPlummerJL(ra::Float64; potential::PlummerPotential=NumericalPlummer())
# this doesn't exist. use (E,L) instead
return OsipkovMerrittPlummerJL(ra,potential)
end

Expand Down Expand Up @@ -51,7 +52,7 @@ end
"""
the anisotropic distribution function from PlummerPlus
"""
function Distribution(EL::Tuple{Float64,Float64}, df::OsipkovMerrittPlummer)
function DistributionFunction(EL::Tuple{Float64,Float64}, df::OsipkovMerrittPlummer)

Q = osipkovmerritt_Q(EL, df)
scaleDF = dfscale(df)
Expand Down
10 changes: 5 additions & 5 deletions src/Analytic/Spheres/Plummer/plummer.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
#####################################
# Plummer distribution functions (analytic)
#####################################
struct IsotropicPlummer{modelT<:PlummerPotential} <: EnergyOnlyDistributionFunction
struct IsotropicPlummer{modelT<:PlummerPotential} <: ErgodicDF
potential::modelT # Potential model
end
struct OsipkovMerrittPlummerEL{modelT<:PlummerPotential} <: SphericalEnergyAngularMomentumDistributionFunction
struct OsipkovMerrittPlummerEL{modelT<:PlummerPotential} <: SphericalEnergyAngularMomentumDF
ra::Float64 # Anisotropy radius
potential::modelT # Potential model
end
struct OsipkovMerrittPlummerJL{modelT<:PlummerPotential} <: SphericalActionDistributionFunction
struct OsipkovMerrittPlummerJL{modelT<:PlummerPotential} <: SphericalActionDF
ra::Float64 # Anisotropy radius
potential::modelT # Potential model
end

# create a type union for all Plummer distribution functions
const PlummerDistributionFunction = Union{IsotropicPlummer,OsipkovMerrittPlummerEL,OsipkovMerrittPlummerJL}
const PlummerDF = Union{IsotropicPlummer,OsipkovMerrittPlummerEL,OsipkovMerrittPlummerJL}

# unify the osipkov-merritt methods
const OsipkovMerrittPlummer = Union{OsipkovMerrittPlummerEL,OsipkovMerrittPlummerJL}

"""
the Plummer distribution function scale
"""
function dfscale(df::PlummerDistributionFunction)
function dfscale(df::PlummerDF)
return (df.potential.G*df.potential.M*df.potential.bc)^(-3/2)
end

Expand Down
14 changes: 9 additions & 5 deletions src/DistributionFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ module DistributionFunctions
#####################################
# Dependencies
#####################################
using OrbitalElements # potentials, resonances
using OrbitalElements # potentials


#####################################
# Exports
#####################################
export DistributionFunction
export Distribution,DFDE,DFDL,gradient

# functions common to all DistributionFunction
export distribution,gradient

# types for multiple dispatch
export EnergyOnlyDistributionFunction,EnergyAngularMomentumDistributionFunction,ActionDistributionFunction
export ErgodicDF,EnergyAngularMomentumDF,ActionDF

# spheres
export PlummerDistributionFunction,IsotropicPlummer,OsipkovMerrittPlummerEL,OsipkovMerrittPlummerJL
export IsochroneDistributionFunction,IsotropicIsochrone,OsipkovMerrittIsochroneEL,OsipkovMerrittIsochroneJL
# change to DF
export PlummerDF,IsotropicPlummer,OsipkovMerrittPlummerEL,OsipkovMerrittPlummerJL
export IsochroneDF,IsotropicIsochrone,OsipkovMerrittIsochroneEL,OsipkovMerrittIsochroneJL

# discs
# add DF here
export MestelDisc,ZangDisc,TruncatedZangDisc


Expand Down
Loading

0 comments on commit 02075b4

Please sign in to comment.