AcceleratorSimUtils

Documentation for AcceleratorSimUtils.

AcceleratorSimUtils.calc_1βFunction
calc_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_γ

source
AcceleratorSimUtils.calc_E_kineticFunction
calc_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_γ

source
AcceleratorSimUtils.calc_E_totFunction
calc_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_γ

source
AcceleratorSimUtils.calc_changed_energyFunction
calc_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.

source
AcceleratorSimUtils.calc_pcFunction
calc_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_γ

source
AcceleratorSimUtils.calc_βFunction
calc_β(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_γ

source
AcceleratorSimUtils.calc_γFunction
calc_γ(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_γ

source
AcceleratorSimUtils.coscuFunction

coscu(x, nd::Int = 0)

Returns, to machine precision, the ndth derivative of (1 - cos(x)) / x^2. If nd = 0, returns the function itself.

Note: Currently, only nd = 0 or 1 are implemented

source
AcceleratorSimUtils.gen_pinknoiseFunction

function 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)"

source
AcceleratorSimUtils.one_cosFunction
one_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.

source
AcceleratorSimUtils.sincuMethod

sincu(z, nd::Int = 0)

Returns the unnormalized sinc(z) (equal to sin(z)/z, no factors of pi here) for nd = 0 or the ndth derivative for nd > 0.

Note: Currently, only nd = 0 or 1 are implemented

source