AcceleratorSimUtils
Documentation for AcceleratorSimUtils.
AcceleratorSimUtils.calc_1β
AcceleratorSimUtils.calc_E_kinetic
AcceleratorSimUtils.calc_E_tot
AcceleratorSimUtils.calc_changed_energy
AcceleratorSimUtils.calc_pc
AcceleratorSimUtils.calc_β
AcceleratorSimUtils.calc_γ
AcceleratorSimUtils.coscu
AcceleratorSimUtils.gen_pinknoise
AcceleratorSimUtils.modulo2
AcceleratorSimUtils.one_cos
AcceleratorSimUtils.sincu
AcceleratorSimUtils.sqrt_one
AcceleratorSimUtils.calc_1β
— Functioncalc_1β(mass; E_tot = nothing, pc = nothing, E_kinetic = nothing, γ = nothing) -> 1-β
calc_1β(species; E_tot = nothing, pc = nothing, E_kinetic = nothing, γ = nothing) -> 1-β
Returns the quantity 1 - β
= 1 - v/c
of a particle given one of E_tot
(total energy), pc
(momentum*c), E_kinetic
(kinetic energy), or γ
(relativistic factor). In the high energy limit, this is approximately 1/(2γ^2)
. calc_1β
is computed such that in the high energy limit, round off error is not a problem.
One and only one of the optional arguments E_tot
, pc
, E_kinetic
, or γ
should be set. All arguments are Numbers
except species
which is of type Species
. The mass
argument is in units of energy/c^2
.
Also see the functions calc_E_tot
; calc_pc
, calc_β
, calc_E_kinetic
, and calc_γ
AcceleratorSimUtils.calc_E_kinetic
— Functioncalc_E_kinetic(mass; E_tot = nothing, pc = nothing, β = nothing, γ = nothing) -> E_kinetic
calc_E_kinetic(species; E_tot = nothing, pc = nothing, β = nothing, γ = nothing) -> E_kinetic
Returns the kinetic energy of a particle in eV
given one of E_tot
(total energy), pc
(momentum*c), β
(velocity/c), or γ
(relativistic factor). One and only one of the optional arguments E_tot
, pc
, β
, or γ
should be set.
All arguments are Numbers
except species
which is of type Species
. The mass
argument is in units of energy/c^2
.
Also see the functions calc_E_tot
; calc_pc
, calc_β
, calc_β1
, and calc_γ
AcceleratorSimUtils.calc_E_tot
— Functioncalc_E_tot(mass; pc = nothing, β = nothing, E_kinetic = nothing, γ = nothing) -> E_tot
calc_E_tot(species; pc = nothing, β = nothing, E_kinetic = nothing, γ = nothing) -> E_tot
Returns the total energy of a particle (in eV
) given one of pc
(momentum*c), β
(velocity/c), E_kinetic
(kinetic energy), or γ
(relativistic factor). One and only one of the optional arguments pc
, β
, E_kinetic
, or γ
should be set. All arguments are Numbers
except species
which is of type Species
.
The mass
argument is in units of energy/c^2
.
Also see the functions calc_pc
, calc_β
, calc_β1
, calc_E_kinetic
, and calc_γ
AcceleratorSimUtils.calc_changed_energy
— Functioncalc_changed_energy(mass; old_pc, dE) -> (pc, E_tot)
calc_changed_energy(species::Species; old_pc, dE) -> (pc, E_tot)
Given an initial old_pc
particle momentum*c
, and a change in energy dE
, calculate the final momentum*c
and total energy. If dE
is too large and negative for there to be a solution, nothing, nothing
is returned. All arguments are Numbers
except species
which is of type Species
.
The mass
argument is in units of energy/c^2
.
The calculation is done in such a way as to not loose precision.
AcceleratorSimUtils.calc_pc
— Functioncalc_pc(mass; E_tot = nothing, β = nothing, E_kinetic = nothing, γ = nothing) -> pc
calc_pc(species; E_tot = nothing, β = nothing, E_kinetic = nothing, γ = nothing) -> pc
Returns the particle momentum*c (in eV
) given one of E_tot
(total energy), β
(velocity/c), E_kinetic
(kinetic energy), or γ
(relativistic factor). One and only one of the optional arguments E_tot
, β
, E_kinetic
, or γ
should be set. All arguments are Numbers
except species
which is of type Species
.
The mass
argument is in units of energy/c^2
.
Also see the functions calc_E_tot
, calc_β
, calc_β1
, calc_E_kinetic
, and calc_γ
AcceleratorSimUtils.calc_β
— Functioncalc_β(mass; E_tot = nothing, pc = nothing, E_kinetic = nothing, γ = nothing) -> β
calc_β(species; E_tot = nothing, pc = nothing, E_kinetic = nothing, γ = nothing) -> β
Returns the normalized velocity β
= v/c
of a particle given one of E_tot
(total energy), pc
(momentum*c), E_kinetic
(kinetic energy), or γ
(relativistic factor). One and only one of the optional arguments E_tot
, pc
, E_kinetic
, or γ
should be set. All arguments are Numbers
except species
which is of type Species
.
The mass
argument is in units of energy/c^2
.
Also see the functions calc_E_tot
, calc_pc
, calc_β1
, calc_E_kinetic
, and calc_γ
AcceleratorSimUtils.calc_γ
— Functioncalc_γ(mass; E_tot = nothing, pc = nothing, β = nothing, E_kinetic = nothing) -> γ
calc_γ(species; E_tot = nothing, pc = nothing, β = nothing, E_kinetic = nothing) -> γ
Returns the relativistic gamma factor of a particle given E_tot
(total energy), pc
(momentum*c), β
(velocity/c), or E_kinetic
(kinetic energy). One and only one of the optional arguments E_tot
, pc
, β
, or E_kinetic
should be set.
All arguments are Numbers
except species
which is of type Species
. The mass
argument is in units of energy/c^2
.
Also see the functions calc_pc
, calc_β
, calc_β1
, calc_E_kinetic
, and calc_γ
AcceleratorSimUtils.coscu
— Functioncoscu(x, nd::Int = 0)
Returns, to machine precision, the nd
th derivative of (1 - cos(x)) / x^2
. If nd = 0
, returns the function itself.
Note: Currently, only nd = 0
or 1
are implemented
AcceleratorSimUtils.gen_pinknoise
— Functionfunction gen_pinknoise( beta::Float64=1.0, size::Int64=2^12, dt::Float64=1.0, f0::Float64=1.0)
Random number generator that has a "pink noise" spectrum with frequency rolloff coefficient beta
.
positional parameter:
- beta – type:Float64, frequency rolloff coefficient
- size – type:Int64, number of points
keyword parameters:
- dt – type:Float64, the difference of between each data, total time = size * dt, unit: s
- f0 – type:Float64, the spectrum has the shape (f0/f)^(beta), unit: Hz.
Note: The algorithm is based on "Timmer, J. and Koenig, M.: On generating power law noise. Astron. Astrophys. 300, 707-710 (1995)"
AcceleratorSimUtils.modulo2
— Function modulo2(x, amp)
Function to return
mod2 = x + 2 * n * amp
where n
is an integer chosen such that
-amp <= mod2 < amp
AcceleratorSimUtils.one_cos
— Functionone_cos(x)
Function to calculate 1 - cos(x)
to machine precision. This is usful if angle can be near zero where the direct evaluation of 1 - cos(x)
is inaccurate.
AcceleratorSimUtils.sincu
— Methodsincu(z, nd::Int = 0)
Returns the unnormalized sinc(z)
(equal to sin(z)/z
, no factors of pi here) for nd = 0
or the nd
th derivative for nd > 0
.
Note: Currently, only nd = 0
or 1
are implemented
AcceleratorSimUtils.sqrt_one
— Functionsqrt_one(x)
Calculate sqrt(1+x) - 1
to machine precision.