Skip to content

Commit

Permalink
update code and GTPSA version, add identity map ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsignorelli committed Sep 15, 2024
1 parent 681e2d9 commit 59c646a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/BeamTracking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


# --------------------------------------


Expand Down
18 changes: 12 additions & 6 deletions src/paraxial/Paraxial.jl
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -14,21 +19,22 @@ 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])
@. zf[4] = z0[4]
@. 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

0 comments on commit 59c646a

Please sign in to comment.