diff --git a/Project.toml b/Project.toml index b8173fc..8f2276d 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/README.md b/README.md index 422315f..4b646b5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/manual/attic/Notes.txt b/manual/attic/Notes.txt index 83112f7..dc917b8 100644 --- a/manual/attic/Notes.txt +++ b/manual/attic/Notes.txt @@ -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. diff --git a/manual/coordinates.tex b/manual/coordinates.tex index 1ba1c38..ddf907d 100644 --- a/manual/coordinates.tex +++ b/manual/coordinates.tex @@ -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 diff --git a/manual/ele-anatomy.tex b/manual/ele-anatomy.tex index c8bca5e..007b57b 100644 --- a/manual/ele-anatomy.tex +++ b/manual/ele-anatomy.tex @@ -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. @@ -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 @@ -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} %--------------------------------------------------------------------------------------------------- diff --git a/manual/ele-param-groups.tex b/manual/ele-param-groups.tex index 694621f..4052c67 100644 --- a/manual/ele-param-groups.tex +++ b/manual/ele-param-groups.tex @@ -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} \\ @@ -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} diff --git a/manual/ele-types.tex b/manual/ele-types.tex index 7de3e1e..dda69c8 100644 --- a/manual/ele-types.tex +++ b/manual/ele-types.tex @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} @@ -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} diff --git a/manual/new-ele.tex b/manual/new-ele.tex index 367c196..edf41c8 100644 --- a/manual/new-ele.tex +++ b/manual/new-ele.tex @@ -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} diff --git a/src/AcceleratorLattice.jl b/src/AcceleratorLattice.jl index a3b63e7..3fea35f 100644 --- a/src/AcceleratorLattice.jl +++ b/src/AcceleratorLattice.jl @@ -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) @@ -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 diff --git a/src/accessor.jl b/src/accessor.jl index 3650ef0..f385f14 100644 --- a/src/accessor.jl +++ b/src/accessor.jl @@ -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 diff --git a/src/bookkeeper.jl b/src/bookkeeper.jl index f0ef355..06aba5d 100644 --- a/src/bookkeeper.jl +++ b/src/bookkeeper.jl @@ -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) @@ -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 @@ -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 @@ -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 diff --git a/src/geometry.jl b/src/geometry.jl index 766a8d5..6e9a530 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -2,9 +2,9 @@ # propagate_ele_geometry """ - propagate_ele_geometry(geometry::Type{<:EleGeometry}, floor_start::OrientationParams, - ele::Ele) -> OrientationParams - propagate_ele_geometry(ele::Ele) -> OrientationParams + propagate_ele_geometry(geometry::Type{<:EleGeometry}, floor_start::FloorParams, + ele::Ele) -> FloorParams + propagate_ele_geometry(ele::Ele) -> FloorParams Returns the floor position at the end of the element given the floor position at the beginning. Normally this routine is called with `floor_start` equal to ele.param[:floor_position]. @@ -17,32 +17,32 @@ That is, the coordinates are the `machine` coordinates and not the `body` coordi """ propagate_ele_geometry function propagate_ele_geometry(ele::Ele) - return propagate_ele_geometry(ele_geometry(ele), ele.OrientationParams, ele) + return propagate_ele_geometry(ele_geometry(ele), ele.FloorParams, ele) end -function propagate_ele_geometry(fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(fstart::FloorParams, ele::Ele) return propagate_ele_geometry(ele_geometry(ele), fstart, ele) end -function propagate_ele_geometry(::Type{ZERO_LENGTH}, fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(::Type{ZERO_LENGTH}, fstart::FloorParams, ele::Ele) return fstart end -function propagate_ele_geometry(::Type{STRAIGHT}, fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(::Type{STRAIGHT}, fstart::FloorParams, ele::Ele) r_floor = fstart.r + rot([0.0, 0.0, ele.L], fstart.q) - return OrientationParams(r_floor, fstart.q) + return FloorParams(r_floor, fstart.q) end -function propagate_ele_geometry(::Type{CIRCULAR}, fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(::Type{CIRCULAR}, fstart::FloorParams, ele::Ele) df = coord_transform(ele.L, ele.BendParams.g, ele.BendParams.tilt_ref) return coord_transform(fstart, df) end -function propagate_ele_geometry(::Type{PATCH_GEOMETRY}, fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(::Type{PATCH_GEOMETRY}, fstart::FloorParams, ele::Ele) error("Not yet implemented!") end -function propagate_ele_geometry(::Type{CRYSTAL_GEOMETRY}, fstart::OrientationParams, ele::Ele) +function propagate_ele_geometry(::Type{CRYSTAL_GEOMETRY}, fstart::FloorParams, ele::Ele) error("Not yet implemented!") end @@ -50,7 +50,7 @@ end # coord_transform """ - coord_transform(ds::Number, g::Number, tilt_ref::Number = 0) -> OrientationParams + coord_transform(ds::Number, g::Number, tilt_ref::Number = 0) -> FloorParams Returns the coordinate transformation from one point on the arc with radius `1/g` of a Bend to another point that is an arc distance `ds` from the first point. @@ -62,7 +62,7 @@ The transformation is function coord_transform(ds::Number, g::Number, tilt_ref::Number = 0.0) if g == 0 - return OrientationParams([0.0, 0.0, ds], Quaternion()) + return FloorParams([0.0, 0.0, ds], Quaternion()) else angle = ds/g @@ -70,10 +70,10 @@ function coord_transform(ds::Number, g::Number, tilt_ref::Number = 0.0) qa = rotY(-angle) if tilt_ref == 0 - return OrientationParams(r_vec, qa) + return FloorParams(r_vec, qa) else qt = rotZ(-tilt_ref) - return OrientationParams(rot(r_vec, qt), qt * qa * inv(qt)) + return FloorParams(rot(r_vec, qt), qt * qa * inv(qt)) end end end @@ -82,15 +82,15 @@ end # coord_transform """ - coord_transform(coord0::OrientationParams, dcoord::OrientationParams) -> OrientationParams + coord_transform(coord0::FloorParams, dcoord::FloorParams) -> FloorParams Returns coordinate transformation of `dcoord` applied to `coord0`. -""" coord_transform(coord0::OrientationParams, dcoord::OrientationParams) +""" coord_transform(coord0::FloorParams, dcoord::FloorParams) -function coord_transform(coord0::OrientationParams, dcoord::OrientationParams) +function coord_transform(coord0::FloorParams, dcoord::FloorParams) r_coord = coord0.r + rot(dcoord.r, coord0.q) q_coord = coord0.q * dcoord.q - return OrientationParams(r_coord, q_coord) + return FloorParams(r_coord, q_coord) end #--------------------------------------------------------------------------------------------------- @@ -116,11 +116,11 @@ end # rot! """ - rot!(coord::OrientationParams, q::Quaternion) -> OrientationParams + rot!(coord::FloorParams, q::Quaternion) -> FloorParams Rotates coordinate position `coord` by `q`. """ -function rot!(coord::OrientationParams, q::Quaternion) +function rot!(coord::FloorParams, q::Quaternion) coord.r = rot(coord.r, q) coord.q = q * coord.q return coord @@ -130,11 +130,11 @@ end # rot """ - rot(coord::OrientationParams, q::Quaternion) -> OrientationParams + rot(coord::FloorParams, q::Quaternion) -> FloorParams Rotates coordinate position `coord` by `q`. """ -function rot(coord::OrientationParams, q::Quaternion) - return OrientationParams(r = rot(coord0.r, q), q = q * coord0.q) +function rot(coord::FloorParams, q::Quaternion) + return FloorParams(r = rot(coord0.r, q), q = q * coord0.q) end diff --git a/src/parameters.jl b/src/parameters.jl index 27f5a6c..5387e2a 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -89,17 +89,17 @@ ELE_PARAM_INFO_DICT = Dict( :amp_function => ParamInfo(ACKickerParams, Function, "Amplitude function."), - :offset => ParamInfo(BodyShiftParams, Vector{Number}, "[x, y, z] offset of element or, for a patch, exit coordinates.", "m"), - :x_rot => ParamInfo(BodyShiftParams, Number, "X-axis rotation of element or, for a patch, exit coordinates.", "rad"), - :y_rot => ParamInfo(BodyShiftParams, Number, "Y-axis rotation of element or, for a patch, exit coordinates.", "rad"), - :z_rot => ParamInfo(BodyShiftParams, Number, "Z-axis rotation of element or, for a patch, exit coordinates.", "rad"), + :offset_body => ParamInfo(BodyShiftParams, Vector{Number}, "[x, y, z] body offset of element.", "m", nothing, :offset), + :x_rot_body => ParamInfo(BodyShiftParams, Number, "X-axis body rotation of element.", "rad", nothing, :x_rot), + :y_rot_body => ParamInfo(BodyShiftParams, Number, "Y-axis body rotation of element.", "rad", nothing, :y_rot), + :z_rot_body => ParamInfo(BodyShiftParams, Number, "Z-axis body rotation of element.", "rad", nothing, :z_rot), - :q_shift => ParamInfo(BodyShiftParams, Quaternion, "Quaternion orientation.", "", OutputParams), - :q_shift_tot => ParamInfo(BodyShiftParams, Quaternion, "Quaternion orientation including Girder orientation.", "", OutputParams), + :q_body => ParamInfo(BodyShiftParams, Quaternion, "Quaternion orientation of body.", "", OutputParams), + :q_tot => ParamInfo(BodyShiftParams, Quaternion, "Quaternion orientation including Girder orientation.", "", OutputParams), :offset_tot => ParamInfo(BodyShiftParams, Vector{Number}, "[x, y, z] element offset including Girder orientation.", "m", OutputParams), - :x_rot_tot => ParamInfo(BodyShiftParams, Number, "X-axis element rotation including Girder orientation.", "rad", OutputParams), - :y_rot_tot => ParamInfo(BodyShiftParams, Number, "Y-axis element rotation including Girder orientation.", "rad", OutputParams), - :z_rot_tot => ParamInfo(BodyShiftParams, Number, "Z-axis element rotation including Girder orientation.", "rad", OutputParams), + :x_rot_tot => ParamInfo(BodyShiftParams, Number, "X-axis body rotation including Girder orientation.", "rad", OutputParams), + :y_rot_tot => ParamInfo(BodyShiftParams, Number, "Y-axis body rotation including Girder orientation.", "rad", OutputParams), + :z_rot_tot => ParamInfo(BodyShiftParams, Number, "Z-axis body rotation including Girder orientation.", "rad", OutputParams), :aperture_shape => ParamInfo(ApertureParams, ApertureShape, "Aperture shape. Default is ELLIPTICAL."), :aperture_at => ParamInfo(ApertureParams, BodyLoc.T, "Aperture location. Default is BodyLoc.ENTRANCE_END."), @@ -110,23 +110,23 @@ ELE_PARAM_INFO_DICT = Dict( :wall => ParamInfo(ApertureParams, Wall2D, "Wall defined by array of aperture vertices."), :custom_aperture => ParamInfo(ApertureParams, Dict, "Custom aperture info."), - :beta_a => ParamInfo(BeginningParams, Number, "A-mode beta Twiss parameter.", "m", nothing, :beta, :a), - :alpha_a => ParamInfo(BeginningParams, Number, "A-mode alpha Twiss parameter.", "", nothing, :alpha, :a), - :gamma_a => ParamInfo(BeginningParams, Number, "A-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :a), - :phi_a => ParamInfo(BeginningParams, Number, "A-mode betatron phase.", "rad", nothing, :phi, :a), + :beta_a => ParamInfo(BeginningParams, Number, "A-mode beta Twiss parameter.", "m", nothing, :beta, :a), + :alpha_a => ParamInfo(BeginningParams, Number, "A-mode alpha Twiss parameter.", "", nothing, :alpha, :a), + :gamma_a => ParamInfo(BeginningParams, Number, "A-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :a), + :phi_a => ParamInfo(BeginningParams, Number, "A-mode betatron phase.", "rad", nothing, :phi, :a), - :beta_b => ParamInfo(BeginningParams, Number, "B-mode beta Twiss parameter.", "m", nothing, :beta, :b), - :alpha_b => ParamInfo(BeginningParams, Number, "B-mode alpha Twiss parameter.", "", nothing, :alpha, :b), - :gamma_b => ParamInfo(BeginningParams, Number, "B-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :b), - :phi_b => ParamInfo(BeginningParams, Number, "B-mode betatron phase.", "rad", nothing, :phi, :b), + :beta_b => ParamInfo(BeginningParams, Number, "B-mode beta Twiss parameter.", "m", nothing, :beta, :b), + :alpha_b => ParamInfo(BeginningParams, Number, "B-mode alpha Twiss parameter.", "", nothing, :alpha, :b), + :gamma_b => ParamInfo(BeginningParams, Number, "B-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :b), + :phi_b => ParamInfo(BeginningParams, Number, "B-mode betatron phase.", "rad", nothing, :phi, :b), - :eta_x => ParamInfo(BeginningParams, Number, "X-mode position dispersion.", "m", nothing, :eta, :x), - :etap_x => ParamInfo(BeginningParams, Number, "X-mode momentum dispersion.", "", nothing, :etap, :x), - :deta_ds_x => ParamInfo(BeginningParams, Number, "X-mode dispersion derivative.", "", nothing, :deta_ds, :x), + :eta_x => ParamInfo(BeginningParams, Number, "X-mode position dispersion.", "m", nothing, :eta, :x), + :etap_x => ParamInfo(BeginningParams, Number, "X-mode momentum dispersion.", "", nothing, :etap, :x), + :deta_ds_x => ParamInfo(BeginningParams, Number, "X-mode dispersion derivative.", "", nothing, :deta_ds, :x), - :eta_y => ParamInfo(BeginningParams, Number, "Y-mode position dispersion.", "m", nothing, :eta, :y), - :etap_y => ParamInfo(BeginningParams, Number, "Y-mode momentum dispersion.", "", nothing, :etap, :y), - :deta_ds_y => ParamInfo(BeginningParams, Number, "Y-mode dispersion derivative.", "", nothing, :deta_ds, :y), + :eta_y => ParamInfo(BeginningParams, Number, "Y-mode position dispersion.", "m", nothing, :eta, :y), + :etap_y => ParamInfo(BeginningParams, Number, "Y-mode momentum dispersion.", "", nothing, :etap, :y), + :deta_ds_y => ParamInfo(BeginningParams, Number, "Y-mode dispersion derivative.", "", nothing, :deta_ds, :y), :angle => ParamInfo(BendParams, Number, "Reference bend angle", "rad"), :bend_field_ref => ParamInfo(BendParams, Number, "Reference bend field corresponding to g bending strength", "T"), @@ -171,8 +171,8 @@ ELE_PARAM_INFO_DICT = Dict( :is_on => ParamInfo(MasterParams, Bool, "Element fields on/off."), :field_master => ParamInfo(MasterParams, Bool, "True: fields are fixed and normalized values change when varying ref energy."), - :r_floor => ParamInfo(OrientationParams, Vector{Number}, "3-vector of element floor position.", "m", nothing, :r), - :q_floor => ParamInfo(OrientationParams, Quaternion, "Element quaternion orientation.", "", nothing, :q), + :r_floor => ParamInfo(FloorParams, Vector{Number}, "3-vector of element floor position.", "m", nothing, :r), + :q_floor => ParamInfo(FloorParams, Quaternion, "Element quaternion orientation.", "", nothing, :q), :origin_ele => ParamInfo(OriginEleParams, Ele, "Coordinate reference element."), :origin_ele_ref_pt => ParamInfo(OriginEleParams, Loc.T, "Reference location on reference element. Default is Loc.CENTER."), @@ -184,6 +184,11 @@ ELE_PARAM_INFO_DICT = Dict( :flexible => ParamInfo(PatchParams, Bool, "Flexible patch?"), :ref_coords => ParamInfo(PatchParams, BodyLoc.T, "Patch coords with respect to BodyLoc.ENTRANCE_END or BodyLoc.EXIT_END?"), + :offset_position => ParamInfo(BodyShiftParams, Vector{Number}, "[x, y, z] offset.", "m", nothing, :offset), + :x_rot_position => ParamInfo(BodyShiftParams, Number, "X-axis rotation.", "rad", nothing, :x_rot), + :y_rot_position => ParamInfo(BodyShiftParams, Number, "Y-axis rotation.", "rad", nothing, :y_rot), + :z_rot_position => ParamInfo(BodyShiftParams, Number, "Z-axis rotation.", "rad", nothing, :z_rot), + :species_ref => ParamInfo(ReferenceParams, Species, "Reference species."), :pc_ref => ParamInfo(ReferenceParams, Number, "Reference momentum * c.", "eV"), :E_tot_ref => ParamInfo(ReferenceParams, Number, "Reference total energy.", "eV"), @@ -248,7 +253,7 @@ List of names (symbols) of parameters associated with element parameter group st Associated parameters are the fields of the struct plus any associated output parameters. If the "user name" is different from the group field name, the user name is used. -For example, for a `OrientationParams`, `r_floor` will be in the name list instead of `r`. +For example, for a `FloorParams`, `r_floor` will be in the name list instead of `r`. """ associated_names function associated_names(group::Type{T}) where T <: EleParams @@ -605,8 +610,9 @@ Order is important. Bookkeeping routines rely on: - `RFCommonParams` comes last (triggers autoscale/autophase and `ReferenceParams` correction). """ PARAM_GROUPS_LIST -base_group_list = [LengthParams, LordSlaveStatusParams, DescriptionParams, ReferenceParams, - DownstreamReferenceParams, OrientationParams, TrackingParams, BodyShiftParams, ApertureParams] +fundamental_group_list = [LengthParams, DescriptionParams, ReferenceParams, + DownstreamReferenceParams, FloorParams, TrackingParams, ApertureParams] +base_group_list = [fundamental_group_list..., LordSlaveStatusParams, BodyShiftParams] multipole_group_list = [MasterParams, BMultipoleParams, EMultipoleParams] general_group_list = [base_group_list..., multipole_group_list...] @@ -625,11 +631,11 @@ PARAM_GROUPS_LIST = Dict( CrabCavity => [base_group_list...], Drift => [base_group_list...], EGun => [general_group_list...], - Fiducial => [DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams], - FloorShift => [DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams], + Fiducial => [fundamental_group_list..., PositionParams, OriginEleParams], + FloorShift => [fundamental_group_list..., PositionParams, OriginEleParams], Foil => [base_group_list...], Fork => [base_group_list..., ForkParams], - Girder => [LengthParams, DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams, GirderParams], + Girder => [LengthParams, DescriptionParams, FloorParams, BodyShiftParams, OriginEleParams, GirderParams], Instrument => [base_group_list...], Kicker => [general_group_list...], LCavity => [base_group_list..., MasterParams, RFAutoParams, RFParams], @@ -638,7 +644,7 @@ PARAM_GROUPS_LIST = Dict( Multipole => [general_group_list...], NullEle => [], Octupole => [general_group_list...], - Patch => [base_group_list..., PatchParams], + Patch => [fundamental_group_list..., PositionParams, PatchParams], Quadrupole => [general_group_list...], RFCavity => [base_group_list..., MasterParams, RFAutoParams, RFParams], Sextupole => [general_group_list...], @@ -657,26 +663,27 @@ end ELE_PARAM_GROUP_INFO = Dict( ACKickerParams => EleParamsInfo("ACKicker element parameters.", false), - BodyShiftParams => EleParamsInfo("Element position/orientation shift.", false), ApertureParams => EleParamsInfo("Vacuum chamber aperture.", false), BeamBeamParams => EleParamsInfo("BeamBeam element parameters.", false), + BeginningParams => EleParamsInfo("Initial Twiss and coupling parameters.", false), BendParams => EleParamsInfo("Bend element parameters.", true), BMultipoleParams => EleParamsInfo("Magnetic multipoles.", true), - BMultipole => EleParamsInfo("Magnetic multipole of given order. Substructure contained in `BMultipoleParams`", false), + BMultipole => EleParamsInfo("Magnetic multipole of given order. Substructure contained in `BMultipoleParams`", false), + BodyShiftParams => EleParamsInfo("Element position/orientation shift.", false), DescriptionParams => EleParamsInfo("Informational strings.", false), DownstreamReferenceParams => EleParamsInfo("Downstream element end reference energy and species.", false), EMultipoleParams => EleParamsInfo("Electric multipoles.", false), - EMultipole => EleParamsInfo("Electric multipole of given order. Substructure contained in `EMultipoleParams`.", false), + EMultipole => EleParamsInfo("Electric multipole of given order. Substructure contained in `EMultipoleParams`.", false), + FloorParams => EleParamsInfo("Global floor position and orientation.", true), ForkParams => EleParamsInfo("Fork element parameters", false), GirderParams => EleParamsInfo("Girder parameters.", false), InitParticleParams => EleParamsInfo("Initial particle position and spin.", false), - BeginningParams => EleParamsInfo("Initial Twiss and coupling parameters.", false), LengthParams => EleParamsInfo("Length and s-position parameters.", true), LordSlaveStatusParams => EleParamsInfo("Element lord and slave status.", false), MasterParams => EleParamsInfo("Contains field_master parameter.", false), - OrientationParams => EleParamsInfo("Global floor position and orientation.", true), OriginEleParams => EleParamsInfo("Defines coordinate origin for Girder, FloorShift and Fiducial elements.", false), PatchParams => EleParamsInfo("Patch parameters.", false), + PositionParams => EleParamsInfo("Position of element (exit end for a Patch) parameters.", false), ReferenceParams => EleParamsInfo("Reference energy and species.", true), RFParams => EleParamsInfo("`RFCavity` and `LCavity` RF parameters.", true), RFAutoParams => EleParamsInfo("Contains `auto_amp`, and `auto_phase` related parameters.", false), diff --git a/src/show.jl b/src/show.jl index 55342d4..a343fad 100644 --- a/src/show.jl +++ b/src/show.jl @@ -9,12 +9,12 @@ second column when displaying the elements of an element parameter group using t Example `show_column2` key/value pair: ```julia - OrientationParams => Dict{Symbol,Symbol}( + FloorParams => Dict{Symbol,Symbol}( :r => :q, :phi => :psi, ) ``` -In this example, when printing the `OrientationParams`, in the line showing the `.r` component, +In this example, when printing the `FloorParams`, in the line showing the `.r` component, the `.r` component will be in the first column and the `.q` component will be in the second column. @@ -38,6 +38,16 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( ), + BeginningParams => Dict{Symbol,Symbol}( + :beta_a => :beta_b, + :alpha_a => :alpha_b, + :gamma_a => :gamma_b, + :phi_a => :phi_b, + :eta_x => :eta_y, + :etap_x => :etap_y, + :deta_ds_x => :deta_ds_y, + ), + BendParams => Dict{Symbol,Symbol}( :bend_type => :exact_multipoles, :g => :norm_bend_field, @@ -49,12 +59,17 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( :L_chord => :L_sagitta, ), + DescriptionParams => Dict{Symbol,Symbol}( + :type => :ID, + ), + Dispersion1 => Dict{Symbol,Symbol}( :eta => :etap, ), - OrientationParams => Dict{Symbol,Symbol}( - :r => :q, + DownstreamReferenceParams => Dict{Symbol,Symbol}( + :pc_ref_downstream => :E_tot_ref_downstream, + :β_ref_downstream => :γ_ref_downstream, ), GirderParams => Dict{Symbol,Symbol}( @@ -62,6 +77,9 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( :dr => :dq, ), + InitParticleParams => Dict{Symbol,Symbol}( + ), + LengthParams => Dict{Symbol,Symbol}( :L => :orientation, :s => :s_downstream, @@ -75,22 +93,21 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( :is_on => :field_master ), + FloorParams => Dict{Symbol,Symbol}( + :r => :q, + ), + PatchParams => Dict{Symbol,Symbol}( :E_tot_offset => :t_offset, :E_tot_downstream => :pc_downstream, :flexible => :L_user, ), - DescriptionParams => Dict{Symbol,Symbol}( - :type => :ID, - ), - - DownstreamReferenceParams => Dict{Symbol,Symbol}( - :pc_ref_downstream => :E_tot_ref_downstream, - :β_ref_downstream => :γ_ref_downstream, - ), - - InitParticleParams => Dict{Symbol,Symbol}( + PositionParams => Dict{Symbol,Symbol}( + :offset => :offset_tot, + :x_rot => :x_rot_tot, + :y_rot => :y_rot_tot, + :z_rot => :z_rot_tot, ), ReferenceParams => Dict{Symbol,Symbol}( @@ -125,17 +142,6 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( :gamma => :phi, :eta => :etap, ), - - BeginningParams => Dict{Symbol,Symbol}( - :beta_a => :beta_b, - :alpha_a => :alpha_b, - :gamma_a => :gamma_b, - :phi_a => :phi_b, - :eta_x => :eta_y, - :etap_x => :etap_y, - :deta_ds_x => :deta_ds_y, - ), - ) #--------------------------------------------------------------------------------------------------- @@ -390,7 +396,7 @@ function show_elegroup(io::IO, group::EMultipoleParams, ele::Ele, docstring::Boo end println(io, "$(off_str)EMultipoleParams:") - println(io, "$(off_str) Order Eintegrated{lpad(\"Etilt (rad)\",23)}") + println(io, "$(off_str) Order Eintegrated $(lpad("Etilt (rad)",22))") for v in group.pole !isnothing(v.Eintegrated) && v.Eintegrated ? ol = "$(v.order)L" : ol = "$(v.order) " ue = units(Symbol("En$(ol)")) @@ -496,7 +502,7 @@ end """ full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParams -For fields where the user name is different (EG: `r_floor` and `r` in a OrientationParams), +For fields where the user name is different (EG: `r_floor` and `r` in a FloorParams), return the string `struct_name (user_name)` (EG: `r (r_floor)`). Also add `(output)` to names of output parameters. """ full_parameter_name diff --git a/src/struct.jl b/src/struct.jl index 70bea91..af74e8c 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -605,29 +605,25 @@ end """ mutable struct BodyShiftParams <: EleParams -Defines the position and orientation of an element. +Defines the position and orientation of the body coordinates of an element with respect to +the supporting girder if it exists or with respect to the machine coordinates. -- For `Patch` elements this is the orientation of the exit face with respect to the entrance face. -- For `FloorShift` and `Fiducial` elements this is the orientation of the element with respect - to the reference element. -- For other elements this is the orientation of element body alignment point with respect to -the supporting girder if it exists or with respect to the machine coordinates. +See the manual for details about how the three rotations are combined. ## Fields -• `offset::Vector` - [x, y, z] offsets not including any Girder. \\ -• `x_rot::Number` - Rotation around the x-axis not including any Girder alignment shifts. \\ -• `y_rot::Number` - Rotation around the y-axis not including any Girder alignment shifts. \\ -• `z_rot::Number` - Rotation around the z-axis not including any Girder alignment shifts. \\ +• `offset::Vector` - [x, y, z] offset. User symbol: `offset_body`. \\ +• `x_rot::Number` - Rotation around the x-axis. User symbol: `x_rot_body`. \\ +• `y_rot::Number` - Rotation around the y-axis. User symbol: `y_rot_body`. \\ +• `z_rot::Number` - Rotation around the z-axis. User symbol: `z_rot_body`. \\ ## Associated Output Parameters -The `tot` parameters are defined only for elements that can be supported by a `Girder`. -These parameters are the body coordinates with respect to machine coordinates. +The `tot` parameters are the body coordinates with respect to the branch coordinates. These parameters are calculated by `AcceleratorLattice` and will be equal to the corresponding non-tot fields if there is no `Girder`. -• `q_shift::Quaternion` - `Quaternion` representation of `x_rot`, `y_rot`, `tilt` orientation. \\ -• `q_shift_tot:: Quaternion` - `Quaternion` representation of orienttion with Girder shifts. +• `q_body::Quaternion` - `Quaternion` representation of `x_rot`, `y_rot`, `tilt` orientation. \\ +• `q_tot:: Quaternion` - `Quaternion` representation of orienttion with Girder shifts. \\ • `offset_tot::Vector` - `[x, y, z]` offsets including Girder alignment shifts. \\ • `x_rot_tot::Number` - Rotation around the x-axis including Girder alignment shifts. \\ • `y_rot_tot::Number` - Rotation around the y-axis including Girder alignment shifts. \\ @@ -819,21 +815,21 @@ and normalized field strengths willbe varied. And vice versa when `field_master` end #--------------------------------------------------------------------------------------------------- -# OrientationParams +# FloorParams """ - mutable struct OrientationParams <: EleParams + mutable struct FloorParams <: EleParams Position and angular orientation. -In a lattice element, this struct gives the Floor coordinates at the entrance end of the element +In a lattice element, this struct gives the Floor coordinates at the upstream end of the element ignoring alignment shifts. # Fields -• `r::Vector` - `[x,y,z]` position. \\ -• `q::Quaternion{Number}` - Quaternion orientation. \\ -""" OrientationParams +• `r::Vector` - `[x,y,z]` position. User symbol: `r_floor`. \\ +• `q::Quaternion{Number}` - Quaternion orientation. User symbol: `q_floor`. \\ +""" FloorParams -@kwdef mutable struct OrientationParams <: EleParams +@kwdef mutable struct FloorParams <: EleParams r::Vector = [0.0, 0.0, 0.0] q::Quaternion{Number} = Quaternion(1.0, 0.0, 0.0, 0.0) end @@ -864,7 +860,7 @@ end """ mutable struct PatchParams <: EleParams -`Patch` element parameters. +`Patch` element parameters. Other `Patch` parameters are in PositionParams ## Fields • `t_offset::Number` - Time offset. \\ @@ -886,6 +882,31 @@ end ref_coords::BodyLoc.T = BodyLoc.EXIT_END end +#--------------------------------------------------------------------------------------------------- +# PositionParams + +""" + mutable struct PositionParams <: EleParams + +- For `Patch` elements this is the position and orientation of the exit face with respect to the entrance face. +- For `FloorShift` and `Fiducial` elements this is the position and orientation of the element with respect + to the reference element. + +## Fields +• `offset::Vector` - [x, y, z] offset. User symbol: `offset_body`. \\ +• `x_rot::Number` - Rotation around the x-axis. User symbol: `x_rot_body`. \\ +• `y_rot::Number` - Rotation around the y-axis. User symbol: `y_rot_body`. \\ +• `z_rot::Number` - Rotation around the z-axis. User symbol: `z_rot_body`. \\ + +""" PositionParams + +@kwdef mutable struct PositionParams <: EleParams + offset::Vector = [0.0, 0.0, 0.0] + x_rot::Number = 0 + y_rot::Number = 0 + z_rot::Number = 0 +end + #--------------------------------------------------------------------------------------------------- # ReferenceParams diff --git a/test/superimpose_test.jl b/test/superimpose_test.jl index 4783157..bc8b266 100644 --- a/test/superimpose_test.jl +++ b/test/superimpose_test.jl @@ -2,7 +2,7 @@ using AcceleratorLattice, Test @eles begin beginning = BeginningEle(pc_ref = 1e7, species_ref = Species("electron")) - q1 = Quadrupole(L = 0.6, x_rot = 2, ID = "qz", Ks8L = 123, tilt8 = 2, Bn9 = 3, + q1 = Quadrupole(L = 0.6, x_rot_body = 2, ID = "qz", Ks8L = 123, tilt8 = 2, Bn9 = 3, En1L = 1, Etilt1 = 2, Es2 = 3, Etilt2 = 4) q2 = Quadrupole(L = 0.6, Kn1 = -0.3); d1 = Drift(L = 1.0);