Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DiffusiveShockAccelerationModels"
uuid = "66fc4661-a670-4cc2-b407-bfd81989e880"
authors = ["Ludwig Böss"]
version = "0.1.2"
version = "0.2.0"

[deps]
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand Down
32 changes: 26 additions & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ Kang24_e
![Kang 2024 DSA model](Kang2024.png)


Version `v0.2` included the model by [Gupta et al. (2025)](https://arxiv.org/pdf/1805.00128.pdf)

```@docs
Gupta24_e
```


You can also use the constant efficiency used by [Pfrommer et al. (2017)](https://ui.adsabs.harvard.edu/abs/2017MNRAS.465.4500P/abstract):

```@docs
Expand Down Expand Up @@ -94,12 +101,24 @@ kr_fitting_function

# Magnetic field angle dependent efficiency models

Another parameter in the acceleration efficiency is the shock obliquity. Here we used the results from [Pais et al. (2019)](http://arxiv.org/abs/1907.04300) who fit a functional form to the data by [Caprioli&Spitkovsky (2014)](https://ui.adsabs.harvard.edu/abs/2014ApJ...783...91C/abstract).
Another parameter in the acceleration efficiency is the shock obliquity.

```@docs
η_B
```

Here we provide the results from [Pais et al. (2019)](http://arxiv.org/abs/1907.04300) who fit a functional form to the data by [Caprioli&Spitkovsky (2014)](https://ui.adsabs.harvard.edu/abs/2014ApJ...783...91C/abstract).

```@docs
Pais2018_t
```

Or for electrons we supply the model by Gupta et al. (2024).

```@docs
Gupta2024_t
```

## Ions

Ions are found to be accelerated primarily at quasi-parallel shocks. We provide two helper functions for this.
Expand All @@ -114,7 +133,7 @@ Ions are found to be accelerated primarily at quasi-parallel shocks. We provide

## Electrons

Electrons are found to be accelerated primarily at quasi-perpendicular shocks. We provide two helper functions for this.
Electron acceleration can be modeled via

```@docs
ηB_acc_e
Expand All @@ -131,13 +150,14 @@ To use for example the mach number dependent model by [Kang & Ryu (2013)](https:
```julia
using DiffusiveShockAccelerationModels

ηM_model = KR13() # Mach number dependent model
Mach = 5.0 # we assume a Mach 5 shock
θ_B = 0.1π # angle between shock normal and magnetic field vector
ηM_model = KR13() # Mach number dependent model
ηM_model = Pais2018_t() # Obliquity dependent model
Mach = 5.0 # we assume a Mach 5 shock
θ_B = 0.1π # angle between shock normal and magnetic field vector
X_cr = 0.0 # X_cr = P_cr / P_th -> in this case no pre-existing CRs

# magnetic field angle dependent acc. efficiency
ηB = ηB_acc_p(θ_B)
ηB = ηB_acc_p(ηB_model, θ_B)

# Mach number dependent acc. efficiency
ηM = η_Ms(ηM_model, Mach, X_cr)
Expand Down
51 changes: 51 additions & 0 deletions src/B_models/gupta.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""
Gupta2024_t(X_cr::T=0.05) where T

Efficiency model by Gupta2024_t, Caprioli & Spitkovsky 2024: MNRAS, 478, 4, 5278–5295, https://arxiv.org/pdf/1805.00128.pdf

## Values
- `X_cr`: P_cr / P_th defined in model for re-acceleration. Basis for interpolation between acceleration and re-acceleration efficiency.
"""
struct Gupta2024_t{T} <: AbstractShockAccelerationEfficiency
X_cr::T
Gupta2024_t(X_cr::T = 0.05) where {T} = new{T}(X_cr)
end

"""
η_B(η_model::Gupta2024_t, θ_B::Real, θ_crit::Real)

Calculate B angle dependent efficiency component following Pais et. al. 2018, eq. 7, https://arxiv.org/pdf/1805.00128.pdf
"""
@inline function η_B(η_model::Gupta2024_t, θ_B::Real, θ_crit::Real)
(tanh((θ_crit - θ_B) / π / 18) + 1) / 2
end

"""
ηB_acc_p(η_model::Gupta2024_t, θ_B::Real)

Magnetic field geometry dependent efficiency for protons at initial acceleration.
"""
function ηB_acc_p(η_model::Gupta2024_t, θ_B::Real)
η_B(η_model, θ_B, π / 3.5)
end

"""
ηB_reacc_p(η_model::Gupta2024_t, θ_B::Real)

Magnetic field geometry dependent efficiency for protons at reacceleration.
"""
ηB_reacc_p(η_model::Gupta2024_t, θ_B::Real) = ηB_acc_p(η_model, θ_B)

"""
ηB_acc_e(η_model::Gupta2024_t, θ_B::Real)

Magnetic field geometry dependent efficiency for electrons at initial acceleration.
"""
ηB_acc_e(η_model::Gupta2024_t, θ_B::Real) = ηB_acc_p(η_model, θ_B)

"""
ηB_reacc_e(η_model::Gupta2024_t, θ_B::Real)

Magnetic field geometry dependent efficiency for electrons at reacceleration.
"""
ηB_reacc_e(η_model::Gupta2024_t, θ_B::Real) = ηB_acc_p(η_model, θ_B)
33 changes: 24 additions & 9 deletions src/B_models/pais.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@ const π_third = π / 3
const π_fourth = π / 4
const π_sixth = π / 6


"""
Pais2018_t(X_cr::T=0.05) where T

Efficiency model by Pais et al. 2018: MNRAS, 478, 4, 5278–5295, https://arxiv.org/pdf/1805.00128.pdf

## Values
- `X_cr`: P_cr / P_th defined in model for re-acceleration. Basis for interpolation between acceleration and re-acceleration efficiency.
"""
struct Pais2018_t{T} <: AbstractShockAccelerationEfficiency
X_cr::T
Pais2018_t(X_cr::T = 0.05) where {T} = new{T}(X_cr)
end


"""
η_B(θ_B::Real, θ_crit::Real)

Calculate B angle dependent efficiency component following Pais et. al. 2018, eq. 7, https://arxiv.org/pdf/1805.00128.pdf
"""
@inline function η_B(θ_B::Real, θ_crit::Real)
@inline function η_B(η_model::Pais2018_t, θ_B::Real, θ_crit::Real)
(tanh((θ_crit - θ_B) / δθ) + 1) / 2
end

Expand All @@ -17,33 +32,33 @@ end

Magnetic field geometry dependent efficiency for protons at initial acceleration.
"""
function ηB_acc_p(θ_B::Real)
η_B(θ_B, π_fourth)
function ηB_acc_p(η_model::Pais2018_t, θ_B::Real)
η_B(η_model, θ_B, π_fourth)
end

"""
ηB_reacc_p(θ_B::Real)

Magnetic field geometry dependent efficiency for protons at reacceleration.
"""
function ηB_reacc_p(θ_B::Real)
η_B(θ_B, π_third)
function ηB_reacc_p(η_model::Pais2018_t, θ_B::Real)
η_B(η_model, θ_B, π_third)
end

"""
ηB_acc_e(θ_B::Real)

Magnetic field geometry dependent efficiency for electrons at initial acceleration.
"""
function ηB_acc_e(θ_B::Real)
1 - η_B(θ_B, π_fourth)
function ηB_acc_e(η_model::Pais2018_t, θ_B::Real)
1 - η_B(η_model, θ_B, π_fourth)
end

"""
ηB_reacc_e(θ_B::Real)

Magnetic field geometry dependent efficiency for electrons at reacceleration.
"""
function ηB_reacc_e(θ_B::Real)
1 - η_B(θ_B, π_sixth)
function ηB_reacc_e(η_model::Pais2018_t, θ_B::Real)
1 - η_B(η_model, θ_B, π_sixth)
end
24 changes: 18 additions & 6 deletions src/DiffusiveShockAccelerationModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export AbstractShockAccelerationEfficiency,
# efficiency models
Kang07, KR13, CS14, Ryu19, P16,
Kang24_p, Kang24_e,
Gupta24_e,
Gupta2024_t, Pais2018_t,
# mach nummber dependent efficiency
η_Ms, η_Ms_acc, η_Ms_reacc,
# B-field dependent efficiency
Expand Down Expand Up @@ -75,22 +77,29 @@ function η_Ms(η_model::AbstractShockAccelerationEfficiency, M::T, X_cr::T) whe
end



include("mach_models/Kang07.jl")
include("mach_models/KR13.jl")
include("mach_models/CS14.jl")
include("mach_models/Ryu19.jl")
include("mach_models/Pfrommer16.jl")
include("mach_models/Kang24.jl")
include("mach_models/Gupta24.jl")

include("B_models/pais.jl")
include("B_models/gupta.jl")

ηB_acc_p(θ_B::Real) = ηB_acc_p(Pais2018_t(), θ_B)
ηB_acc_e(θ_B::Real) = ηB_acc_e(Pais2018_t(), θ_B)
ηB_reacc_p(θ_B::Real) = ηB_reacc_p(Pais2018_t(), θ_B)
ηB_reacc_e(θ_B::Real) = ηB_reacc_e(Pais2018_t(), θ_B)

using PrecompileTools # this is a small dependency

@setup_workload begin
# Putting some things in `setup` can reduce the size of the
# precompile file and potentially make loading faster.
η_models = [Kang07(), KR13(), CS14(), Ryu19(), Kang24_p(), Kang24_e()]
η_models = [Kang07(), KR13(), CS14(), Ryu19(), Kang24_p(), Kang24_e(), Gupta24_e()]
B_models = [Pais2018_t(), Gupta2024_t()]

@compile_workload begin
# all calls in this block will be precompiled, regardless of whether
Expand All @@ -109,10 +118,13 @@ using PrecompileTools # this is a small dependency
end
end

ηB_acc_p(1.0)
ηB_reacc_p(1.0)
ηB_acc_e(1.0)
ηB_reacc_e(1.0)
# loop over models
for η ∈ B_models
ηB_acc_p(η, 1.0)
ηB_reacc_p(η, 1.0)
ηB_acc_e(η, 1.0)
ηB_reacc_e(η, 1.0)
end
end
end

Expand Down
39 changes: 39 additions & 0 deletions src/mach_models/Gupta24.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Gupta24_e(X_cr::T=1.0, η_max::T=0.0004871685) where T

Efficiency model for electrons by Gupta, Caprioli & Sptikovsky (2024)

## Values
- `X_cr`: P_cr / P_th defined in model for re-acceleration. Basis for interpolation between acceleration and re-acceleration efficiency.
- `η_max`: Maximum efficiency defined in the model
"""
struct Gupta24_e{T} <: AbstractShockAccelerationEfficiency
X_cr::T
η_max::T

Gupta24_e(X_cr::T = 1.0, η_max::T = 0.05) where {T} = new{T}(X_cr, η_max)
end


"""
η_Ms_acc(η_model::Gupta24_e, M::Real)

Initial acceleration efficiency model for electrons by Gupta, Caprioli & Sptikovsky (2024)
"""
function η_Ms_acc(η_model::Gupta24_e, M::Real)
if M < 2.0
return 0
else
p = [19.301588195907662, -0.6544505664085758, 30053.623240151297, -2.420544376432326, 0.0024391157810159103]
return (p[1] * M^p[2] / (1 + p[3] * M^p[4]) + p[5]) * 0.25
end
end

"""
η_Ms_reacc(η_model::Gupta24_e, M::Real)

Reacceleration efficiency for model by Kang (2024), identical to acceleration efficiency.
"""
function η_Ms_reacc(η_model::Gupta24_e, M::Real)
η_Ms_acc(η_model, M)
end