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: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PyFormattedStrings = "5f89f4a4-a228-4886-b223-c468a82ed5b9"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
ReferenceFrameRotations = "74f56ac7-18b3-5285-802d-d4bd4f104033"
SimUtils = "042f21a8-4046-4c2b-b9ed-b6e14110b343"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand All @@ -25,6 +26,7 @@ LinearAlgebra = "1.10"
OrderedCollections = "1.6"
PyFormattedStrings = "0.1"
Random = "1.10"
Reexport = "1.2"
ReferenceFrameRotations = "3"
SimUtils = "0.4"
Test = "1.10"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Ele: "qf" (b1>>2) Quadrupole
1 false 0.0 0.34 Kn1 0.0 Ks1 (1/m^2)
-0.011341179236737171 Bn1 -0.0 Bs1 (T/m^1)
EMultipoleParams: No electric multipoles
OrientationParams:
FloorParams:
r (r_floor) [0.0, 0.0, 0.0] m
q (q_floor) 1.0 + 0.0⋅i + 0.0⋅j + 0.0⋅k
theta (theta_floor) 0.0 rad
Expand Down
2 changes: 1 addition & 1 deletion manual/attic/Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Note: Could also have defined parameters to be Union{Float64,Missing} but this p

* Implementation note: Bookkeeping is element-by-element rather then parameter group by parameter group since
the parameter groups are not necessarily independent. For example, the reference time will depend upon
the OrientationParams if the lattice contains a flexible patch.
the FloorParams if the lattice contains a flexible patch.

* Using Strings for the keys of ele.pdict[] would have worked instead of Symbols. Using Symbols gives
a slightly cleaner look to the code.
Expand Down
2 changes: 1 addition & 1 deletion manual/coordinates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ \section{Branch Coordinates Construction}
branch coordinate system starts at the \vn{BeginningEle} element (\sref{s:begin.ele}) at the start of a
branch. If the branch is a \vn{root} branch (\sref{s:lattice.def}), The orientation of the beginning
element within the floor coordinate system (\sref{s:coords}) can be fixed by setting
\vn{OrientationParams parameters} (\sref{s:orientationition.g}) in the \vn{BeginningEle} element.
\vn{FloorParams parameters} (\sref{s:orientationition.g}) in the \vn{BeginningEle} element.
If the branch is not a \vn{root} branch, the position
of the beginning element is determined by the position of the \vn{Fork} element
from which the branch forks from. The default value of $s$ at the \vn{BeginningEle} element is zero
Expand Down
8 changes: 4 additions & 4 deletions manual/ele-anatomy.tex
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ \section{Element Parameter Paramss}
• ApertureParams -> Vacuum chamber aperture.
• BMultipoleParams -> Magnetic multipoles.
• EMultipoleParams -> Electric multipoles.
OrientationParams -> Floor position and orientation.
FloorParams -> Floor position and orientation.
• LengthParams -> Length and s-position parameters.
• LordSlaveParams -> Element lord and slave status.
• MasterParams -> Contains field_master parameter.
Expand Down Expand Up @@ -135,7 +135,7 @@ \section{Element Parameters}
\begin{example}
julia> info(:theta)
User name: theta_floor
Stored in: OrientationParams.theta
Stored in: FloorParams.theta
Parameter type: Number
Units: rad
Description: Element floor theta angle orientation
Expand All @@ -145,9 +145,9 @@ \section{Element Parameters}
@ele bg = BeginningEle(theta_floor = 0.3) # Set at element definition time.
bg.theta_floor = 2.7 # Or set after definition.
\end{example}
But the component in the \vn{OrientationParams} is \vn{theta} so
But the component in the \vn{FloorParams} is \vn{theta} so
\begin{example}
bg.OrientationParams.theta = 2.7 # Equivalent to the set above.
bg.FloorParams.theta = 2.7 # Equivalent to the set above.
\end{example}

%---------------------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions manual/ele-param-groups.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ \chapter{Element Parameter Paramss}
ACKickerParams & \sref{s:ackicker.g} & LengthParams & \sref{s:length.g} \\
BodyShiftParams & \sref{s:alignment.g} & LordSlaveStatusParams & \sref{s:lord.slave.g} \\
ApertureParams & \sref{s:aperture.g} & MasterParams & \sref{s:master.g} \\
BMultipoleParams & \sref{s:bmultipole.g} & OrientationParams & \sref{s:orientation.g} \\
BMultipoleParams & \sref{s:bmultipole.g} & FloorParams & \sref{s:orientation.g} \\
BeamBeamParams & \sref{s:beam.beam.g} & OriginEleParams & \sref{s:origin.ele.g} \\
BendParams & \sref{s:bend.g} & PatchParams & \sref{s:patch.g} \\
DescriptionParams & \sref{s:descrip.g} & RFParams & \sref{s:rf.g} \\
Expand Down Expand Up @@ -869,10 +869,10 @@ \section{MasterParams}
\end{example}

%---------------------------------------------------------------------------------------------------
\section{OrientationParams}
\section{FloorParams}
\label{s:orientation.g}

The \vn{OrientationParams} stores the nominal (calculated without alignment shifts)
The \vn{FloorParams} stores the nominal (calculated without alignment shifts)
position and angular orientation in the floor coordinates of the upstream end of the element.
system. The components of this group are:
\begin{example}
Expand Down
24 changes: 12 additions & 12 deletions manual/ele-types.tex
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ \section{ACKicker}
BodyShiftParams -> Element position/orientation shift. \sref{s:align.g}
ApertureParams -> Vacuum chamber aperture. \sref{s:aperture.g}
BMultipoleParams -> Magnetic multipoles. \sref{s:bmultipole.g}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
MasterParams -> Contains field_master parameter. \sref{s:master.g}
Expand Down Expand Up @@ -88,7 +88,7 @@ \section{BeamBeam}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -111,7 +111,7 @@ \section{BeginningEle}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
InitParticleParams -> Initial particle position and spin. \sref{s:init.particle.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
Expand Down Expand Up @@ -148,7 +148,7 @@ \section{Bend}
BMultipoleParams -> Magnetic multipoles. \sref{s:bmultipole.g}
BendParams -> Bend element parameters. \sref{s:bend.g}
EMultipoleParams -> Electric multipoles. \sref{s:emultipole.g}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
MasterParams -> Contains field_master parameter. \sref{s:master.g}
Expand Down Expand Up @@ -195,7 +195,7 @@ \section{Collimator}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -217,7 +217,7 @@ \section{Converter}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -240,7 +240,7 @@ \section{CrabCavity}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -260,7 +260,7 @@ \section{Drift}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -282,7 +282,7 @@ \section{EGun}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand All @@ -306,7 +306,7 @@ \section{Fiducial}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
LordSlaveParams -> Element lord and slave status. \sref{s:lord.slave.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
Expand Down Expand Up @@ -361,7 +361,7 @@ \section{Fork}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
TrackingParams -> Default tracking settings. \sref{s:tracking.g}
Expand Down Expand Up @@ -559,7 +559,7 @@ \section{Girder}
Element parameter groups associated with this element type are:
\TOPrule
\begin{example}
OrientationParams -> Floor floor position and orientation. \sref{s:orientation.g}
FloorParams -> Floor floor position and orientation. \sref{s:orientation.g}
LengthParams -> Length and s-position parameters. \sref{s:length.g}
DescriptionParams -> Element descriptive strings. \sref{s:descrip.g}
BodyShiftParams -> Alignment with respect to the reference. \sref{s:alignment.g}
Expand Down
4 changes: 2 additions & 2 deletions manual/new-ele.tex
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ \section{Defining a New Element}
* If the element has a new type of geometry, extend the \vn{propagate_ele_geometry()} function
to handle the new type of geometry. Example:
\begin{example}
function propagate_ele_geometry(::Type{CORKSCREW}, fstart::OrientationParams, ele::Ele)
function propagate_ele_geometry(::Type{CORKSCREW}, fstart::FloorParams, ele::Ele)
...
return floor_end # OrientationParams at the downstream end of the element.
return floor_end # FloorParams at the downstream end of the element.
end
\end{example}

Expand Down
11 changes: 4 additions & 7 deletions src/AcceleratorLattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ using ReferenceFrameRotations
using EnumX
using Random
using OrderedCollections
using SimUtils
using AtomicAndPhysicalConstants
using Reexport
@reexport using SimUtils
@reexport using AtomicAndPhysicalConstants

# AtomicAndPhysicalConstants

@APCdef;

for name in names(AtomicAndPhysicalConstants)
eval(Meta.parse("export $name"))
end

function charge(species::Species)
if species == Species(); error("Species not set!"); end
return chargeof(species)
Expand Down Expand Up @@ -69,7 +66,7 @@ export split!, construct_ele_type, ele_at_s, toggle_integrated!
export eles_search, eles_substitute_lords!, eles_sort!
export next_ele, ele_at_offset, ele_param_value_str, strip_AL, ele_param_group_symbols
export branch, matches_branch, create_ele_vars, eval_str, Vertex1, LatticeGlobal
export EleParams, BodyShiftParams, OrientationParams, BMultipole, BMultipoleParams, BeamBeamParams
export EleParams, PositionParams, BodyShiftParams, FloorParams, BMultipole, BMultipoleParams, BeamBeamParams
export EMultipole, EMultipoleParams, BendParams, ApertureParams, DescriptionParams, RFParams, SolenoidParams
export TrackingParams, LengthParams, ReferenceParams, DownstreamReferenceParams, ForkParams
export MasterParams, LordSlaveStatusParams, ACKickerParams
Expand Down
20 changes: 10 additions & 10 deletions src/accessor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -487,40 +487,40 @@ function output_parameter(sym::Symbol, ele::Ele, output_group::Type{T}) where T
if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end
if isnothing(girder(ele)); return ele.offset; end
ag = ele.pdict[:BodyShiftParams]
orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = OrientationParams(ele.offset, ele.q_shift)
orient_girder = FloorParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = FloorParams(ele.offset, ele.q_shift)
return coord_transform(orient_ele, orient_girder).r

elseif sym == :x_rot_tot
if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end
if isnothing(girder(ele)); return ele.x_rot; end
ag = ele.pdict[:BodyShiftParams]
orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = OrientationParams(ele.offset, ele.q_shift)
orient_girder = FloorParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = FloorParams(ele.offset, ele.q_shift)
return rot_angles(coord_transform(orient_ele, orient_girder).q)[1]

elseif sym == :y_rot_tot
if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end
if isnothing(girder(ele)); return ele.y_rot; end
ag = ele.pdict[:BodyShiftParams]
orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = OrientationParams(ele.offset, ele.q_shift)
orient_girder = FloorParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = FloorParams(ele.offset, ele.q_shift)
return rot_angles(coord_transform(orient_ele, orient_girder).q)[2]

elseif sym == :z_rot_tot
if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end
if isnothing(girder(ele)); return ele.z_rot; end
ag = ele.pdict[:BodyShiftParams]
orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = OrientationParams(ele.offset, ele.q_shift)
orient_girder = FloorParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = FloorParams(ele.offset, ele.q_shift)
return rot_angles(coord_transform(orient_ele, orient_girder).q)[3]

elseif sym == :q_shift_tot
if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end
if isnothing(girder(ele)); return ele.q_shift; end
ag = ele.pdict[:BodyShiftParams]
orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = OrientationParams(ele.offset, ele.q_shift)
orient_girder = FloorParams(girder(ele).offset_tot, girder(ele).q_shift_tot)
orient_ele = FloorParams(ele.offset, ele.q_shift)
return coord_transform(orient_ele, orient_girder).q
end

Expand Down
20 changes: 10 additions & 10 deletions src/bookkeeper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele
for group in PARAM_GROUPS_LIST[typeof(lord)]
if group == LengthParams; continue; end # Do not modify length of slave
if group == DownstreamReferenceParams; continue; end
if group == OrientationParams; continue; end
if group == FloorParams; continue; end
if group == LordSlaveStatusParams; continue; end

group_changed = has_changed(lord, group)
Expand Down Expand Up @@ -256,7 +256,7 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele
bgs = slave.pdict[:BendParams]
# Need transformation from lord alignment point to slave alignment point
# Translate from lord alignment point to beginning of lord point
ct = OrientationParams(r = [0.0, 0.0, -0.5*bgl.l_chord])
ct = FloorParams(r = [0.0, 0.0, -0.5*bgl.l_chord])
# Rotate from z parallel to lord chord to z tangent to bend curve.
ct = rot(ct, bend_quaternion(-0.5*bgl.angle, bg.ref_tilt))
# Transform from beginning of lord to beginning of slave
Expand All @@ -267,7 +267,7 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele
ct.r = ct.r + [0.0, 0.0, 0.5*bgs.l_chord]
# Apply total transformation of BodyShiftParams.
bs = lord.pdict[:BodyShiftParams]
lord_shift = OrientationParams(bs.offset, Quaternion(bs.x_rot, bs.y_rot, bs.z_rot))
lord_shift = FloorParams(bs.offset, Quaternion(bs.x_rot, bs.y_rot, bs.z_rot))
slave_shift = coord_transform(lord_shift, ct)
slave.BodyShiftParams = BodyShiftParams(slave_shift.r, rot_angles(slave_shift.q)...)
end
Expand Down Expand Up @@ -716,21 +716,21 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceParams}, changed::C
end

#---------------------------------------------------------------------------------------------------
# elegroup_bookkeeper!(ele::Ele, group::Type{OrientationParams}, ...)
# OrientationParams bookkeeper
# elegroup_bookkeeper!(ele::Ele, group::Type{FloorParams}, ...)
# FloorParams bookkeeper

function elegroup_bookkeeper!(ele::Ele, group::Type{OrientationParams},
function elegroup_bookkeeper!(ele::Ele, group::Type{FloorParams},
changed::ChangedLedger, previous_ele::Ele)
fpg = ele.OrientationParams
fpg = ele.FloorParams
cdict = ele.changed

if has_changed(ele, OrientationParams) || changed.this_ele_length; changed.floor_position = true; end
if has_changed(ele, FloorParams) || changed.this_ele_length; changed.floor_position = true; end
if !changed.floor_position; return; end

if is_null(previous_ele); return; end # Happens with beginning element

ele.OrientationParams = propagate_ele_geometry(previous_ele)
clear_changed!(ele, OrientationParams)
ele.FloorParams = propagate_ele_geometry(previous_ele)
clear_changed!(ele, FloorParams)

return
end
Expand Down
Loading
Loading