diff --git a/Project.toml b/Project.toml index f6b6b6b..e4de621 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ ReferenceFrameRotations = "74f56ac7-18b3-5285-802d-d4bd4f104033" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -GTPSA = "1" +GTPSA = "1.2.0" ReferenceFrameRotations = "3" StaticArrays = "1" julia = "1.9" diff --git a/src/BeamTracking.jl b/src/BeamTracking.jl index eb55cfc..32cad09 100644 --- a/src/BeamTracking.jl +++ b/src/BeamTracking.jl @@ -59,6 +59,14 @@ function Beam( return Beam(species, coords) end +# Creates a Beam as identity GTPSA +function Beam(d::Descriptor; species::Species=Species("electron")) + GTPSA.numvars(d) == 6 || error("Invalid GTPSA Descriptor! Number of variables must be equal to 6.") + z = vars(d) + return Beam(species, Coords([z[1]], [z[2]], [z[3]], [z[4]], [z[5]], [z[6]])) +end + + # -------------------------------------- diff --git a/src/paraxial/Paraxial.jl b/src/paraxial/Paraxial.jl index f19fc3d..f644117 100644 --- a/src/paraxial/Paraxial.jl +++ b/src/paraxial/Paraxial.jl @@ -1,10 +1,15 @@ module Paraxial using ..BeamTracking: Coords, Beam using ..GTPSA -using ..AcceleratorLattice +#using ..AcceleratorLattice + +struct ParaxialDrift{T} + L::T +end + """ - track!(L, beamf::Beam, beam0::Beam) -> beamf + track!(ele::ParaxialDrift, beamf::Beam, beam0::Beam) -> beamf Routine to tracking through a drift using the paraxial approximation and including higher-order energy effects. @@ -14,13 +19,12 @@ including higher-order energy effects. - `beamf` -- Output beam after tracking through - `beam0` -- Input beam before tracking through """ -function track!(ele::Drift, beamf::Beam, beam0::Beam) +function track!(L, beamf::Beam, beam0::Beam) @assert !(beamf === beam0) "Aliasing beamf === beam0 not allowed!" - L = ele.L z0 = beam0.z zf = beamf.z - - @FastGTPSA begin + + @FastGTPSA! begin @. zf[1] = z0[1]+z0[2]*L/(1.0+z0[6]) @. zf[2] = z0[2] @. zf[3] = z0[3]+z0[4]*L/(1.0+z0[6]) @@ -28,7 +32,9 @@ function track!(ele::Drift, beamf::Beam, beam0::Beam) @. zf[5] = z0[5]-L*((z0[2]^2)+(z0[4]^2))/(1.0+z0[6])^2/2.0 @. zf[6] = z0[6] end + return beamf end + end \ No newline at end of file