diff --git a/README.md b/README.md index 1edfc93..422315f 100644 --- a/README.md +++ b/README.md @@ -49,27 +49,27 @@ An individual element looks like: Ele: "qf" (b1>>2) Quadrupole branch Branch 1: "b1" ix_ele 2 - BodyShiftGroup: + BodyShiftParams: offset [0.0, 0.0, 0.0] m offset_tot [0.0, 0.0, 0.0] m x_rot 0 rad x_rot_tot 0 rad y_rot 0 rad y_rot_tot 0 rad tilt 0 rad tilt_tot 0 rad - ApertureGroup: + ApertureParams: x_limit [NaN, NaN] m y_limit [NaN, NaN] m aperture_at BodyLoc.ENTRANCE_END aperture_type ApertureShape.ELLIPTICAL misalignment_moves_aperture true - BMultipoleGroup: + BMultipoleParams: Order Integrated Tilt (rad) 1 false 0.0 0.34 Kn1 0.0 Ks1 (1/m^2) -0.011341179236737171 Bn1 -0.0 Bs1 (T/m^1) - EMultipoleGroup: No electric multipoles - OrientationGroup: + EMultipoleParams: No electric multipoles + OrientationParams: 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 phi (phi_floor) 0.0 rad psi (psi_floor) 0.0 rad - LengthGroup: + LengthParams: L 0.6 m orientation 1 s 0.0 m s_downstream 0.6 m ... etc... diff --git a/manual/attic/Notes.txt b/manual/attic/Notes.txt index 74e269e..83112f7 100644 --- a/manual/attic/Notes.txt +++ b/manual/attic/Notes.txt @@ -1,13 +1,13 @@ -* Some element parameter groups may or may not be present. EG: AmpVsTimeGroup for ACKicker. +* Some element parameter groups may or may not be present. EG: AmpVsTimeParams for ACKicker. -* EG AmpVsTimeGroup: There are no "shortcuts" like ele.L -> ele.LengthGroup.L. Can set via: - at = ele.AmpVsTimeGroup # Does this work if AmpVsTimeGroup is not present? If so need function for this. +* EG AmpVsTimeParams: There are no "shortcuts" like ele.L -> ele.LengthParams.L. Can set via: + at = ele.AmpVsTimeParams # Does this work if AmpVsTimeParams is not present? If so need function for this. at.interpolation = ... or - at = AmpVsTimeGroup(t_offset = ...) + at = AmpVsTimeParams(t_offset = ...) at.interpolation = ... ... - ele.AmpVsTimeGroup = at + ele.AmpVsTimeParams = at * BeamBeam element can have a reference to a Solenoid element @@ -52,7 +52,7 @@ The reason for doing a shallow copy, instead of a deep copy, is to save on memor * "Lattice" bookkeeping triggered by user (or optimizer). * Drifts are temporarily put in branch.ele_saved for superposition. -* MultipassLord elements do not have orientation, s, nor s_downstream parameters but does have a LengthGroup +* MultipassLord elements do not have orientation, s, nor s_downstream parameters but does have a LengthParams * Lattice bookkeeping can be bypassed by setting the element group parameter directly. @@ -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 OrientationGroup if the lattice contains a flexible patch. +the OrientationParams 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. @@ -87,7 +87,7 @@ values is redefined). * Coding tip: Element group structures are not mutable by design to maximize tracking speed. This is a bit inconvenient when a structure needs to be modified. One way to handle this is using the @set macro. Another way is to convert a structure instance to a Dict, change the Dict, and then convert back (note: this is possible since the @kwdef macro was used to define the element group structures). Example: ... -* Some element groups are optional and may not be present in a given element. For example, LengthGroup is required and BMultipoleGroup and EMultipoleGroup are optional. +* Some element groups are optional and may not be present in a given element. For example, LengthParams is required and BMultipoleParams and EMultipoleParams are optional. * Online documentation: For element groups use REPL "?" and type in the name. diff --git a/manual/bookkeeping.tex b/manual/bookkeeping.tex index d628cd1..78a2193 100644 --- a/manual/bookkeeping.tex +++ b/manual/bookkeeping.tex @@ -15,7 +15,7 @@ \section{Lord/Slave Bookkeeping} Multipass: Multipass lords Multipass Slaves \sref{c:multipass} \end{example} -The lord and slave slave status of a lattice element is contained in the \vn{LordSlaveStatusGroup} +The lord and slave slave status of a lattice element is contained in the \vn{LordSlaveStatusParams} parameter group. The components of this group are (\sref{s:lord.slave.g}): \begin{example} lord_status::Lord.T - Lord status. diff --git a/manual/coordinates.tex b/manual/coordinates.tex index ff71903..1ba1c38 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{OrientationGroup parameters} (\sref{s:orientationition.g}) in the \vn{BeginningEle} element. +\vn{OrientationParams 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 a2ff38b..8e71970 100644 --- a/manual/ele-anatomy.tex +++ b/manual/ele-anatomy.tex @@ -59,19 +59,19 @@ \section{Instantiating a Lattice Element} \end{example} %--------------------------------------------------------------------------------------------------- -\section{Element Parameter Groups} +\section{Element Parameter Paramss} \label{s:ele.groups} Generally, element parameters are grouped into ``\vn{element} \vn{parameter} \vn{group}'' -structs which inherit from the abstract type \vn{EleParameterGroup}. +structs which inherit from the abstract type \vn{EleParameterParams}. Element parameter documentation is in Chapter~\sref{c:ele.groups}. In the REPL, To see a list of parameter groups, use the \vn{suptypes} function: \begin{example} - julia> subtypes(EleParameterGroup) + julia> subtypes(EleParameterParams) 28-element Vector{Any}: - BodyShiftGroup - ApertureGroup - BMultipoleGroup + BodyShiftParams + ApertureParams + BMultipoleParams ... \end{example} Chapter~\sref{c:ele.types} documents the parameters groups that are associated with any particular element type. @@ -83,17 +83,17 @@ \section{Element Parameter Groups} Associated parameter groups =========================== - • BodyShiftGroup -> Element position/orientation shift. - • ApertureGroup -> Vacuum chamber aperture. - • BMultipoleGroup -> Magnetic multipoles. - • EMultipoleGroup -> Electric multipoles. - • OrientationGroup -> Floor position and orientation. - • LengthGroup -> Length and s-position parameters. - • LordSlaveGroup -> Element lord and slave status. - • MasterGroup -> Contains field_master parameter. - • ReferenceGroup -> Reference energy and species. - • DescriptionGroup -> String labels for element. - • TrackingGroup -> Default tracking settings. + • BodyShiftParams -> Element position/orientation shift. + • ApertureParams -> Vacuum chamber aperture. + • BMultipoleParams -> Magnetic multipoles. + • EMultipoleParams -> Electric multipoles. + • OrientationParams -> Floor position and orientation. + • LengthParams -> Length and s-position parameters. + • LordSlaveParams -> Element lord and slave status. + • MasterParams -> Contains field_master parameter. + • ReferenceParams -> Reference energy and species. + • DescriptionParams -> String labels for element. + • TrackingParams -> Default tracking settings. \end{example} Alternatively, @@ -101,26 +101,26 @@ \section{Element Parameter Groups} \section{Element Parameters} \label{s:ele.params} -For example, the \vn{LengthGroup} holds the length and s-positions of the element and is defined by: +For example, the \vn{LengthParams} holds the length and s-positions of the element and is defined by: \begin{example} - @kwdef struct LengthGroup <: EleParameterGroup + @kwdef struct LengthParams <: EleParameterParams L::Number = 0.0 # Length of element s::Number = 0.0 # Starting s-position s_downstream::Number = 0.0 # Ending s-position orientation::Int = 1 # Longitudinal orientation end \end{example} -The \vn{@kwdef} macro automatically defines a keyword-based constructor for \vn{LengthGroup}. +The \vn{@kwdef} macro automatically defines a keyword-based constructor for \vn{LengthParams}. See the Julia manual for more information on \vn{@kwdef}. -To see a list of all element parameter groups use the \vn{subtypes(EleParamterGroup)} command. +To see a list of all element parameter groups use the \vn{subtypes(EleParamterParams)} command. To see the components of a given group use the \vn{fieldnames} function. For information on a given element parameter use the \vn{info(::Symbol)} function where the argument is the symbol corresponding to the component. For example, the information on -the \vn{s_downstream} parameter which is a field of the \vn{LengthGroup} is: +the \vn{s_downstream} parameter which is a field of the \vn{LengthParams} is: \begin{example} julia> info(:s_downstream) User name: s_downstream - Stored in: LengthGroup.s_downstream + Stored in: LengthParams.s_downstream Parameter type: Number Units: m Description: Longitudinal s-position at the downstream end. @@ -135,7 +135,7 @@ \section{Element Parameters} \begin{example} julia> info(:theta) User name: theta_floor - Stored in: OrientationGroup.theta + Stored in: OrientationParams.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{OrientationGroup} is \vn{theta} so +But the component in the \vn{OrientationParams} is \vn{theta} so \begin{example} - bg.OrientationGroup.theta = 2.7 # Equivalent to the set above. + bg.OrientationParams.theta = 2.7 # Equivalent to the set above. \end{example} %--------------------------------------------------------------------------------------------------- @@ -157,13 +157,13 @@ \section{How Element Parameters are Stored in an Element} All lattice element types have a single field of type \vn{Dict\{Symbol,Any\}} named \vn{pdict}. The values of \vn{pdict} will, with a few exceptions, be an element parameter group. The corresponding key for a parameter group in \vn{pdict} is the symbol associated -with the type. For example, a \vn{LengthGroup} struct would be stored in \vn{pdict[:LengthGroup]}. +with the type. For example, a \vn{LengthParams} struct would be stored in \vn{pdict[:LengthParams]}. To (partially) hide the complexity of parameter groups, the dot selection operator is overloaded for elements. This is achieved by overloading the \vn{Base.setproperty} and \vn{Base.getproperty} functions, which get called when the dot selection operator is used. -For example, if \vn{q} is an element instance, \vn{q.s} will get mapped to \vn{q.pdict[:LengthGroup].s}. -Additionally, \vn{q.LengthGroup} is mapped to \vn{q.pdict[:LengthGroup]}. +For example, if \vn{q} is an element instance, \vn{q.s} will get mapped to \vn{q.pdict[:LengthParams].s}. +Additionally, \vn{q.LengthParams} is mapped to \vn{q.pdict[:LengthParams]}. Besides simplifying the syntax, overloading the dot selection operator has a second purpose which is to allow the \accellat bookkeeping routines to properly do dependent parameter bookkeeping (\sref{param.depend}). diff --git a/manual/ele-param-groups.tex b/manual/ele-param-groups.tex index b6f129e..cc63390 100644 --- a/manual/ele-param-groups.tex +++ b/manual/ele-param-groups.tex @@ -1,4 +1,4 @@ -\chapter{Element Parameter Groups} +\chapter{Element Parameter Paramss} \label{c:ele.groups} Generally, element parameters are grouped into ``\vn{element} \vn{parameter} \vn{group}'' @@ -10,20 +10,20 @@ \chapter{Element Parameter Groups} \centering {\tt \begin{tabular}{llll} \toprule - {\it Group} & {\it Section} & {\it Group} & {\it Section} \\ + {\it Params} & {\it Section} & {\it Params} & {\it Section} \\ \midrule - ACKickerGroup & \sref{s:ackicker.g} & LengthGroup & \sref{s:length.g} \\ - BodyShiftGroup & \sref{s:alignment.g} & LordSlaveStatusGroup & \sref{s:lord.slave.g} \\ - ApertureGroup & \sref{s:aperture.g} & MasterGroup & \sref{s:master.g} \\ - BMultipoleGroup & \sref{s:bmultipole.g} & OrientationGroup & \sref{s:orientation.g} \\ - BeamBeamGroup & \sref{s:beam.beam.g} & OriginEleGroup & \sref{s:origin.ele.g} \\ - BendGroup & \sref{s:bend.g} & PatchGroup & \sref{s:patch.g} \\ - DescriptionGroup & \sref{s:descrip.g} & RFGroup & \sref{s:rf.g} \\ - DownstreamReferenceGroup & \sref{s:dreference.g} & RFAutoGroup & \sref{s:rfauto.g} \\ - EMultipoleGroup & \sref{s:emultipole.g} & ReferenceGroup & \sref{s:reference.g} \\ - ForkGroup & \sref{s:fork.g} & SolenoidGroup & \sref{s:solenoid.g} \\ - GirderGroup & \sref{s:girder.g} & TrackingGroup & \sref{s:tracking.g} \\ - InitParticleGroup & \sref{s:init.particle.g} & TwissGroup & \sref{s:twiss.g} \\ + 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} \\ + 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} \\ + DownstreamReferenceParams & \sref{s:dreference.g} & RFAutoParams & \sref{s:rfauto.g} \\ + EMultipoleParams & \sref{s:emultipole.g} & ReferenceParams & \sref{s:reference.g} \\ + ForkParams & \sref{s:fork.g} & SolenoidParams & \sref{s:solenoid.g} \\ + GirderParams & \sref{s:girder.g} & TrackingParams & \sref{s:tracking.g} \\ + InitParticleParams & \sref{s:init.particle.g} & TwissParams & \sref{s:twiss.g} \\ \bottomrule \end{tabular} } @@ -31,21 +31,21 @@ \chapter{Element Parameter Groups} \label{t:ele.param.g} \end{table} -Element parameter groups inherit from the abstract type \vn{EleParameterGroup} which -in turn inherits from \vn{BaseEleParameterGroup}. Some +Element parameter groups inherit from the abstract type \vn{EleParameterParams} which +in turn inherits from \vn{BaseEleParameterParams}. Some parameter groups have sub-group components. -These sub-groups also inherit from \vn{BaseEleParameterGroup}: +These sub-groups also inherit from \vn{BaseEleParameterParams}: \begin{example} - abstract type BaseEleParameterGroup end - abstract type EleParameterGroup <: BaseEleParameterGroup end - abstract type EleParameterSubGroup <: BaseEleParameterGroup end + abstract type BaseEleParameterParams end + abstract type EleParameterParams <: BaseEleParameterParams end + abstract type EleParameterSubParams <: BaseEleParameterParams end \end{example} -To see which element types contain a given group, use the \vn{info(::EleParameterGroup)} +To see which element types contain a given group, use the \vn{info(::EleParameterParams)} method. Example: \begin{example} - julia> info(BodyShiftGroup) - ApertureGroup: Vacuum chamber aperture. + julia> info(BodyShiftParams) + ApertureParams: Vacuum chamber aperture. ... Found in: ACKicker @@ -60,7 +60,7 @@ \chapter{Element Parameter Groups} \begin{example} julia> info(:Ks2L) User name: Ks2L - Stored in: BMultipoleGroup.Ks + Stored in: BMultipoleParams.Ks Parameter type: Number Units: 1/m^2 Description: Skew, length-integrated, momentum-normalized, @@ -91,10 +91,10 @@ \chapter{Element Parameter Groups} See \sref{s:ele.access} for details. %--------------------------------------------------------------------------------------------------- -\section{ACKickerGroup} +\section{ACKickerParams} \label{s:ackicker.g} -The \vn{ACKickerGroup} holds parameters associated with \vn{ACKicker} elements. +The \vn{ACKickerParams} holds parameters associated with \vn{ACKicker} elements. The parameters of this group are: \begin{example} @@ -104,13 +104,13 @@ \section{ACKickerGroup} \newpage %--------------------------------------------------------------------------------------------------- -\section{BodyShiftGroup} +\section{BodyShiftParams} \label{s:alignment.g} \begin{figure}[bt] \centering \includegraphics{alignment-ref.pdf} \caption[Element alignment.] -{BodyShiftGroup parameters The reference point is the origin +{BodyShiftParams parameters The reference point is the origin about which the element alignment is calculated. A) For straight elements, the reference point is in the center of the element. For \vn{Bend} elements, the reference point is at the midpoint of the chord connecting @@ -127,7 +127,7 @@ \section{BodyShiftGroup} } \label{f:alignment} \end{figure} -The \vn{BodyShiftGroup} gives the alignment (position and angular orientation) of the physical element +The \vn{BodyShiftParams} gives the alignment (position and angular orientation) of the physical element relative to the nominal position defined by the branch coordinates (\sref{s:orient}). Alignment is specified with respect to the ``alignment reference point'' of an element as shown in Fig~\ref{s:alignment}. The \vn{Bend} reference point is chosen to be the center of the chord @@ -136,7 +136,7 @@ \section{BodyShiftGroup} common simulation problem is to simulate a bend with a \vn{z_rot} keeping the entrance and exit endpoints fixed. -The parameters of the \vn{BodyShiftGroup} are: +The parameters of the \vn{BodyShiftParams} are: \begin{example} offset::Vector - $[x, y, z]$ offset. x_rot::Number - Rotation around the x-axis. @@ -170,7 +170,7 @@ \section{BodyShiftGroup} quaternion representation of \vn{x_rot_tot}, \vn{y_rot_tot} and \vn{z_rot_tot}. %--------------------------------------------------------------------------------------------------- -\section{ApertureGroup} +\section{ApertureParams} \label{s:aperture.g} \begin{figure}[bt] @@ -182,7 +182,7 @@ \section{ApertureGroup} } \label{f:apertures} \end{figure} -The \vn{ApertureGroup} stores information about apertures an element may have. +The \vn{ApertureParams} stores information about apertures an element may have. The parameters of this group are: \begin{example} x_limit::Vector\{Number\} - Min/Max x-aperture limits. (m) @@ -271,7 +271,7 @@ \section{ApertureGroup} The \vn{VERTEX} setting for \vn{aperture_shape} is for defining an aperture using a set of vertex points as illustrated in \fig{f:apetures}B. Between vertex points, the aperture can can follow a straight line or the arc of an ellipse. The vertex points are specified by -setting the \vn{section} parameter of \vn{ApertureGroup}. Example: +setting the \vn{section} parameter of \vn{ApertureParams}. Example: \begin{example} wall = Wall2D([Vertex1([1.0, 4.0]), Vertex1([-1.0, 4.0, 6.0]), Vertex1([-5.0, 1.0]), Vertex1([-5.0, -1.0]), @@ -279,10 +279,10 @@ \section{ApertureGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{BMultipoleGroup} +\section{BMultipoleParams} \label{s:bmultipole.g} -The \vn{BMultipoleGroup} group stores magnetic multipole strengths. Also see \vn{EMultipoleGroup}. +The \vn{BMultipoleParams} group stores magnetic multipole strengths. Also see \vn{EMultipoleParams}. The parameters of this group are: \begin{example} vec::Vector{BMultipole1} @@ -368,7 +368,7 @@ \section{BMultipoleGroup} unnormalized quantities will stay constant if the reference energy is varied. %--------------------------------------------------------------------------------------------------- -\section{BeamBeamGroup} +\section{BeamBeamParams} \label{s:beam.beam.g} The parameters of this group are: @@ -387,12 +387,12 @@ \section{BeamBeamGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{BendGroup} +\section{BendParams} \label{s:bend.g} -The \vn{BendGroup} stores the parameters that characterize the shape of a \vn{Bend} element -\sref{s:bend}. The only relavent shape parameter that is not in the \vn{BendGroup} is the -length \vn{L} which is in the \vn{LengthGroup}. +The \vn{BendParams} stores the parameters that characterize the shape of a \vn{Bend} element +\sref{s:bend}. The only relavent shape parameter that is not in the \vn{BendParams} is the +length \vn{L} which is in the \vn{LengthParams}. The parameters of this group are: \begin{example} @@ -586,7 +586,7 @@ \section{BendGroup} The attributes \vn{h1} and \vn{h2} are the curvature of the entrance and exit pole faces. % \item[L, L_arc, L_chord, L_sagitta (output param)] \Newline -The \vn{L} parameter, which is in the \vn{LengthGroup} and not the \vn{BendGroup}, +The \vn{L} parameter, which is in the \vn{LengthParams} and not the \vn{BendParams}, is the arc length of the reference trajectory through the bend. \vn{L_chord} is the chord length from entrance point to exit point. @@ -633,7 +633,7 @@ \section{BendGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{DescriptionGroup} +\section{DescriptionParams} \label{s:descrip.g} The components of this group are element descriptive strings: @@ -656,7 +656,7 @@ \section{DescriptionGroup} in it. %--------------------------------------------------------------------------------------------------- -\section{DownstreamReferenceGroup} +\section{DownstreamReferenceParams} \label{s:dreference.g} The components of this group are: @@ -673,29 +673,29 @@ \section{DownstreamReferenceGroup} \end{example} This group holds the reference energy and species at the downstream end of an element. -Also see the \vn{ReferenceGroup} (\sref{s:reference.g}) documentation. -This group and \vn{ReferenceGroup} group are always paired. +Also see the \vn{ReferenceParams} (\sref{s:reference.g}) documentation. +This group and \vn{ReferenceParams} group are always paired. That is, these two are always both present or both not present in any given element. -For most elements, the values of the parameters in \vn{DownstreamReferenceGroup} will -be the same as the values in the corresponding \vn{ReferenceGroup} parameters. -That is, the value of \vn{species_ref_downstream} in \vn{DownstreamReferenceGroup} will be the same -as the value of \vn{species_ref} in \vn{ReferenceGroup}, the value of \vn{pc_ref_downstream} +For most elements, the values of the parameters in \vn{DownstreamReferenceParams} will +be the same as the values in the corresponding \vn{ReferenceParams} parameters. +That is, the value of \vn{species_ref_downstream} in \vn{DownstreamReferenceParams} will be the same +as the value of \vn{species_ref} in \vn{ReferenceParams}, the value of \vn{pc_ref_downstream} will be the same as \vn{pc_ref}, etc. Elements where the reference energy (here "energy" refers to either pc_ref, E_tot_ref, β, or γ) differs between upstream and downstream include \vn{LCavity} and \vn{Patch} elements. Elements where the reference energy and species differ between upstream and downstream include \vn{Foil} and \vn{Converter} elements. -Parameters of the \vn{DownstreamReferenceGroup} are not user settable and are -calculated by the \accellat bookkeeping routines. See the \vn{ReferenceGroup} documentation +Parameters of the \vn{DownstreamReferenceParams} are not user settable and are +calculated by the \accellat bookkeeping routines. See the \vn{ReferenceParams} documentation for how these parameters are calculated. %--------------------------------------------------------------------------------------------------- -\section{EMultipoleGroup} +\section{EMultipoleParams} \label{s:emultipole.g} -The \vn{EMultipoleGroup} group stores electric multipole strengths. Also see \vn{BMultipoleGroup}. +The \vn{EMultipoleParams} group stores electric multipole strengths. Also see \vn{BMultipoleParams}. The parameters of this group are: \begin{example} vec::Vector{EMultipole1} @@ -772,7 +772,7 @@ \section{EMultipoleGroup} whether normalized or unnormalized quantities will stay constant if the reference energy is varied. %--------------------------------------------------------------------------------------------------- -\section{ForkGroup} +\section{ForkParams} \label{s:fork.g} The components of this group are: @@ -787,7 +787,7 @@ \section{ForkGroup} %--------------------------------------------------------------------------------------------------- -\section{GirderGroup} +\section{GirderParams} \label{s:girder.g} The components of this group are: @@ -797,7 +797,7 @@ \section{GirderGroup} %--------------------------------------------------------------------------------------------------- -\section{InitParticleGroup} +\section{InitParticleParams} \label{s:init.particle.g} The components of this group are: @@ -806,7 +806,7 @@ \section{InitParticleGroup} spin::Vector{Number} - Spin 3-vector. \end{example} %--------------------------------------------------------------------------------------------------- -\section{LengthGroup} +\section{LengthParams} \label{s:length.g} The components of this group are: @@ -818,7 +818,7 @@ \section{LengthGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{LordSlaveStatusGroup} +\section{LordSlaveStatusParams} \label{s:lord.slave.g} \label{s:lord.enum} \label{s:slave.enum} @@ -859,7 +859,7 @@ \section{LordSlaveStatusGroup} section for more details. %--------------------------------------------------------------------------------------------------- -\section{MasterGroup} +\section{MasterParams} \label{s:master.g} The components of this group are: @@ -869,10 +869,10 @@ \section{MasterGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{OrientationGroup} +\section{OrientationParams} \label{s:orientation.g} -The \vn{OrientationGroup} stores the nominal (calculated without alignment shifts) +The \vn{OrientationParams} 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} @@ -884,7 +884,7 @@ \section{OrientationGroup} %--------------------------------------------------------------------------------------------------- -\section{OriginEleGroup} +\section{OriginEleParams} \label{s:origin.ele.g} The components of this group are: @@ -893,16 +893,16 @@ \section{OriginEleGroup} origin_ele_ref_pt::Loc.T - Origin reference point. Default is Loc.CENTER. \end{example} -The \vn{OriginEleGroup} is used with \vn{Fiducial}, \vn{FloorShift}, and \vn{Girder} elements. -The \vn{OriginEleGroup} is used to set the coordinate reference frame from which -the orientation set by the \vn{BodyShiftGroup} is measured. To specify that the floor coordinates are +The \vn{OriginEleParams} is used with \vn{Fiducial}, \vn{FloorShift}, and \vn{Girder} elements. +The \vn{OriginEleParams} is used to set the coordinate reference frame from which +the orientation set by the \vn{BodyShiftParams} is measured. To specify that the floor coordinates are to be used, set the \vn{origin_ele} to \vn{NULL_ELE}. Typically this is the same as using the beginning element of the first branch of a lattice as long as the first element does not have any orientation shifts. %--------------------------------------------------------------------------------------------------- -\section{PatchGroup} +\section{PatchParams} \label{s:patch.g} \begin{figure}[tb] @@ -1094,7 +1094,7 @@ \section{PatchGroup} %--------------------------------------------------------------------------------------------------- -\section{RFGroup} +\section{RFParams} \label{s:rf.g} The components of this group are: @@ -1115,7 +1115,7 @@ \section{RFGroup} \vn{gradient} is kept constant and vice versa. %--------------------------------------------------------------------------------------------------- -\section{RFAutoGroup} +\section{RFAutoParams} \label{s:rfauto.g} The components of this group are: @@ -1127,7 +1127,7 @@ \section{RFAutoGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{ReferenceGroup} +\section{ReferenceParams} \label{s:reference.g} The components of this group are: @@ -1149,10 +1149,10 @@ \section{ReferenceGroup} This group holds the reference energy, species, and time parameters at the upstream end of a lattice element. -Also see the \vn{DownstreamReferenceGroup} group documentation (\sref{s:dreference.g}). -The \vn{DownstreamReferenceGroup} group holds the reference energy and species +Also see the \vn{DownstreamReferenceParams} group documentation (\sref{s:dreference.g}). +The \vn{DownstreamReferenceParams} group holds the reference energy and species at the downstream end of the element. -This group and \vn{DownstreamReferenceGroup} group are always paired. +This group and \vn{DownstreamReferenceParams} group are always paired. That is, these two are always both present or both not present in any given element. For a \vn{Beginning} element, parameters of this group are user settable except for the @@ -1160,10 +1160,10 @@ \section{ReferenceGroup} \vn{extra_dtime_ref}, the parameters of this group are calculated by the \accellat bookkeeping routines and are not user settable. -For most elements, the values of the parameters in \vn{DownstreamReferenceGroup} will -be the same as the values in the corresponding \vn{ReferenceGroup} parameters. -That is, the value of \vn{species_ref_downstream} in \vn{DownstreamReferenceGroup} will be the same -as the value of \vn{species_ref} in \vn{ReferenceGroup}, the value of \vn{pc_ref_downstream} +For most elements, the values of the parameters in \vn{DownstreamReferenceParams} will +be the same as the values in the corresponding \vn{ReferenceParams} parameters. +That is, the value of \vn{species_ref_downstream} in \vn{DownstreamReferenceParams} will be the same +as the value of \vn{species_ref} in \vn{ReferenceParams}, the value of \vn{pc_ref_downstream} will be the same as \vn{pc_ref}, etc. Elements where the reference energy (here "energy" refers to either pc_ref, E_tot_ref, β, or γ) differs between upstream and downstream are elements with a non-zero \vn{dvoltage_ref} and include \vn{LCavity} and \vn{Patch} elements. @@ -1179,7 +1179,7 @@ \section{ReferenceGroup} fundamental charge. Once \vn{E_tot_ref_downstream} has been calculated, the downstream values of pc, β, and γ are calculated using the standard formulas. Notice that \vn{dvoltage_ref} is completely independent from the actual voltage seen by a particle which is set by the \vn{voltage} -parameter of the \vn{RFGroup}. +parameter of the \vn{RFParams}. The downstream reference time \vn{time_ref_downstream} is calculated via \begin{example} @@ -1207,7 +1207,7 @@ \section{ReferenceGroup} %--------------------------------------------------------------------------------------------------- -\section{SolenoidGroup} +\section{SolenoidParams} \label{s:solenoid.g} The components of this group are: @@ -1217,7 +1217,7 @@ \section{SolenoidGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{TrackingGroup} +\section{TrackingParams} \label{s:tracking.g} The components of this group are: @@ -1227,7 +1227,7 @@ \section{TrackingGroup} \end{example} %--------------------------------------------------------------------------------------------------- -\section{TwissGroup} +\section{TwissParams} \label{s:twiss.g} In development diff --git a/manual/ele-types.tex b/manual/ele-types.tex index c32bea0..7de3e1e 100644 --- a/manual/ele-types.tex +++ b/manual/ele-types.tex @@ -49,17 +49,17 @@ \section{ACKicker} Element parameter groups associated with this element type are: \TOPrule \begin{example} - BodyShiftGroup -> Element position/orientation shift. \sref{s:align.g} - ApertureGroup -> Vacuum chamber aperture. \sref{s:aperture.g} - BMultipoleGroup -> Magnetic multipoles. \sref{s:bmultipole.g} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - MasterGroup -> Contains field_master parameter. \sref{s:master.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + 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} + 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} + DescriptionParams -> Element descriptive strings. \sref{s:descrip.g} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -88,13 +88,13 @@ \section{BeamBeam} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -111,15 +111,15 @@ \section{BeginningEle} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - InitParticleGroup -> Initial particle position and spin. \sref{s:init.particle.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - TwissGroup -> Initial Twiss and coupling parameters. \sref{s:twiss.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + DescriptionParams -> Element descriptive strings. \sref{s:descrip.g} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + TwissParams -> Initial Twiss and coupling parameters. \sref{s:twiss.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -143,19 +143,19 @@ \section{Bend} Element parameter groups associated with this element type are: \TOPrule \begin{example} - BodyShiftGroup -> Element position/orientation shift. \sref{s:align.g} - ApertureGroup -> Vacuum chamber aperture. \sref{s:aperture.g} - BMultipoleGroup -> Magnetic multipoles. \sref{s:bmultipole.g} - BendGroup -> Bend element parameters. \sref{s:bend.g} - EMultipoleGroup -> Electric multipoles. \sref{s:emultipole.g} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - MasterGroup -> Contains field_master parameter. \sref{s:master.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + BodyShiftParams -> Element position/orientation shift. \sref{s:align.g} + ApertureParams -> Vacuum chamber aperture. \sref{s:aperture.g} + 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} + 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} + DescriptionParams -> Element descriptive strings. \sref{s:descrip.g} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -177,7 +177,7 @@ \section{Bend} \label{f:bend2} \end{figure} -The \vn{BendGroup} group (\sref{s:bend.g}) contains the parameters that define the shape of the bend. +The \vn{BendParams} group (\sref{s:bend.g}) contains the parameters that define the shape of the bend. Example: \begin{example} @@ -195,13 +195,13 @@ \section{Collimator} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -217,13 +217,13 @@ \section{Converter} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -240,13 +240,13 @@ \section{CrabCavity} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -260,13 +260,13 @@ \section{Drift} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -282,13 +282,13 @@ \section{EGun} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -306,13 +306,13 @@ \section{Fiducial} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - LordSlaveGroup -> Element lord and slave status. \sref{s:lord.slave.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + TrackingParams -> Default tracking settings. \sref{s:tracking.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -361,13 +361,13 @@ \section{Fork} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - TrackingGroup -> Default tracking settings. \sref{s:tracking.g} - ForkGroup -> Fork parameters. \sref{s:fork.g} - ReferenceGroup -> Reference energy and species. \sref{s:reference.g} - DownstreamReferenceGroup -> Reference energy and species at downstream end. \sref{s:dreference.g} + OrientationParams -> 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} + ForkParams -> Fork parameters. \sref{s:fork.g} + ReferenceParams -> Reference energy and species. \sref{s:reference.g} + DownstreamReferenceParams -> Reference energy and species at downstream end. \sref{s:dreference.g} \end{example} \BOTTOMrule @@ -559,10 +559,10 @@ \section{Girder} Element parameter groups associated with this element type are: \TOPrule \begin{example} - OrientationGroup -> Floor floor position and orientation. \sref{s:orientation.g} - LengthGroup -> Length and s-position parameters. \sref{s:length.g} - DescriptionGroup -> Element descriptive strings. \sref{s:descrip.g} - BodyShiftGroup -> Alignment with respect to the reference. \sref{s:alignment.g} + OrientationParams -> 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} \end{example} \BOTTOMrule @@ -601,7 +601,7 @@ \section{Girder} The reference frame from which a \vn{Girder}'s orientation is measured is set by the \vn{origin_ele} and \vn{origin_ele_ref_point} parameters (\sref{s:origin.ele.g}). -Orientation shifts are controlled by the \vn{BodyShiftGroup} (\sref{s:align.g}). +Orientation shifts are controlled by the \vn{BodyShiftParams} (\sref{s:align.g}). When a girder is shifted in space, the elements it supports are also shifted. In this case, the orientation diff --git a/manual/enums.tex b/manual/enums.tex index bed1706..4bcaad4 100644 --- a/manual/enums.tex +++ b/manual/enums.tex @@ -23,7 +23,7 @@ \section{Enums} The group name followed by a \vn{.T} suffix denotes the enum type. For example: \begin{example} - struct ApertureGroup <: EleParameterGroup + struct ApertureParams <: EleParameterParams aperture_type::ApertureShape.T = ApertureShape.ELLIPTICAL aperture_at::BodyLoc.T = BodyLoc.ENTRANCE_END ... @@ -42,7 +42,7 @@ \section{Enums} \centering {\tt \begin{tabular}{llll} \toprule - {\it Group} & {\it Section} & {\it Group} & {\it Section} \\ \midrule + {\it Params} & {\it Section} & {\it Params} & {\it Section} \\ \midrule BendType & \sref{s:bendtype} & Slave & \sref{s:slave.enum} \\ BodyLoc & \sref{s:bodyloc} & Loc & \sref{s:loc} \\ BranchGeometry & \sref{s:branchgeometry} & Select & \sref{s:select} \\ @@ -56,7 +56,7 @@ \section{Enums} \label{t:enum} \end{table} %--------------------------------------------------------------------------------------------------- -\subsection{BendType Enum Group} +\subsection{BendType Enum Params} \label{s:bendtype} \vspace*{-2ex} @@ -69,13 +69,13 @@ \subsection{BendType Enum Group} \end{tabular} \hfill \break \vskip -1.2ex -\vn{BendType} is used with the \vn{bend_type} parameter of the \vn{BendGroup} parameter group +\vn{BendType} is used with the \vn{bend_type} parameter of the \vn{BendParams} parameter group (\sref{s:bend.g}). The \vn{bend_type} parameter gives the ``logical'' shape of the bend. The setting of \vn{bend_type} is only relavent when the bend curvature is varied. See \sref{s:bend.g} for more details. %--------------------------------------------------------------------------------------------------- -\subsection{BodyLoc Enum Group} +\subsection{BodyLoc Enum Params} \label{s:bodyloc} \vspace*{-2ex} @@ -97,7 +97,7 @@ \subsection{BodyLoc Enum Group} For example, specifying where apertures are placed. %--------------------------------------------------------------------------------------------------- -\subsection{BranchGeometry Enum Group} +\subsection{BranchGeometry Enum Params} \label{s:branchgeometry} \vspace*{-2ex} @@ -132,7 +132,7 @@ \subsection{BranchGeometry Enum Group} closed if that is desired. %--------------------------------------------------------------------------------------------------- -\subsection{Cavity Enum Group} +\subsection{Cavity Enum Params} \label{s:cavity} \vspace*{-2ex} @@ -147,7 +147,7 @@ \subsection{Cavity Enum Group} \hfill \break \vskip -1.2ex %--------------------------------------------------------------------------------------------------- -\subsection{ParticleState Enum Group} +\subsection{ParticleState Enum Params} \label{s:particlestate} State of a particle. @@ -176,7 +176,7 @@ \subsection{ParticleState Enum Group} is needed. %--------------------------------------------------------------------------------------------------- -\subsection{Loc Enum Group} +\subsection{Loc Enum Params} \label{s:loc} \vspace*{-2ex} @@ -194,7 +194,7 @@ \subsection{Loc Enum Group} %--------------------------------------------------------------------------------------------------- -\subsection{Select Enum Group} +\subsection{Select Enum Params} \label{s:select} \vspace*{-2ex} @@ -210,7 +210,7 @@ \subsection{Select Enum Group} %--------------------------------------------------------------------------------------------------- -\subsection{ExactMultipoles Enum Group} +\subsection{ExactMultipoles Enum Params} \label{s:exactmultipoles} \vspace*{-2ex} @@ -227,7 +227,7 @@ \subsection{ExactMultipoles Enum Group} %--------------------------------------------------------------------------------------------------- -\subsection{FiducialPt Enum Group} +\subsection{FiducialPt Enum Params} \label{s:fiducialpt} \vspace*{-2ex} @@ -264,7 +264,7 @@ \section{Holy Traits} \end{example} %--------------------------------------------------------------------------------------------------- -\subsection{ApertureShape Holy Trait Group} +\subsection{ApertureShape Holy Trait Params} \label{s:apertureshape} \vspace*{-2ex} @@ -279,7 +279,7 @@ \subsection{ApertureShape Holy Trait Group} \hfill \break \vskip -1.2ex %--------------------------------------------------------------------------------------------------- -\subsection{EleGeometry Holy Trait Group} +\subsection{EleGeometry Holy Trait Params} \label{s:elegeometry} \vspace*{-2ex} diff --git a/manual/new-ele.tex b/manual/new-ele.tex index 61629ec..367c196 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::OrientationGroup, ele::Ele) + function propagate_ele_geometry(::Type{CORKSCREW}, fstart::OrientationParams, ele::Ele) ... - return floor_end # OrientationGroup at the downstream end of the element. + return floor_end # OrientationParams at the downstream end of the element. end \end{example} diff --git a/scripts/tex_check_ele-param_groups.jl b/scripts/tex_check_ele-param_groups.jl index 55a791e..a890531 100644 --- a/scripts/tex_check_ele-param_groups.jl +++ b/scripts/tex_check_ele-param_groups.jl @@ -13,7 +13,7 @@ # The comment character in the first line of the block will result in this script ignoring the block # when this script makes a list from the file of what fields a parameter group has. # -# Note: Due to the complexity of BMultipoleGroup and EMultipoleGroup, these groups are ignored +# Note: Due to the complexity of BMultipoleParams and EMultipoleParams, these groups are ignored # by this script. #- @@ -47,7 +47,7 @@ while true if !startswith(line, "\\section{"); line = strip(readline(epgfile)); end if eof(epgfile); break; end if !startswith(line, "\\section{"); continue; end - if !endswith(line, "Group}"); continue; end + if !endswith(line, "Params}"); continue; end group = split(line[10:end], '}')[1] if group ∉ keys(group_list); error("`$(group)` not in table of groups at top of $fname file."); end @@ -59,7 +59,7 @@ while true pop!(group_list, group) # Find field definitions. First find beginning of list. - if group == "BMultipoleGroup"|| group == "EMultipoleGroup"; continue; end + if group == "BMultipoleParams"|| group == "EMultipoleParams"; continue; end fields_in_file = [] in_example = false @@ -88,6 +88,6 @@ while true end if length(group_list) != 0 - println("Groups in table of groups at top of $fname that do not have a corresponding section:") + println("Paramss in table of groups at top of $fname that do not have a corresponding section:") println(group_list) end \ No newline at end of file diff --git a/src/AcceleratorLattice.jl b/src/AcceleratorLattice.jl index d148215..f7485e5 100644 --- a/src/AcceleratorLattice.jl +++ b/src/AcceleratorLattice.jl @@ -69,12 +69,12 @@ 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 EleParameterGroup, BodyShiftGroup, OrientationGroup, BMultipole, BMultipoleGroup, BeamBeamGroup -export EMultipole, EMultipoleGroup, BendGroup, ApertureGroup, DescriptionGroup, RFGroup, SolenoidGroup -export TrackingGroup, LengthGroup, ReferenceGroup, DownstreamReferenceGroup, ForkGroup -export MasterGroup, LordSlaveStatusGroup, ACKickerGroup -export GirderGroup, PatchGroup, RFAutoGroup, OutputGroup, full_parameter_name -export TwissGroup, Twiss1, Wall2D, Vertex1, InitSpinGroup, InitParticleGroup, show_changed +export EleParameterParams, BodyShiftParams, OrientationParams, BMultipole, BMultipoleParams, BeamBeamParams +export EMultipole, EMultipoleParams, BendParams, ApertureParams, DescriptionParams, RFParams, SolenoidParams +export TrackingParams, LengthParams, ReferenceParams, DownstreamReferenceParams, ForkParams +export MasterParams, LordSlaveStatusParams, ACKickerParams +export GirderParams, PatchParams, RFAutoParams, OutputParams, full_parameter_name +export TwissParams, Twiss1, Wall2D, Vertex1, InitSpinParams, InitParticleParams, show_changed export info, ctrl, var, create_external_ele, ele_param_info, units, ele_param_group_syms export show_group, switch_list_dict, lat_sanity_check, NULL_ELE, NULL_BRANCH, is_null export ele_param_struct_field_to_user_sym, multipole!, index, integer, rot_angles, Quaternion @@ -88,6 +88,6 @@ export rotX, rotY, rotZ, rot, rot!, bend_quaternion, lat_ele_dict export norm # From SimUtils -export cos_one +export one_cos, modulo2, un_sinc, cosc end # module diff --git a/src/accessor.jl b/src/accessor.jl index b6a420e..8c4de3e 100644 --- a/src/accessor.jl +++ b/src/accessor.jl @@ -68,7 +68,7 @@ Overloads the dot struct component selection operator. ## Notes Exceptions: Something like `ele.Kn2L` is handled specially since storage for this parameter may -not exist (parameter is stored in `ele.pdict[:BMultipoleGroup].pole(N).Kn` where `N` is some integer). +not exist (parameter is stored in `ele.pdict[:BMultipoleParams].pole(N).Kn` where `N` is some integer). Also see: `get_elegroup_param` """ Base.getproperty(ele::Ele, sym::Symbol) @@ -305,8 +305,8 @@ end # get_elegroup_param """ - Internal: get_elegroup_param(ele::Ele, group::EleParameterGroup, pinfo::ParamInfo) - Internal: get_elegroup_param(ele::Ele, group::Union{BMultipoleGroup, EMultipoleGroup}, pinfo::ParamInfo) + Internal: get_elegroup_param(ele::Ele, group::EleParameterParams, pinfo::ParamInfo) + Internal: get_elegroup_param(ele::Ele, group::Union{BMultipoleParams, EMultipoleParams}, pinfo::ParamInfo) Internal function used by Base.getproperty. @@ -314,7 +314,7 @@ This function will return dependent values. EG: integrated multipole value even if stored value is not integrated. """ get_elegroup_param -function get_elegroup_param(ele::Ele, group::EleParameterGroup, pinfo::ParamInfo) +function get_elegroup_param(ele::Ele, group::EleParameterParams, pinfo::ParamInfo) if pinfo.parent_group == pinfo.paramkind # Example see: ParamInfo(:twiss) return group else @@ -324,7 +324,7 @@ end #- -function get_elegroup_param(ele::Ele, group::Union{BMultipoleGroup, EMultipoleGroup}, pinfo::ParamInfo) +function get_elegroup_param(ele::Ele, group::Union{BMultipoleParams, EMultipoleParams}, pinfo::ParamInfo) (mtype, order, group_type) = multipole_type(pinfo.user_sym) if group_type == Nothing; error("Internal error. Unknown multipole group type. Please report."); end @@ -341,7 +341,7 @@ function get_elegroup_param(ele::Ele, group::Union{BMultipoleGroup, EMultipoleGr val = getfield(mul, pinfo.struct_sym) if mtype == "tilt" || mtype == "Etilt" || mtype == "integrated" || mtype == "Eintegrated"; return val; end - group_type == BMultipoleGroup ? integrated = mul.integrated : integrated = mul.Eintegrated + group_type == BMultipoleParams ? integrated = mul.integrated : integrated = mul.Eintegrated if mtype[end] == 'L' && !integrated return val * ele.L elseif mtype[end] != 'L' && integrated @@ -357,11 +357,11 @@ end # set_elegroup_param! """ - Internal: set_elegroup_param!(ele::Ele, group::EleParameterGroup, pinfo::ParamInfo, value) + Internal: set_elegroup_param!(ele::Ele, group::EleParameterParams, pinfo::ParamInfo, value) """ set_elegroup_param -function set_elegroup_param!(ele::Ele, group::EleParameterGroup, pinfo::ParamInfo, value) +function set_elegroup_param!(ele::Ele, group::EleParameterParams, pinfo::ParamInfo, value) if !isnothing(pinfo.sub_struct) # Example see: ParamInfo(:a_beta) return setfield!(pinfo.sub_struct(group), pinfo.struct_sym, value) else @@ -369,7 +369,7 @@ function set_elegroup_param!(ele::Ele, group::EleParameterGroup, pinfo::ParamInf end end -function set_elegroup_param!(ele::Ele, group::BMultipoleGroup, pinfo::ParamInfo, value) +function set_elegroup_param!(ele::Ele, group::BMultipoleParams, pinfo::ParamInfo, value) (mtype, order, group_type) = multipole_type(pinfo.user_sym) mul = multipole!(group, order, insert = true) if mtype == "tilt" || mtype == "integrated"; return setfield!(mul, pinfo.struct_sym, value); end @@ -385,7 +385,7 @@ function set_elegroup_param!(ele::Ele, group::BMultipoleGroup, pinfo::ParamInfo, return setfield!(mul, pinfo.struct_sym, value) end -function set_elegroup_param!(ele::Ele, group::EMultipoleGroup, pinfo::ParamInfo, value) +function set_elegroup_param!(ele::Ele, group::EMultipoleParams, pinfo::ParamInfo, value) (mtype, order, group_type) = multipole_type(pinfo.user_sym) mul = multipole!(group, order, insert = true) if mtype == "Etilt" || mtype == "Eintegrated"; return setfield!(mul, pinfo.struct_sym, value); end @@ -421,14 +421,14 @@ end # base_field(group, pinfo) """ - base_field(group::EleParameterGroup, pinfo::ParamInfo) -> BaseEleParameterGroup + base_field(group::EleParameterParams, pinfo::ParamInfo) -> BaseEleParameterParams Return group containing parameter described by `pinfo`. For most parameters this will be the `group` -itself. However, for example, for the parameter `eta_a`, `group` will be a `TwissGroup` instance +itself. However, for example, for the parameter `eta_a`, `group` will be a `TwissParams` instance and returned is the sub group `group.a`. -""" base_field(group::EleParameterGroup, pinfo::ParamInfo) +""" base_field(group::EleParameterParams, pinfo::ParamInfo) -function base_field(group::EleParameterGroup, pinfo::ParamInfo) +function base_field(group::EleParameterParams, pinfo::ParamInfo) if isnothing(pinfo.sub_struct) return group else # Example see: ParamInfo(:a_beta) @@ -446,81 +446,81 @@ end function output_parameter(sym::Symbol, ele::Ele, output_group::Type{T}) where T <: BaseOutput if sym == :rho - if :BendGroup ∉ keys(ele.pdict); return NaN; end + if :BendParams ∉ keys(ele.pdict); return NaN; end ele.g == 0 ? (return NaN) : return 1/ele.g elseif sym == :L_sagitta - if :BendGroup ∉ keys(ele.pdict); return NaN; end - ele.g == 0 ? (return 0.0) : return -cos_one(ele.angle/2) / ele.g + if :BendParams ∉ keys(ele.pdict); return NaN; end + ele.g == 0 ? (return 0.0) : return one_cos(ele.angle/2) / ele.g elseif sym == :bend_field - if :BendGroup ∉ keys(ele.pdict); return NaN; end + if :BendParams ∉ keys(ele.pdict); return NaN; end norm_bend_field = ele.g + cos(ele.tilt0) * ele.Kn0 + sin(ele.tilt0) * ele.Ks0 return norm_bend_field * ele.pc_ref / (C_LIGHT * charge(ele.species_ref)) elseif sym == :norm_bend_field - if :BendGroup ∉ keys(ele.pdict); return NaN; end + if :BendParams ∉ keys(ele.pdict); return NaN; end return ele.g + cos(ele.tilt0) * ele.Kn0 + sin(ele.tilt0) * ele.Ks0 elseif sym == :β_ref - if :ReferenceGroup ∉ keys(ele.pdict); return NaN; end + if :ReferenceParams ∉ keys(ele.pdict); return NaN; end return ele.pc_ref / ele.E_tot_ref elseif sym == :γ_ref - if :ReferenceGroup ∉ keys(ele.pdict); return NaN; end + if :ReferenceParams ∉ keys(ele.pdict); return NaN; end return ele.E_tot_ref / massof(ele.species_ref) elseif sym == :β_ref_downstream - if :DownstreamReferenceGroup ∉ keys(ele.pdict); return NaN; end + if :DownstreamReferenceParams ∉ keys(ele.pdict); return NaN; end return ele.pc_ref_downstream / ele.E_tot_ref_downstream elseif sym == :γ_ref_downstream - if :DownstreamReferenceGroup ∉ keys(ele.pdict); return NaN; end + if :DownstreamReferenceParams ∉ keys(ele.pdict); return NaN; end return ele.E_tot_ref_downstream / massof(ele.species_ref_downstream) elseif sym == :q_shift - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end - ag = ele.pdict[:BodyShiftGroup] + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end + ag = ele.pdict[:BodyShiftParams] return Quaternion(ag.x_rot, ag.y_rot, ag.z_rot) elseif sym == :offset_tot - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end if isnothing(girder(ele)); return ele.offset; end - ag = ele.pdict[:BodyShiftGroup] - orient_girder = OrientationGroup(girder(ele).offset_tot, girder(ele).q_shift_tot) - orient_ele = OrientationGroup(ele.offset, ele.q_shift) + ag = ele.pdict[:BodyShiftParams] + orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot) + orient_ele = OrientationParams(ele.offset, ele.q_shift) return coord_transform(orient_ele, orient_girder).r elseif sym == :x_rot_tot - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end if isnothing(girder(ele)); return ele.x_rot; end - ag = ele.pdict[:BodyShiftGroup] - orient_girder = OrientationGroup(girder(ele).offset_tot, girder(ele).q_shift_tot) - orient_ele = OrientationGroup(ele.offset, ele.q_shift) + ag = ele.pdict[:BodyShiftParams] + orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot) + orient_ele = OrientationParams(ele.offset, ele.q_shift) return rot_angles(coord_transform(orient_ele, orient_girder).q)[1] elseif sym == :y_rot_tot - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end if isnothing(girder(ele)); return ele.y_rot; end - ag = ele.pdict[:BodyShiftGroup] - orient_girder = OrientationGroup(girder(ele).offset_tot, girder(ele).q_shift_tot) - orient_ele = OrientationGroup(ele.offset, ele.q_shift) + ag = ele.pdict[:BodyShiftParams] + orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot) + orient_ele = OrientationParams(ele.offset, ele.q_shift) return rot_angles(coord_transform(orient_ele, orient_girder).q)[2] elseif sym == :z_rot_tot - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end if isnothing(girder(ele)); return ele.z_rot; end - ag = ele.pdict[:BodyShiftGroup] - orient_girder = OrientationGroup(girder(ele).offset_tot, girder(ele).q_shift_tot) - orient_ele = OrientationGroup(ele.offset, ele.q_shift) + ag = ele.pdict[:BodyShiftParams] + orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot) + orient_ele = OrientationParams(ele.offset, ele.q_shift) return rot_angles(coord_transform(orient_ele, orient_girder).q)[3] elseif sym == :q_shift_tot - if :BodyShiftGroup ∉ keys(ele.pdict); return NaN; end + if :BodyShiftParams ∉ keys(ele.pdict); return NaN; end if isnothing(girder(ele)); return ele.q_shift; end - ag = ele.pdict[:BodyShiftGroup] - orient_girder = OrientationGroup(girder(ele).offset_tot, girder(ele).q_shift_tot) - orient_ele = OrientationGroup(ele.offset, ele.q_shift) + ag = ele.pdict[:BodyShiftParams] + orient_girder = OrientationParams(girder(ele).offset_tot, girder(ele).q_shift_tot) + orient_ele = OrientationParams(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 221abb7..d204f73 100644 --- a/src/bookkeeper.jl +++ b/src/bookkeeper.jl @@ -155,7 +155,7 @@ function bookkeeper_ele!(ele::Ele, changed::ChangedLedger, previous_ele::Ele) cdict = ele.pdict[:changed] for param in copy(keys(cdict)) - if typeof(param) != Symbol # Something like param = `ReferenceGroup` + if typeof(param) != Symbol # Something like param = `ReferenceParams` group = param else pinfo = ele_param_info(param, throw_error = false) @@ -168,7 +168,7 @@ function bookkeeper_ele!(ele::Ele, changed::ChangedLedger, previous_ele::Ele) end end - if AllGroup in keys(cdict); pop!(cdict, AllGroup); end + if AllParams in keys(cdict); pop!(cdict, AllParams); end return end @@ -205,20 +205,20 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele # Transfer info from lord to slave for group in PARAM_GROUPS_LIST[typeof(lord)] - if group == LengthGroup; continue; end # Do not modify length of slave - if group == DownstreamReferenceGroup; continue; end - if group == OrientationGroup; continue; end - if group == LordSlaveStatusGroup; continue; end + if group == LengthParams; continue; end # Do not modify length of slave + if group == DownstreamReferenceParams; continue; end + if group == OrientationParams; continue; end + if group == LordSlaveStatusParams; continue; end group_changed = has_changed(lord, group) - if group_changed && group != AlginmentGroup + if group_changed && group != AlginmentParams slave.pdict[Symbol(group)] = copy(lord.pdict[Symbol(group)]) slave.pdict[:changed][group] = "changed" end # Note: BodyLoc.CENTER cannot be handled. # Possible solution: Add aperture_offset parameter to group. - if group == ApertureGroup && group_changed && length(lord.slaves) > 1 + if group == ApertureParams && group_changed && length(lord.slaves) > 1 lord.orientation == 1 ? ixs = ix_slave : ixs = length(lord.slaves) + 1 - ix_slave if slave.aperture_at == BodyLoc.ENTRANCE_END if ixs > 1; slave.aperture_at = BodyLoc.NOWHERE; end @@ -235,28 +235,28 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele end end - if group == EMultipoleGroup && (group_changed ||changed.this_ele_length) - for (ix, elord) in enumerate(lord.pdict[:EMultipoleGroup].pole) + if group == EMultipoleParams && (group_changed ||changed.this_ele_length) + for (ix, elord) in enumerate(lord.pdict[:EMultipoleParams].pole) if !elord.Eintegrated; continue; end - eslave = deepcopy(slave.pdict[:EMultipoleGroup].pole[ix]) + eslave = deepcopy(slave.pdict[:EMultipoleParams].pole[ix]) eslave.En = elord.En * L_rel eslave.Es = elord.Es * L_rel end end - if group == TrackingGroup && (group_changed ||changed.this_ele_length) + if group == TrackingParams && (group_changed ||changed.this_ele_length) if lord.num_steps > 0 slave.num_steps = nint(lord.num_steps * L_rel) end end - if group == BodyShiftGroup && (group_changed ||changed.this_ele_length) - if haskey(lord.pdict, :BendGroup) - bgl = lord.pdict[:BendGroup] - bgs = slave.pdict[:BendGroup] + if group == BodyShiftParams && (group_changed ||changed.this_ele_length) + if haskey(lord.pdict, :BendParams) + bgl = lord.pdict[:BendParams] + 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 = OrientationGroup(r = [0.0, 0.0, -0.5*bgl.l_chord]) + ct = OrientationParams(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 @@ -265,11 +265,11 @@ function bookkeeper_superslave!(slave::Ele, changed::ChangedLedger, previous_ele ct = rot(ct, bend_quaternion(0.5*bgs.angle, bg.ref_tilt)) # translate from beginning of slave to center of slave chord. ct.r = ct.r + [0.0, 0.0, 0.5*bgs.l_chord] - # Apply total transformation of BodyShiftGroup. - bs = lord.pdict[:BodyShiftGroup] - lord_shift = OrientationGroup(bs.offset, Quaternion(bs.x_rot, bs.y_rot, bs.z_rot)) + # Apply total transformation of BodyShiftParams. + bs = lord.pdict[:BodyShiftParams] + lord_shift = OrientationParams(bs.offset, Quaternion(bs.x_rot, bs.y_rot, bs.z_rot)) slave_shift = coord_transform(lord_shift, ct) - slave.BodyShiftGroup = BodyShiftGroup(slave_shift.r, rot_angles(slave_shift.q)...) + slave.BodyShiftParams = BodyShiftParams(slave_shift.r, rot_angles(slave_shift.q)...) end end end @@ -306,9 +306,9 @@ function bookkeeper_multipass_slave!(slave::Ele, changed::ChangedLedger, previou if isnothing(pinfo); continue; end group = pinfo.parent_group if group ∉ keys(ELE_PARAM_GROUP_INFO); continue; end # Ignore custom stuff - if group == LengthGroup; continue; end # Do not modify length of slave - if group == ReferenceGroup; continue; end # Slave ReferenceGroup independent of lord - if group == DownstreamReferenceGroup; continue; end + if group == LengthParams; continue; end # Do not modify length of slave + if group == ReferenceParams; continue; end # Slave ReferenceParams independent of lord + if group == DownstreamReferenceParams; continue; end slave.pdict[Symbol(group)] = deepcopy(lord.pdict[Symbol(group)]) slave.pdict[:changed][group] = "changed" @@ -387,34 +387,34 @@ end # Essentially no bookkeeping is needed for groups not covered by a specific method. function elegroup_bookkeeper!(ele::Ele, group::Type{T}, changed::ChangedLedger, - previous_ele::Ele) where T <: EleParameterGroup + previous_ele::Ele) where T <: EleParameterParams clear_changed!(ele, group) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleGroup}, ...) -# BMultipoleGroup bookkeeping. +# elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleParams}, ...) +# BMultipoleParams bookkeeping. -function elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleGroup}, changed::ChangedLedger, previous_ele::Ele) - bmg = ele.BMultipoleGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleParams}, changed::ChangedLedger, previous_ele::Ele) + bmg = ele.BMultipoleParams cdict = ele.changed - if !has_changed(ele, BMultipoleGroup) && !changed.this_ele_length && !changed.ref_group; return; end + if !has_changed(ele, BMultipoleParams) && !changed.this_ele_length && !changed.ref_group; return; end ff = ele.pc_ref / (C_LIGHT * charge(ele.species_ref)) if ele.slave_status == Slave.SUPER lord = ele.super_lords[1] L_rel = ele.L / lord.L - for (ix, lpole) in enumerate(lord.pdict[:BMultipoleGroup].pole) - epole = deepcopy(ele.pdict[:BMultipoleGroup].pole[ix]) + for (ix, lpole) in enumerate(lord.pdict[:BMultipoleParams].pole) + epole = deepcopy(ele.pdict[:BMultipoleParams].pole[ix]) if lpole.integrated epole.Kn = lpole.Kn * L_rel epole.Bn = lpole.Bn * L_rel epole.Ks = lpole.Ks * L_rel epole.Bs = lpole.Bs * L_rel else - ele.pdict[:BMultipoleGroup].pole[ix] = deepcopy(lpole) + ele.pdict[:BMultipoleParams].pole[ix] = deepcopy(lpole) end end @@ -423,7 +423,7 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleGroup}, changed::C for param in keys(cdict) if typeof(param) == DataType; continue; end (mtype, order, group) = multipole_type(param) - if isnothing(group) || group != BMultipoleGroup || mtype == "tilt"; continue; end + if isnothing(group) || group != BMultipoleParams || mtype == "tilt"; continue; end mul = multipole!(bmg, order) if mtype[1:2] == "Kn"; mul.Bn = mul.Kn * ff @@ -449,26 +449,26 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{BMultipoleGroup}, changed::C end end - clear_changed!(ele, BMultipoleGroup) + clear_changed!(ele, BMultipoleParams) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{BendGroup}, ...) -# BendGroup bookkeeping. +# elegroup_bookkeeper!(ele::Ele, group::Type{BendParams}, ...) +# BendParams bookkeeping. -function elegroup_bookkeeper!(ele::Ele, group::Type{BendGroup}, changed::ChangedLedger, previous_ele::Ele) - bg = ele.BendGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{BendParams}, changed::ChangedLedger, previous_ele::Ele) + bg = ele.BendParams cdict = ele.changed - if !has_changed(ele, BendGroup) && !changed.this_ele_length && !changed.ref_group; return; end + if !has_changed(ele, BendParams) && !changed.this_ele_length && !changed.ref_group; return; end if ele.slave_status == Slave.SUPER lord = ele.super_lords[1] L_rel = ele.L / lord.L ix_slave = slave_index(ele) - ele.BendGroup = copy(lord.BendGroup) - bg = ele.BendGroup + ele.BendParams = copy(lord.BendParams) + bg = ele.BendParams bg.angle = lord.angle * L_rel if ix_slave < length(lord.slaves) bg.e2 = 0 @@ -487,7 +487,7 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{BendGroup}, changed::Changed param_conflict_check(ele, :e2, :e2_rect) if haskey(cdict, :bend_field_ref) - # Use previous_ele for ref parameters since BendGroup is first group to be bookkeeped + # Use previous_ele for ref parameters since BendParams is first group to be bookkeeped bg.g = bg.bend_field_ref * C_LIGHT * charge(previous_ele.species_ref_downstream) / previous_ele.pc_ref_downstream end @@ -523,7 +523,7 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{BendGroup}, changed::Changed if ele.L != L ele.L = L - elegroup_bookkeeper!(ele, LengthGroup, changed, previous_ele) + elegroup_bookkeeper!(ele, LengthParams, changed, previous_ele) end if haskey(cdict, :e1) @@ -546,18 +546,18 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{BendGroup}, changed::Changed bg.e2 = bg.e2_rect - 0.5 * bg.angle end - clear_changed!(ele, BendGroup) + clear_changed!(ele, BendParams) end return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{LengthGroup}, ...) -# Low level LengthGroup bookkeeping. +# elegroup_bookkeeper!(ele::Ele, group::Type{LengthParams}, ...) +# Low level LengthParams bookkeeping. -function elegroup_bookkeeper!(ele::Ele, group::Type{LengthGroup}, changed::ChangedLedger, previous_ele::Ele) - lg = ele.LengthGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{LengthParams}, changed::ChangedLedger, previous_ele::Ele) + lg = ele.LengthParams cdict = ele.changed if haskey(cdict, :L) @@ -585,19 +585,19 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{LengthGroup}, changed::Chang end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{RFGroup}, ...) +# elegroup_bookkeeper!(ele::Ele, group::Type{RFParams}, ...) """ - elegroup_bookkeeper!(ele::Ele, group::Type{RFGroup}, changed::ChangedLedger, previous_ele::Ele) + elegroup_bookkeeper!(ele::Ele, group::Type{RFParams}, changed::ChangedLedger, previous_ele::Ele) -`RFGroup` bookkeeping. +`RFParams` bookkeeping. """ -function elegroup_bookkeeper!(ele::Ele, group::Type{RFGroup}, changed::ChangedLedger, previous_ele::Ele) - rg = ele.RFGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{RFParams}, changed::ChangedLedger, previous_ele::Ele) + rg = ele.RFParams cdict = ele.changed - if !has_changed(ele, RFGroup) && !has_changed(ele, ReferenceGroup) && !changed.this_ele_length + if !has_changed(ele, RFParams) && !has_changed(ele, ReferenceParams) && !changed.this_ele_length return end @@ -615,25 +615,25 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{RFGroup}, changed::ChangedLe rg.gradient = rg.voltage / ele.L end - clear_changed!(ele, RFGroup) + clear_changed!(ele, RFParams) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceGroup}, ...) +# elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceParams}, ...) """ - elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceGroup}, changed::ChangedLedger, previous_ele::Ele) + elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceParams}, changed::ChangedLedger, previous_ele::Ele) -`ReferenceGroup` bookkeeping. This also includes `DownstreamReferenceGroup` bookkeeping. +`ReferenceParams` bookkeeping. This also includes `DownstreamReferenceParams` bookkeeping. """ -function elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceGroup}, changed::ChangedLedger, previous_ele::Ele) - rg = ele.ReferenceGroup - drg = ele.DownstreamReferenceGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceParams}, changed::ChangedLedger, previous_ele::Ele) + rg = ele.ReferenceParams + drg = ele.DownstreamReferenceParams cdict = ele.changed - if has_changed(ele, ReferenceGroup); changed.ref_group = true; end + if has_changed(ele, ReferenceParams); changed.ref_group = true; end if ele.slave_status == Slave.SUPER lord = ele.super_lords[1] @@ -670,7 +670,7 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceGroup}, changed::Ch drg.pc_ref_downstream = rg.pc_ref drg.E_tot_ref_downstream = rg.E_tot_ref - clear_changed!(ele, ReferenceGroup) + clear_changed!(ele, ReferenceParams) return end @@ -701,48 +701,48 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{ReferenceGroup}, changed::Ch if ele.slave_status == Slave.MULTIPASS lord = ele.pdict[:multipass_lord] if lord.pdict[:slaves][1] === ele - lord.ReferenceGroup = rg - haskey(lord.pdict, :changed) ? lord.changed = Dict(ReferenceGroup => "changed") : - lord.changed[ReferenceGroup] = "changed" + lord.ReferenceParams = rg + haskey(lord.pdict, :changed) ? lord.changed = Dict(ReferenceParams => "changed") : + lord.changed[ReferenceParams] = "changed" end end # End stuff - clear_changed!(ele, ReferenceGroup) + clear_changed!(ele, ReferenceParams) changed.ref_group = (old_drg != drg) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{OrientationGroup}, ...) -# OrientationGroup bookkeeper +# elegroup_bookkeeper!(ele::Ele, group::Type{OrientationParams}, ...) +# OrientationParams bookkeeper -function elegroup_bookkeeper!(ele::Ele, group::Type{OrientationGroup}, +function elegroup_bookkeeper!(ele::Ele, group::Type{OrientationParams}, changed::ChangedLedger, previous_ele::Ele) - fpg = ele.OrientationGroup + fpg = ele.OrientationParams cdict = ele.changed - if has_changed(ele, OrientationGroup) || changed.this_ele_length; changed.floor_position = true; end + if has_changed(ele, OrientationParams) || 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.OrientationGroup = propagate_ele_geometry(previous_ele) - clear_changed!(ele, OrientationGroup) + ele.OrientationParams = propagate_ele_geometry(previous_ele) + clear_changed!(ele, OrientationParams) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{SolenoidGroup}, ...) -# SolenoidGroup bookkeeping. +# elegroup_bookkeeper!(ele::Ele, group::Type{SolenoidParams}, ...) +# SolenoidParams bookkeeping. -function elegroup_bookkeeper!(ele::Ele, group::Type{SolenoidGroup}, changed::ChangedLedger, previous_ele::Ele) - sg = ele.SolenoidGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{SolenoidParams}, changed::ChangedLedger, previous_ele::Ele) + sg = ele.SolenoidParams cdict = ele.changed - if !has_changed(ele, SolenoidGroup) && !changed.ref_group; return; end + if !has_changed(ele, SolenoidParams) && !changed.ref_group; return; end ff = ele.pc_ref / (C_LIGHT * charge(ele.species_ref)) @@ -756,16 +756,16 @@ function elegroup_bookkeeper!(ele::Ele, group::Type{SolenoidGroup}, changed::Cha sg.Bsol = sg.Ksol * ff end - clear_changed!(ele, SolenoidGroup) + clear_changed!(ele, SolenoidParams) return end #--------------------------------------------------------------------------------------------------- -# elegroup_bookkeeper!(ele::Ele, group::Type{TrackingGroup}, ...) -# Low level LengthGroup bookkeeping. +# elegroup_bookkeeper!(ele::Ele, group::Type{TrackingParams}, ...) +# Low level LengthParams bookkeeping. -function elegroup_bookkeeper!(ele::Ele, group::Type{TrackingGroup}, changed::ChangedLedger, previous_ele::Ele) - tg = ele.TrackingGroup +function elegroup_bookkeeper!(ele::Ele, group::Type{TrackingParams}, changed::ChangedLedger, previous_ele::Ele) + tg = ele.TrackingParams cdict = ele.changed if haskey(cdict, :num_steps) @@ -785,16 +785,16 @@ end # has_changed """ - has_changed(ele::Ele, group::Type{T}) where T <: EleParameterGroup -> Bool + has_changed(ele::Ele, group::Type{T}) where T <: EleParameterParams -> Bool Has any parameter in `group` changed since the last bookkeeping? """ -function has_changed(ele::Ele, group::Type{T}) where T <: EleParameterGroup +function has_changed(ele::Ele, group::Type{T}) where T <: EleParameterParams if ele.slave_status == Slave.SUPER lord = ele.super_lords[1] # UnionEle slave handled elsewhere. for param in keys(lord.changed) - if param == AllGroup; return true; end + if param == AllParams; return true; end if param == group; return true; end info = ele_param_info(param, lord, throw_error = false) if isnothing(info); continue; end @@ -803,7 +803,7 @@ function has_changed(ele::Ele, group::Type{T}) where T <: EleParameterGroup end for param in keys(ele.changed) - if param == AllGroup; return true; end + if param == AllParams; return true; end if param == group; return true; end info = ele_param_info(param, ele, throw_error = false) if isnothing(info); continue; end @@ -817,7 +817,7 @@ end # clear_changed! """ - clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParameterGroup + clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParameterParams clear_changed!(ele::Ele) Clear record of any parameter in `ele` as having been changed that is associated with `group`. @@ -828,7 +828,7 @@ information until bookkeeping has finished for all slaves. The appropriate lord/ bookkeeping code will handle this. """ clear_changed! -function clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParameterGroup +function clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParameterParams if !clear_lord && (ele.lord_status == Lord.SUPER || ele.lord_status == Lord.MULTIPASS); return; end @@ -857,7 +857,7 @@ Reinstate values for parameters associated with `group`. This is used to try to back out of changes that cause an error. """ -function reinstate_changed!(ele::Ele, group::Type{T}) where T <: EleParameterGroup +function reinstate_changed!(ele::Ele, group::Type{T}) where T <: EleParameterParams for param in keys(ele.changed) info = ele_param_info(param, ele, throw_error = false) if isnothing(info) || info.parent_group != group; continue; end @@ -911,7 +911,7 @@ function init_multipass_bookkeeper!(lat::Lattice) ele.name = ele.name * "!mp" * string(ix) ele.pdict[:multipass_lord] = lord ele.slave_status = Slave.MULTIPASS - if haskey(ele.pdict, :MasterGroup); ele.field_master = true; end + if haskey(ele.pdict, :MasterParams); ele.field_master = true; end push!(lord.pdict[:slaves], ele) end end diff --git a/src/find.jl b/src/find.jl index 6e17683..1f13210 100644 --- a/src/find.jl +++ b/src/find.jl @@ -326,7 +326,7 @@ same branch. do not affect matching to the elements at the ends of the range. That is, the elements at the range ends do not have to be of type `ele_type`. -Group expressions may be combined using the operators `","` (union), `"~"` (negation) or `"&"` (intersection): +Params expressions may be combined using the operators `","` (union), `"~"` (negation) or `"&"` (intersection): If there are more than two block expressions involved, evaluation is left to right. For example: ``` ", " # Union of and . diff --git a/src/geometry.jl b/src/geometry.jl index cb628b7..a495c5a 100644 --- a/src/geometry.jl +++ b/src/geometry.jl @@ -2,9 +2,9 @@ # propagate_ele_geometry """ - propagate_ele_geometry(geometry::Type{<:EleGeometry}, floor_start::OrientationGroup, - ele::Ele) -> OrientationGroup - propagate_ele_geometry(ele::Ele) -> OrientationGroup + propagate_ele_geometry(geometry::Type{<:EleGeometry}, floor_start::OrientationParams, + ele::Ele) -> OrientationParams + propagate_ele_geometry(ele::Ele) -> OrientationParams 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.OrientationGroup, ele) + return propagate_ele_geometry(ele_geometry(ele), ele.OrientationParams, ele) end -function propagate_ele_geometry(fstart::OrientationGroup, ele::Ele) +function propagate_ele_geometry(fstart::OrientationParams, ele::Ele) return propagate_ele_geometry(ele_geometry(ele), fstart, ele) end -function propagate_ele_geometry(::Type{ZERO_LENGTH}, fstart::OrientationGroup, ele::Ele) +function propagate_ele_geometry(::Type{ZERO_LENGTH}, fstart::OrientationParams, ele::Ele) return fstart end -function propagate_ele_geometry(::Type{STRAIGHT}, fstart::OrientationGroup, ele::Ele) +function propagate_ele_geometry(::Type{STRAIGHT}, fstart::OrientationParams, ele::Ele) r_floor = fstart.r + rot([0.0, 0.0, ele.L], fstart.q) - return OrientationGroup(r_floor, fstart.q) + return OrientationParams(r_floor, fstart.q) end -function propagate_ele_geometry(::Type{CIRCULAR}, fstart::OrientationGroup, ele::Ele) - df = coord_transform(ele.L, ele.BendGroup.g, ele.BendGroup.tilt_ref) +function propagate_ele_geometry(::Type{CIRCULAR}, fstart::OrientationParams, 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::OrientationGroup, ele::Ele) +function propagate_ele_geometry(::Type{PATCH_GEOMETRY}, fstart::OrientationParams, ele::Ele) error("Not yet implemented!") end -function propagate_ele_geometry(::Type{CRYSTAL_GEOMETRY}, fstart::OrientationGroup, ele::Ele) +function propagate_ele_geometry(::Type{CRYSTAL_GEOMETRY}, fstart::OrientationParams, ele::Ele) error("Not yet implemented!") end @@ -50,7 +50,7 @@ end # coord_transform """ - coord_transform(ds::Number, g::Number, tilt_ref::Number = 0) -> OrientationGroup + coord_transform(ds::Number, g::Number, tilt_ref::Number = 0) -> OrientationParams 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,18 +62,18 @@ The transformation is function coord_transform(ds::Number, g::Number, tilt_ref::Number = 0.0) if g == 0 - return OrientationGroup([0.0, 0.0, ds], Quaternion()) + return OrientationParams([0.0, 0.0, ds], Quaternion()) else angle = ds/g - r_vec = [-ds * sinc(angle/(2*pi)) * sin(angle), 0.0, ds * sinc(angle/(2*pi))] + r_vec = [-ds * un_sinc(0.5*angle) * sin(angle), 0.0, ds * un_sinc(0.5*angle)] qa = rotY(-angle) if tilt_ref == 0 - return OrientationGroup(r_vec, qa) + return OrientationParams(r_vec, qa) else qt = rotZ(-tilt_ref) - return OrientationGroup(rot(r_vec, qt), qt * qa * inv(qt)) + return OrientationParams(rot(r_vec, qt), qt * qa * inv(qt)) end end end @@ -82,15 +82,15 @@ end # coord_transform """ - coord_transform(coord0::OrientationGroup, dcoord::OrientationGroup) -> OrientationGroup + coord_transform(coord0::OrientationParams, dcoord::OrientationParams) -> OrientationParams Returns coordinate transformation of `dcoord` applied to `coord0`. -""" coord_transform(coord0::OrientationGroup, dcoord::OrientationGroup) +""" coord_transform(coord0::OrientationParams, dcoord::OrientationParams) -function coord_transform(coord0::OrientationGroup, dcoord::OrientationGroup) +function coord_transform(coord0::OrientationParams, dcoord::OrientationParams) r_coord = coord0.r + rot(dcoord.r, coord0.q) q_coord = coord0.q * dcoord.q - return OrientationGroup(r_coord, q_coord) + return OrientationParams(r_coord, q_coord) end #--------------------------------------------------------------------------------------------------- @@ -116,11 +116,11 @@ end # rot! """ - rot!(coord::OrientationGroup, q::Quaternion) -> OrientationGroup + rot!(coord::OrientationParams, q::Quaternion) -> OrientationParams Rotates coordinate position `coord` by `q`. """ -function rot!(coord::OrientationGroup, q::Quaternion) +function rot!(coord::OrientationParams, q::Quaternion) coord.r = rot(coord.r, q) coord.q = q * coord.q return coord @@ -130,11 +130,11 @@ end # rot """ - rot(coord::OrientationGroup, q::Quaternion) -> OrientationGroup + rot(coord::OrientationParams, q::Quaternion) -> OrientationParams Rotates coordinate position `coord` by `q`. """ -function rot(coord::OrientationGroup, q::Quaternion) - return OrientationGroup(r = rot(coord0.r, q), q = q * coord0.q) +function rot(coord::OrientationParams, q::Quaternion) + return OrientationParams(r = rot(coord0.r, q), q = q * coord0.q) end diff --git a/src/lat_construction.jl b/src/lat_construction.jl index 66e8565..95ee173 100644 --- a/src/lat_construction.jl +++ b/src/lat_construction.jl @@ -157,12 +157,12 @@ function add_beamline_ele_to_branch!(branch::Branch, bele::BeamLineEle, ele.pdict[:ix_ele] = length(branch.ele) ele.pdict[:branch] = branch if info isa LatticeConstructionInfo - ele.pdict[:LengthGroup].orientation = bele.pdict[:orientation] * info.orientation_here + ele.pdict[:LengthParams].orientation = bele.pdict[:orientation] * info.orientation_here ele.pdict[:multipass_id] = copy(info.multipass_id) if length(ele.pdict[:multipass_id]) > 0; push!(ele.pdict[:multipass_id], ele.name * ":" * string(bele.pdict[:ix_beamline])); end else - ele.pdict[:LengthGroup].orientation = +1 + ele.pdict[:LengthParams].orientation = +1 ele.pdict[:multipass_id] = [] end return nothing @@ -267,8 +267,8 @@ function new_tracking_branch!(lat::Lattice, bline::BeamLine) end # Beginning and end elements inherit orientation from neighbor elements. - branch.ele[1].pdict[:LengthGroup].orientation = branch.ele[2].pdict[:LengthGroup].orientation - branch.ele[end].pdict[:LengthGroup].orientation = branch.ele[end-1].pdict[:LengthGroup].orientation + branch.ele[1].pdict[:LengthParams].orientation = branch.ele[2].pdict[:LengthParams].orientation + branch.ele[end].pdict[:LengthParams].orientation = branch.ele[end-1].pdict[:LengthParams].orientation branch.ix_ele_min_changed = 1 branch.ix_ele_max_changed = length(branch.ele) diff --git a/src/manipulation.jl b/src/manipulation.jl index e8023b8..da6727b 100644 --- a/src/manipulation.jl +++ b/src/manipulation.jl @@ -86,14 +86,14 @@ function Base.insert!(branch::Branch, ix_ele::Int, ele::Ele; adjust_orientation if adjust_orientation && branch.type == TrackingBranch && length(branch.ele) > 1 if ix_ele == 1 - ele.pdict[:LengthGroup].orientation = branch.ele[2].orientation + ele.pdict[:LengthParams].orientation = branch.ele[2].orientation else - ele.pdict[:LengthGroup].orientation = branch.ele[ele.ix_ele-1].orientation + ele.pdict[:LengthParams].orientation = branch.ele[ele.ix_ele-1].orientation end end set_branch_min_max_changed!(branch, ix_ele) - ele.pdict[:changed][AllGroup] = true + ele.pdict[:changed][AllParams] = true if typeof(ele) == Fork; fork_bookkeeper(ele); end if !isnothing(branch.lat) && branch.lat.autobookkeeping; bookkeeper!(branch.lat); end return ele @@ -137,14 +137,14 @@ function set!(branch::Branch, ix_ele::Int, ele::Ele; adjust_orientation = true) if adjust_orientation && branch.type == TrackingBranch && length(branch.ele) > 1 if ix_ele == 1 - ele.pdict[:LengthGroup].orientation = branch.ele[2].orientation + ele.pdict[:LengthParams].orientation = branch.ele[2].orientation else - ele.pdict[:LengthGroup].orientation = branch.ele[ele.ix_ele-1].orientation + ele.pdict[:LengthParams].orientation = branch.ele[ele.ix_ele-1].orientation end end set_branch_min_max_changed!(branch, ix_ele) - ele.pdict[:changed][AllGroup] = true + ele.pdict[:changed][AllParams] = true if !isnothing(branch.lat) && branch.lat.autobookkeeping; bookkeeper!(branch.lat); end return ele end @@ -165,7 +165,7 @@ function Base.pop!(branch::Branch, ix_ele::Int) index_and_s_bookkeeper!(branch, ix_ele) set_branch_min_max_changed!(branch, ix_ele) - branch.ele[ix_ele].pdict[:changed][AllGroup] = "changed" + branch.ele[ix_ele].pdict[:changed][AllParams] = "changed" if !isnothing(branch.lat) && branch.lat.autobookkeeping; bookkeeper!(branch.lat); end return nothing end @@ -193,7 +193,7 @@ function Base.push!(branch::Branch, ele::Ele; adjust_orientation = true) index_and_s_bookkeeper!(branch, ix_ele) if adjust_orientation && branch.type == TrackingBranch && ix_ele > 1 - ele.pdict[:LengthGroup].orientation = branch.ele[ele.ix_ele-1].orientation + ele.pdict[:LengthParams].orientation = branch.ele[ele.ix_ele-1].orientation end return ele @@ -332,8 +332,8 @@ function split!(branch::Branch, s_split::Real; select::Select.T = Select.UPSTREA slave2 = insert!(branch, slave1.ix_ele+1, slave1) # Just after slave1 slave1.L = s_split - slave1.s slave2.L = slave1.s_downstream - s_split - slave1.pdict[:changed][AllGroup] = true - slave2.pdict[:changed][AllGroup] = true + slave1.pdict[:changed][AllParams] = true + slave2.pdict[:changed][AllParams] = true # Now update the slave lists for the super lords to include the new slave. # Notice that the lord list of the slaves does not have to be modified. @@ -366,14 +366,14 @@ function split!(branch::Branch, s_split::Real; select::Select.T = Select.UPSTREA slave2 = insert!(branch, slave1.ix_ele+1, slave1) slave1.L = s_split - lord.s slave2.L = lord.s_downstream - s_split - slave1.pdict[:changed][AllGroup] = true - slave2.pdict[:changed][AllGroup] = true + slave1.pdict[:changed][AllParams] = true + slave2.pdict[:changed][AllParams] = true sbranch = branch.lat[SuperBranch] push!(sbranch.ele, lord) lord.pdict[:slaves] = Vector{Ele}([slave1, slave2]) lord.lord_status = Lord.SUPER - lord.pdict[:changed][AllGroup] = true + lord.pdict[:changed][AllParams] = true index_and_s_bookkeeper!(branch) index_and_s_bookkeeper!(sbranch) diff --git a/src/output_lat.jl b/src/output_lat.jl index 6283a39..a1f3c3f 100644 --- a/src/output_lat.jl +++ b/src/output_lat.jl @@ -13,6 +13,6 @@ end function Base.write(io::IO, ele::Ele) end -function Base.write(io::IO, group::EleParameterGroup) +function Base.write(io::IO, group::EleParameterParams) end diff --git a/src/parameters.jl b/src/parameters.jl index f69a179..08e7846 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -74,7 +74,7 @@ ParamInfo(parent, kind, description, units::String = "", output_group = nothing, Dictionary mapping element parameters to `ParamInfo` structs which hold information on the parameters. For example, `ELE_PARAM_INFO_DICT[:species_ref]` shows that the `species_ref` parameter is associated -with the `ReferenceGroup`, etc. See the documentation on `ParamInfo` for more details. +with the `ReferenceParams`, etc. See the documentation on `ParamInfo` for more details. """ ELE_PARAM_INFO_DICT ELE_PARAM_INFO_DICT = Dict( @@ -86,124 +86,124 @@ ELE_PARAM_INFO_DICT = Dict( :slaves => ParamInfo(Nothing, Vector{Ele}, "Array of slaves of element. Will not be present if no slaves exist."), :girder => ParamInfo(Nothing, Ele, "Supporting Girder element. Will not be present if no supporting girder."), - :amp_function => ParamInfo(ACKickerGroup, Function, "Amplitude function."), + :amp_function => ParamInfo(ACKickerParams, Function, "Amplitude function."), - :offset => ParamInfo(BodyShiftGroup, Vector{Number}, "[x, y, z] offset of element or, for a patch, exit coordinates.", "m"), - :x_rot => ParamInfo(BodyShiftGroup, Number, "X-axis rotation of element or, for a patch, exit coordinates.", "rad"), - :y_rot => ParamInfo(BodyShiftGroup, Number, "Y-axis rotation of element or, for a patch, exit coordinates.", "rad"), - :z_rot => ParamInfo(BodyShiftGroup, Number, "Z-axis rotation of element or, for a patch, exit coordinates.", "rad"), + :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"), - :q_shift => ParamInfo(BodyShiftGroup, Quaternion, "Quaternion orientation.", "", OutputGroup), - :q_shift_tot => ParamInfo(BodyShiftGroup, Quaternion, "Quaternion orientation including Girder orientation.", "", OutputGroup), - :offset_tot => ParamInfo(BodyShiftGroup, Vector{Number}, "[x, y, z] element offset including Girder orientation.", "m", OutputGroup), - :x_rot_tot => ParamInfo(BodyShiftGroup, Number, "X-axis element rotation including Girder orientation.", "rad", OutputGroup), - :y_rot_tot => ParamInfo(BodyShiftGroup, Number, "Y-axis element rotation including Girder orientation.", "rad", OutputGroup), - :z_rot_tot => ParamInfo(BodyShiftGroup, Number, "Z-axis element rotation including Girder orientation.", "rad", OutputGroup), + :q_shift => ParamInfo(BodyShiftParams, Quaternion, "Quaternion orientation.", "", OutputParams), + :q_shift_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), - :aperture_shape => ParamInfo(ApertureGroup, ApertureShape, "Aperture shape. Default is ELLIPTICAL."), - :aperture_at => ParamInfo(ApertureGroup, BodyLoc.T, "Aperture location. Default is BodyLoc.ENTRANCE_END."), + :aperture_shape => ParamInfo(ApertureParams, ApertureShape, "Aperture shape. Default is ELLIPTICAL."), + :aperture_at => ParamInfo(ApertureParams, BodyLoc.T, "Aperture location. Default is BodyLoc.ENTRANCE_END."), :aperture_shifts_with_body - => ParamInfo(ApertureGroup, Bool, "Do element alignment shifts move the aperture?"), - :x_limit => ParamInfo(ApertureGroup, Vector{Number}, "Min/Max horizontal aperture limits.", "m"), - :y_limit => ParamInfo(ApertureGroup, Vector{Number}, "Min/Max vertical aperture limits.", "m"), - :wall => ParamInfo(ApertureGroup, Wall2D, "Wall defined by array of aperture vertices."), - :custom_aperture => ParamInfo(ApertureGroup, Dict, "Custom aperture info."), - - :angle => ParamInfo(BendGroup, Number, "Reference bend angle", "rad"), - :bend_field_ref => ParamInfo(BendGroup, Number, "Reference bend field corresponding to g bending strength", "T"), - :g => ParamInfo(BendGroup, Number, "Reference bend strength (1/rho)", "1/m"), - :e1 => ParamInfo(BendGroup, Number, "Bend entrance face angle.", "rad"), - :e2 => ParamInfo(BendGroup, Number, "Bend exit face angle.", "rad"), - :e1_rect => ParamInfo(BendGroup, Number, "Bend entrance face angles relative to a rectangular geometry.", "rad"), - :e2_rect => ParamInfo(BendGroup, Number, "Bend exit face angles relative to a rectangular geometry.", "rad"), - :L_chord => ParamInfo(BendGroup, Number, "Bend chord length.", "m"), - :tilt_ref => ParamInfo(BendGroup, Number, "Bend reference orbit rotation around the upstream z-axis", "rad"), - :edge_int1 => ParamInfo(BendGroup, Number, "Bend entrance edge field integral.", "m"), - :edge_int2 => ParamInfo(BendGroup, Number, "Bend exit edge field integral.", "m"), - :bend_type => ParamInfo(BendGroup, BendType.T, "Sets the \"logical\" shape of a bend."), - :exact_multipoles => ParamInfo(BendGroup, ExactMultipoles.T, "Are multipoles treated exactly?"), - - :rho => ParamInfo(BendGroup, Number, "Reference bend radius", "m", OutputGroup), - :L_sagitta => ParamInfo(BendGroup, Number, "Bend sagitta length.", "m", OutputGroup), - :norm_bend_field => ParamInfo(BendGroup, Number, "Actual bend strength in the plane of the bend", "1/m", OutputGroup), - :bend_field => ParamInfo(BendGroup, Number, "Actual bend field in the plane of the bend field", "T", OutputGroup), - - :species_ref_downstream => ParamInfo(DownstreamReferenceGroup, Species, "Reference species at downstream end."), - :pc_ref_downstream => ParamInfo(DownstreamReferenceGroup, Number, "Reference momentum * c at downstream end.", "eV"), - :E_tot_ref_downstream => ParamInfo(DownstreamReferenceGroup, Number, "Reference total energy at downstream end.", "eV"), - - :β_ref_downstream => ParamInfo(DownstreamReferenceGroup, Number, "Reference velocity/c at downstream end.", "", OutputGroup), - :γ_ref_downstream => ParamInfo(DownstreamReferenceGroup, Number, "Reference relativistic gamma factor at downstream end.", "", OutputGroup), - - :to_line => ParamInfo(ForkGroup, Union{BeamLine, Nothing}, "Beamline forked to."), - :to_ele => ParamInfo(ForkGroup, Union{String,Ele}, "Lattice element forked to."), - :direction => ParamInfo(ForkGroup, Int, "Direction (forwards or backwards) of injection."), - - :supported => ParamInfo(GirderGroup, Vector{Ele}, "Array of elements supported by a Girder."), - - :L => ParamInfo(LengthGroup, Number, "Element length.", "m"), - :orientation => ParamInfo(LengthGroup, Int, "Longitudinal orientation of element. May be +1 or -1."), - :s => ParamInfo(LengthGroup, Number, "Longitudinal s-position at the upstream end.", "m"), - :s_downstream => ParamInfo(LengthGroup, Number, "Longitudinal s-position at the downstream end.", "m"), - - :slave_status => ParamInfo(LordSlaveStatusGroup, Slave.T, "Slave status."), - :lord_status => ParamInfo(LordSlaveStatusGroup, Lord.T, "Lord status."), - - :is_on => ParamInfo(MasterGroup, Bool, "Element fields on/off."), - :field_master => ParamInfo(MasterGroup, Bool, "True: fields are fixed and normalized values change when varying ref energy."), - - :r_floor => ParamInfo(OrientationGroup, Vector{Number}, "3-vector of element floor position.", "m", nothing, :r), - :q_floor => ParamInfo(OrientationGroup, Quaternion, "Element quaternion orientation.", "", nothing, :q), - - :origin_ele => ParamInfo(OriginEleGroup, Ele, "Coordinate reference element."), - :origin_ele_ref_pt => ParamInfo(OriginEleGroup, Loc.T, "Reference location on reference element. Default is Loc.CENTER."), - - :E_tot_offset => ParamInfo(PatchGroup, Number, "Reference energy offset.", "eV"), - :E_tot_exit => ParamInfo(PatchGroup, Number, "Reference energy at exit end.", "eV"), - :pc_exit => ParamInfo(PatchGroup, Number, "Reference momentum at exit end.", "eV"), - :L_user => ParamInfo(PatchGroup, Number, "User set length.", "m"), - :flexible => ParamInfo(PatchGroup, Bool, "Flexible patch?"), - :ref_coords => ParamInfo(PatchGroup, BodyLoc.T, "Patch coords with respect to BodyLoc.ENTRANCE_END or BodyLoc.EXIT_END?"), - - :species_ref => ParamInfo(ReferenceGroup, Species, "Reference species."), - :pc_ref => ParamInfo(ReferenceGroup, Number, "Reference momentum * c.", "eV"), - :E_tot_ref => ParamInfo(ReferenceGroup, Number, "Reference total energy.", "eV"), - :time_ref => ParamInfo(ReferenceGroup, Number, "Reference time.", "sec"), - :extra_dtime_ref => ParamInfo(ReferenceGroup, Number, "Additional reference time change.", "sec"), - :time_ref_downstream => ParamInfo(ReferenceGroup, Number, "Reference time at downstream end.", "sec"), - :dE_ref => ParamInfo(ReferenceGroup, Number, "Change in reference energy.", "volt"), - - :β_ref => ParamInfo(ReferenceGroup, Number, "Reference velocity/c.", "", OutputGroup), - :γ_ref => ParamInfo(ReferenceGroup, Number, "Reference relativistic gamma factor.", "", OutputGroup), - - :voltage => ParamInfo(RFGroup, Number, "RF voltage.", "volt"), - :gradient => ParamInfo(RFGroup, Number, "RF gradient.", "volt/m"), - :phase => ParamInfo(RFGroup, Number, "RF phase.", "rad"), - :multipass_phase => ParamInfo(RFGroup, Number, + => ParamInfo(ApertureParams, Bool, "Do element alignment shifts move the aperture?"), + :x_limit => ParamInfo(ApertureParams, Vector{Number}, "Min/Max horizontal aperture limits.", "m"), + :y_limit => ParamInfo(ApertureParams, Vector{Number}, "Min/Max vertical aperture limits.", "m"), + :wall => ParamInfo(ApertureParams, Wall2D, "Wall defined by array of aperture vertices."), + :custom_aperture => ParamInfo(ApertureParams, Dict, "Custom aperture info."), + + :angle => ParamInfo(BendParams, Number, "Reference bend angle", "rad"), + :bend_field_ref => ParamInfo(BendParams, Number, "Reference bend field corresponding to g bending strength", "T"), + :g => ParamInfo(BendParams, Number, "Reference bend strength (1/rho)", "1/m"), + :e1 => ParamInfo(BendParams, Number, "Bend entrance face angle.", "rad"), + :e2 => ParamInfo(BendParams, Number, "Bend exit face angle.", "rad"), + :e1_rect => ParamInfo(BendParams, Number, "Bend entrance face angles relative to a rectangular geometry.", "rad"), + :e2_rect => ParamInfo(BendParams, Number, "Bend exit face angles relative to a rectangular geometry.", "rad"), + :L_chord => ParamInfo(BendParams, Number, "Bend chord length.", "m"), + :tilt_ref => ParamInfo(BendParams, Number, "Bend reference orbit rotation around the upstream z-axis", "rad"), + :edge_int1 => ParamInfo(BendParams, Number, "Bend entrance edge field integral.", "m"), + :edge_int2 => ParamInfo(BendParams, Number, "Bend exit edge field integral.", "m"), + :bend_type => ParamInfo(BendParams, BendType.T, "Sets the \"logical\" shape of a bend."), + :exact_multipoles => ParamInfo(BendParams, ExactMultipoles.T, "Are multipoles treated exactly?"), + + :rho => ParamInfo(BendParams, Number, "Reference bend radius", "m", OutputParams), + :L_sagitta => ParamInfo(BendParams, Number, "Bend sagitta length.", "m", OutputParams), + :norm_bend_field => ParamInfo(BendParams, Number, "Actual bend strength in the plane of the bend", "1/m", OutputParams), + :bend_field => ParamInfo(BendParams, Number, "Actual bend field in the plane of the bend field", "T", OutputParams), + + :species_ref_downstream => ParamInfo(DownstreamReferenceParams, Species, "Reference species at downstream end."), + :pc_ref_downstream => ParamInfo(DownstreamReferenceParams, Number, "Reference momentum * c at downstream end.", "eV"), + :E_tot_ref_downstream => ParamInfo(DownstreamReferenceParams, Number, "Reference total energy at downstream end.", "eV"), + + :β_ref_downstream => ParamInfo(DownstreamReferenceParams, Number, "Reference velocity/c at downstream end.", "", OutputParams), + :γ_ref_downstream => ParamInfo(DownstreamReferenceParams, Number, "Reference relativistic gamma factor at downstream end.", "", OutputParams), + + :to_line => ParamInfo(ForkParams, Union{BeamLine, Nothing}, "Beamline forked to."), + :to_ele => ParamInfo(ForkParams, Union{String,Ele}, "Lattice element forked to."), + :direction => ParamInfo(ForkParams, Int, "Direction (forwards or backwards) of injection."), + + :supported => ParamInfo(GirderParams, Vector{Ele}, "Array of elements supported by a Girder."), + + :L => ParamInfo(LengthParams, Number, "Element length.", "m"), + :orientation => ParamInfo(LengthParams, Int, "Longitudinal orientation of element. May be +1 or -1."), + :s => ParamInfo(LengthParams, Number, "Longitudinal s-position at the upstream end.", "m"), + :s_downstream => ParamInfo(LengthParams, Number, "Longitudinal s-position at the downstream end.", "m"), + + :slave_status => ParamInfo(LordSlaveStatusParams, Slave.T, "Slave status."), + :lord_status => ParamInfo(LordSlaveStatusParams, Lord.T, "Lord status."), + + :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), + + :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."), + + :E_tot_offset => ParamInfo(PatchParams, Number, "Reference energy offset.", "eV"), + :E_tot_exit => ParamInfo(PatchParams, Number, "Reference energy at exit end.", "eV"), + :pc_exit => ParamInfo(PatchParams, Number, "Reference momentum at exit end.", "eV"), + :L_user => ParamInfo(PatchParams, Number, "User set length.", "m"), + :flexible => ParamInfo(PatchParams, Bool, "Flexible patch?"), + :ref_coords => ParamInfo(PatchParams, BodyLoc.T, "Patch coords with respect to BodyLoc.ENTRANCE_END or BodyLoc.EXIT_END?"), + + :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"), + :time_ref => ParamInfo(ReferenceParams, Number, "Reference time.", "sec"), + :extra_dtime_ref => ParamInfo(ReferenceParams, Number, "Additional reference time change.", "sec"), + :time_ref_downstream => ParamInfo(ReferenceParams, Number, "Reference time at downstream end.", "sec"), + :dE_ref => ParamInfo(ReferenceParams, Number, "Change in reference energy.", "volt"), + + :β_ref => ParamInfo(ReferenceParams, Number, "Reference velocity/c.", "", OutputParams), + :γ_ref => ParamInfo(ReferenceParams, Number, "Reference relativistic gamma factor.", "", OutputParams), + + :voltage => ParamInfo(RFParams, Number, "RF voltage.", "volt"), + :gradient => ParamInfo(RFParams, Number, "RF gradient.", "volt/m"), + :phase => ParamInfo(RFParams, Number, "RF phase.", "rad"), + :multipass_phase => ParamInfo(RFParams, Number, "RF phase added to element and not controlled by multipass lord.", "rad"), - :frequency => ParamInfo(RFGroup, Number, "RF frequency.", "Hz"), - :harmon => ParamInfo(RFGroup, Number, "RF frequency harmonic number.", ""), - :cavity_type => ParamInfo(RFGroup, Cavity.T, "Type of cavity."), - :n_cell => ParamInfo(RFGroup, Int, "Number of RF cells."), + :frequency => ParamInfo(RFParams, Number, "RF frequency.", "Hz"), + :harmon => ParamInfo(RFParams, Number, "RF frequency harmonic number.", ""), + :cavity_type => ParamInfo(RFParams, Cavity.T, "Type of cavity."), + :n_cell => ParamInfo(RFParams, Int, "Number of RF cells."), - :auto_amp => ParamInfo(RFAutoGroup, Number, + :auto_amp => ParamInfo(RFAutoParams, Number, "Correction to the voltage/gradient calculated by the auto scale code.", ""), - :auto_phase => ParamInfo(RFAutoGroup, Number, "Correction RF phase calculated by the auto scale code.", "rad"), - :do_auto_amp => ParamInfo(RFAutoGroup, Bool, "Autoscale voltage/gradient?"), - :do_auto_phase => ParamInfo(RFAutoGroup, Bool, "Autoscale phase?"), + :auto_phase => ParamInfo(RFAutoParams, Number, "Correction RF phase calculated by the auto scale code.", "rad"), + :do_auto_amp => ParamInfo(RFAutoParams, Bool, "Autoscale voltage/gradient?"), + :do_auto_phase => ParamInfo(RFAutoParams, Bool, "Autoscale phase?"), - :num_steps => ParamInfo(TrackingGroup, Int, "Nominal number of tracking steps."), - :ds_step => ParamInfo(TrackingGroup, Number, "Nominal distance between tracking steps.", "m"), + :num_steps => ParamInfo(TrackingParams, Int, "Nominal number of tracking steps."), + :ds_step => ParamInfo(TrackingParams, Number, "Nominal distance between tracking steps.", "m"), - :Ksol => ParamInfo(SolenoidGroup, Number, "Solenoid strength.", "1/m"), - :Bsol => ParamInfo(SolenoidGroup, Number, "Solenoid field.", "T"), + :Ksol => ParamInfo(SolenoidParams, Number, "Solenoid strength.", "1/m"), + :Bsol => ParamInfo(SolenoidParams, Number, "Solenoid field.", "T"), - :spin => ParamInfo(InitParticleGroup, Vector{Number}, "Initial particle spin"), - :orbit => ParamInfo(InitParticleGroup, Vector{Number}, "Initial particle position."), + :spin => ParamInfo(InitParticleParams, Vector{Number}, "Initial particle spin"), + :orbit => ParamInfo(InitParticleParams, Vector{Number}, "Initial particle position."), - :type => ParamInfo(DescriptionGroup, String, "Type of element."), - :ID => ParamInfo(DescriptionGroup, String, "Identification name."), - :class => ParamInfo(DescriptionGroup, String, "Classification of element."), + :type => ParamInfo(DescriptionParams, String, "Type of element."), + :ID => ParamInfo(DescriptionParams, String, "Identification name."), + :class => ParamInfo(DescriptionParams, String, "Classification of element."), :beta => ParamInfo(Twiss1, Number, "Beta Twiss parameter.", "m"), :alpha => ParamInfo(Twiss1, Number, "Alpha Twiss parameter.", ""), @@ -213,23 +213,23 @@ ELE_PARAM_INFO_DICT = Dict( :etap => ParamInfo(Twiss1, Number, "Momentum dispersion.", ""), :deta_ds => ParamInfo(Twiss1, Number, "Dispersion derivative.", ""), - :beta_a => ParamInfo(TwissGroup, Number, "A-mode beta Twiss parameter.", "m", nothing, :beta, :a), - :alpha_a => ParamInfo(TwissGroup, Number, "A-mode alpha Twiss parameter.", "", nothing, :alpha, :a), - :gamma_a => ParamInfo(TwissGroup, Number, "A-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :a), - :phi_a => ParamInfo(TwissGroup, Number, "A-mode betatron phase.", "rad", nothing, :phi, :a), + :beta_a => ParamInfo(TwissParams, Number, "A-mode beta Twiss parameter.", "m", nothing, :beta, :a), + :alpha_a => ParamInfo(TwissParams, Number, "A-mode alpha Twiss parameter.", "", nothing, :alpha, :a), + :gamma_a => ParamInfo(TwissParams, Number, "A-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :a), + :phi_a => ParamInfo(TwissParams, Number, "A-mode betatron phase.", "rad", nothing, :phi, :a), - :beta_b => ParamInfo(TwissGroup, Number, "B-mode beta Twiss parameter.", "m", nothing, :beta, :b), - :alpha_b => ParamInfo(TwissGroup, Number, "B-mode alpha Twiss parameter.", "", nothing, :alpha, :b), - :gamma_b => ParamInfo(TwissGroup, Number, "B-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :b), - :phi_b => ParamInfo(TwissGroup, Number, "B-mode betatron phase.", "rad", nothing, :phi, :b), + :beta_b => ParamInfo(TwissParams, Number, "B-mode beta Twiss parameter.", "m", nothing, :beta, :b), + :alpha_b => ParamInfo(TwissParams, Number, "B-mode alpha Twiss parameter.", "", nothing, :alpha, :b), + :gamma_b => ParamInfo(TwissParams, Number, "B-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :b), + :phi_b => ParamInfo(TwissParams, Number, "B-mode betatron phase.", "rad", nothing, :phi, :b), - :eta_x => ParamInfo(TwissGroup, Number, "X-mode position dispersion.", "m", nothing, :eta, :x), - :etap_x => ParamInfo(TwissGroup, Number, "X-mode momentum dispersion.", "", nothing, :etap, :x), - :deta_ds_x => ParamInfo(TwissGroup, Number, "X-mode dispersion derivative.", "", nothing, :deta_ds, :x), + :eta_x => ParamInfo(TwissParams, Number, "X-mode position dispersion.", "m", nothing, :eta, :x), + :etap_x => ParamInfo(TwissParams, Number, "X-mode momentum dispersion.", "", nothing, :etap, :x), + :deta_ds_x => ParamInfo(TwissParams, Number, "X-mode dispersion derivative.", "", nothing, :deta_ds, :x), - :eta_y => ParamInfo(TwissGroup, Number, "Y-mode position dispersion.", "m", nothing, :eta, :y), - :etap_y => ParamInfo(TwissGroup, Number, "Y-mode momentum dispersion.", "", nothing, :etap, :y), - :deta_ds_y => ParamInfo(TwissGroup, Number, "Y-mode dispersion derivative.", "", nothing, :deta_ds, :y), + :eta_y => ParamInfo(TwissParams, Number, "Y-mode position dispersion.", "m", nothing, :eta, :y), + :etap_y => ParamInfo(TwissParams, Number, "Y-mode momentum dispersion.", "", nothing, :etap, :y), + :deta_ds_y => ParamInfo(TwissParams, Number, "Y-mode dispersion derivative.", "", nothing, :deta_ds, :y), ) for (key, info) in ELE_PARAM_INFO_DICT @@ -247,10 +247,10 @@ 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 `OrientationGroup`, `r_floor` will be in the name list instead of `r`. +For example, for a `OrientationParams`, `r_floor` will be in the name list instead of `r`. """ associated_names -function associated_names(group::Type{T}) where T <: EleParameterGroup +function associated_names(group::Type{T}) where T <: EleParameterParams names = [field for field in fieldnames(group)] for (key, pinfo) in ELE_PARAM_INFO_DICT if pinfo.parent_group != group; continue; end @@ -268,7 +268,7 @@ DEPENDENT_ELE_PARAMETERS::Vector{Symbol} = #--------------------------------------------------------------------------------------------------- # has_parent_group -function has_parent_group(pinfo::ParamInfo, group::Type{T}) where T <: BaseEleParameterGroup +function has_parent_group(pinfo::ParamInfo, group::Type{T}) where T <: BaseEleParameterParams if typeof(pinfo.parent_group) <: Vector return group in pinfo.parent_group else @@ -291,10 +291,10 @@ This mapping only covers stuff in `ELE_PARAM_INFO_DICT` so this mapping does not Example: `ele_param_struct_field_to_user_sym[:beta] => [:beta_b, :beta, :beta_a, :beta_c]` The mappings from user name to field for this example are: \\ -• `beta_a` - maps to `a.beta` in a TwissGroup \\ -• `beta_b` - maps to `b.beta` in a TwissGroup \\ -• `beta_c` - maps to `c.beta` in a TwissGroup \\ -• `beta` - maps to `beta` in a Twiss1Group \\ +• `beta_a` - maps to `a.beta` in a TwissParams \\ +• `beta_b` - maps to `b.beta` in a TwissParams \\ +• `beta_c` - maps to `c.beta` in a TwissParams \\ +• `beta` - maps to `beta` in a Twiss1Params \\ """ ele_param_struct_field_to_user_sym ele_param_struct_field_to_user_sym = Dict{Symbol,Vector{Symbol}}() @@ -315,7 +315,7 @@ end units(param::Union{Symbol,DataType}, eletype::Type{T}) where T <: Ele -> units::String Returns the units associated with symbol. EG: `m` (meters) for `param` = `:L`. -`param` may be an element parameter group type (EG: `LengthGroup`) in which +`param` may be an element parameter group type (EG: `LengthParams`) in which case `units` returns a blank string. """ units @@ -360,7 +360,7 @@ end """ function multipole_type(sym::Symbol) -> (type::String, order::Int, group_type::Type{T}) function multipole_type(str::AbstractString}) -> (type::String, order::Int, group_type::Type{T}) - where T <: Union{BMultipoleGroup,EMultipoleGroup,Nothing} + where T <: Union{BMultipoleParams,EMultipoleParams,Nothing} If `str` is a multipole parameter name like `Kn2L` or `Etilt`, `order` will be the multipole order and `type` will be one of: @@ -376,22 +376,22 @@ function multipole_type(str::AbstractString) if length(str) > 4 && str[1:4] == "tilt" order = tryparse(Int, str[5:end]) - isnothing(order) || order < 0 ? (return isbad) : return ("tilt", order, BMultipoleGroup) + isnothing(order) || order < 0 ? (return isbad) : return ("tilt", order, BMultipoleParams) elseif length(str) > 5 && str[1:5] == "Etilt" order = tryparse(Int, str[6:end]) - isnothing(order) || order < 0 ? (return isbad) : return ("Etilt", order, EMultipoleGroup) + isnothing(order) || order < 0 ? (return isbad) : return ("Etilt", order, EMultipoleParams) elseif length(str) > 10 && str[1:10] == "integrated" order = tryparse(Int, str[11:end]) - isnothing(order) || order < 0 ? (return isbad) : return ("integrated", order, BMultipoleGroup) + isnothing(order) || order < 0 ? (return isbad) : return ("integrated", order, BMultipoleParams) elseif length(str) > 11 && str[1:11] == "Eintegrated" order = tryparse(Int, str[12:end]) - isnothing(order) || order < 0 ? (return isbad) : return ("Eintegrated", order, EMultipoleGroup) + isnothing(order) || order < 0 ? (return isbad) : return ("Eintegrated", order, EMultipoleParams) end if str[1:2] in Set(["Kn", "Ks", "Bn", "Bs"]) - group_type = BMultipoleGroup + group_type = BMultipoleParams elseif str[1:2] in Set(["En", "Es"]) - group_type = EMultipoleGroup + group_type = EMultipoleParams else return isbad end @@ -429,13 +429,13 @@ function multipole_param_info(sym::Symbol) if group == Nothing; return nothing; end if mtype == "tilt" - return ParamInfo(BMultipoleGroup, Number, "Magnetic multipole tilt for order $order", "rad", nothing, :tilt, nothing, sym) + return ParamInfo(BMultipoleParams, Number, "Magnetic multipole tilt for order $order", "rad", nothing, :tilt, nothing, sym) elseif mtype == "Etilt" - return ParamInfo(EMultipoleGroup, Number, "Electric multipole tilt for order $order", "rad", nothing, :Etilt, nothing, sym) + return ParamInfo(EMultipoleParams, Number, "Electric multipole tilt for order $order", "rad", nothing, :Etilt, nothing, sym) elseif mtype == "integrated" - return ParamInfo(BMultipoleGroup, Bool, "Are stored multipoles integrated for order $order?", "", nothing, :integrated, nothing, sym) + return ParamInfo(BMultipoleParams, Bool, "Are stored multipoles integrated for order $order?", "", nothing, :integrated, nothing, sym) elseif mtype == "Eintegrated" - return ParamInfo(EMultipoleGroup, Bool, "Are stored multipoles integrated for order $order?", "", nothing, :Eintegrated, nothing, sym) + return ParamInfo(EMultipoleParams, Bool, "Are stored multipoles integrated for order $order?", "", nothing, :Eintegrated, nothing, sym) end mtype[2] == 's' ? str = "Skew" : str = "Normal (non-skew)" @@ -453,7 +453,7 @@ function multipole_param_info(sym::Symbol) else; units = "1/m^$(exp+1)" end - return ParamInfo(BMultipoleGroup, Number, "$str, momentum-normalized, magnetic multipole of order $order.", units, nothing, insym, nothing, sym) + return ParamInfo(BMultipoleParams, Number, "$str, momentum-normalized, magnetic multipole of order $order.", units, nothing, insym, nothing, sym) elseif mtype[1] == 'B' if order == -1; units = "T*m" @@ -461,14 +461,14 @@ function multipole_param_info(sym::Symbol) else; units = "T/m^$exp" end - return ParamInfo(BMultipoleGroup, Number, "$str, magnetic field multipole of order $order.", units, nothing, insym, nothing, sym) + return ParamInfo(BMultipoleParams, Number, "$str, magnetic field multipole of order $order.", units, nothing, insym, nothing, sym) elseif mtype[1] == 'E' if order == -1; units = "V" else; units = "V/m^$(exp+1)" end - return ParamInfo(EMultipoleGroup, Number, "$str, electric field multipole of order $order.", units, nothing, insym, nothing, sym) + return ParamInfo(EMultipoleParams, Number, "$str, electric field multipole of order $order.", units, nothing, insym, nothing, sym) end end @@ -547,7 +547,7 @@ If there are no multipoles corresponding to `order`, nothing is done. """ toggle_integrated! function toggle_integrated!(ele::Ele, ftype::Type{MAGNETIC}, order::Int) - mul = multipole!(BMultipoleGroup, order) + mul = multipole!(BMultipoleParams, order) if isnothing(mul); return; end L = ele.L want_integrated = !mul.integrated @@ -571,7 +571,7 @@ function toggle_integrated!(ele::Ele, ftype::Type{MAGNETIC}, order::Int) end function toggle_integrated!(ele::Ele, ftype::Type{ELECTRIC}, order::Int) - mul = multipole!(EMultipoleGroup, order) + mul = multipole!(EMultipoleParams, order) if isnothing(mul); return; end L = ele.L want_integrated = !mul.integrated @@ -598,12 +598,23 @@ end Table of what element groups are associated with what element types. Order is important. Bookkeeping routines rely on: - - `LengthGroup` being first (except for a `Bend` where BendGroup is `first`). - - `BendGroup` after `ReferenceGroup` and `MasterGroup` (in case the reference energy is changing). - - `BMultipoleGroup` and `EMultipoleGroup` after `MasterGroup` (in case the reference energy is changing). - - `RFCommonGroup` comes last (triggers autoscale/autophase and `ReferenceGroup` correction). + - `LengthParams` being first (except for a `Bend` where BendParams is `first`). + - `BendParams` after `ReferenceParams` and `MasterParams` (in case the reference energy is changing). + - `BMultipoleParams` and `EMultipoleParams` after `MasterParams` (in case the reference energy is changing). + - `RFCommonParams` comes last (triggers autoscale/autophase and `ReferenceParams` correction). """ PARAM_GROUPS_LIST +base_group_list = [LengthParams, LordSlaveStatusParams, DescriptionParams, ReferenceParams, + DownstreamReferenceParams, OrientationParams, TrackingParams, BodyShiftParams, ApertureParams] +multipole_group_list = [MasterParams, BMultipoleParams, EMultipoleParams] +general_group_list = [base_group_list..., multipole_group_list...] + +PARAM_GROUPS_LIST = Dict( + ACKicker => [general_group_list..., ACKickerParams], + BeamBeam => [base_group_list..., BeamBeamParams], + BeginningEle => [base_group_list..., TwissParams, InitParticleParams], + Bend => [BendParams, general_group_list...], + base_group_list = [LengthGroup, LordSlaveStatusGroup, DescriptionGroup, ReferenceGroup, DownstreamReferenceGroup, OrientationGroup, TrackingGroup, BodyShiftGroup, ApertureGroup] multipole_group_list = [MasterGroup, BMultipoleGroup, EMultipoleGroup] @@ -619,24 +630,24 @@ PARAM_GROUPS_LIST = Dict( CrabCavity => [base_group_list...], Drift => [base_group_list...], EGun => [general_group_list...], - Fiducial => [DescriptionGroup, OrientationGroup, BodyShiftGroup, OriginEleGroup], - FloorShift => [DescriptionGroup, OrientationGroup, BodyShiftGroup, OriginEleGroup], + Fiducial => [DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams], + FloorShift => [DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams], Foil => [base_group_list...], - Fork => [base_group_list..., ForkGroup], - Girder => [LengthGroup, DescriptionGroup, OrientationGroup, BodyShiftGroup, OriginEleGroup, GirderGroup], + Fork => [base_group_list..., ForkParams], + Girder => [LengthParams, DescriptionParams, OrientationParams, BodyShiftParams, OriginEleParams, GirderParams], Instrument => [base_group_list...], Kicker => [general_group_list...], - LCavity => [base_group_list..., MasterGroup, RFAutoGroup, RFGroup], + LCavity => [base_group_list..., MasterParams, RFAutoParams, RFParams], Marker => [base_group_list...], Match => [base_group_list...], Multipole => [general_group_list...], NullEle => [], Octupole => [general_group_list...], - Patch => [base_group_list..., PatchGroup], + Patch => [base_group_list..., PatchParams], Quadrupole => [general_group_list...], - RFCavity => [base_group_list..., MasterGroup, RFAutoGroup, RFGroup], + RFCavity => [base_group_list..., MasterParams, RFAutoParams, RFParams], Sextupole => [general_group_list...], - Solenoid => [general_group_list..., SolenoidGroup], + Solenoid => [general_group_list..., SolenoidParams], Taylor => [base_group_list...], Undulator => [base_group_list...], UnionEle => [base_group_list...], @@ -650,32 +661,32 @@ end ELE_PARAM_GROUP_INFO = Dict( - ACKickerGroup => EleParameterGroupInfo("ACKicker element parameters.", false), - BodyShiftGroup => EleParameterGroupInfo("Element position/orientation shift.", false), - ApertureGroup => EleParameterGroupInfo("Vacuum chamber aperture.", false), - BeamBeamGroup => EleParameterGroupInfo("BeamBeam element parameters.", false), - BendGroup => EleParameterGroupInfo("Bend element parameters.", true), - BMultipoleGroup => EleParameterGroupInfo("Magnetic multipoles.", true), - BMultipole => EleParameterGroupInfo("Magnetic multipole of given order. Substructure contained in `BMultipoleGroup`", false), - DescriptionGroup => EleParameterGroupInfo("Informational strings.", false), - DownstreamReferenceGroup => EleParameterGroupInfo("Downstream element end reference energy and species.", false), - EMultipoleGroup => EleParameterGroupInfo("Electric multipoles.", false), - EMultipole => EleParameterGroupInfo("Electric multipole of given order. Substructure contained in `EMultipoleGroup`.", false), - ForkGroup => EleParameterGroupInfo("Fork element parameters", false), - GirderGroup => EleParameterGroupInfo("Girder parameters.", false), - InitParticleGroup => EleParameterGroupInfo("Initial particle position and spin.", false), - TwissGroup => EleParameterGroupInfo("Initial Twiss and coupling parameters.", false), - LengthGroup => EleParameterGroupInfo("Length and s-position parameters.", true), - LordSlaveStatusGroup => EleParameterGroupInfo("Element lord and slave status.", false), - MasterGroup => EleParameterGroupInfo("Contains field_master parameter.", false), - OrientationGroup => EleParameterGroupInfo("Global floor position and orientation.", true), - OriginEleGroup => EleParameterGroupInfo("Defines coordinate origin for Girder, FloorShift and Fiducial elements.", false), - PatchGroup => EleParameterGroupInfo("Patch parameters.", false), - ReferenceGroup => EleParameterGroupInfo("Reference energy and species.", true), - RFGroup => EleParameterGroupInfo("`RFCavity` and `LCavity` RF parameters.", true), - RFAutoGroup => EleParameterGroupInfo("Contains `auto_amp`, and `auto_phase` related parameters.", false), - SolenoidGroup => EleParameterGroupInfo("`Solenoid` parameters.", false), - TrackingGroup => EleParameterGroupInfo("Default tracking settings.", false), + ACKickerParams => EleParameterParamsInfo("ACKicker element parameters.", false), + BodyShiftParams => EleParameterParamsInfo("Element position/orientation shift.", false), + ApertureParams => EleParameterParamsInfo("Vacuum chamber aperture.", false), + BeamBeamParams => EleParameterParamsInfo("BeamBeam element parameters.", false), + BendParams => EleParameterParamsInfo("Bend element parameters.", true), + BMultipoleParams => EleParameterParamsInfo("Magnetic multipoles.", true), + BMultipole => EleParameterParamsInfo("Magnetic multipole of given order. Substructure contained in `BMultipoleParams`", false), + DescriptionParams => EleParameterParamsInfo("Informational strings.", false), + DownstreamReferenceParams => EleParameterParamsInfo("Downstream element end reference energy and species.", false), + EMultipoleParams => EleParameterParamsInfo("Electric multipoles.", false), + EMultipole => EleParameterParamsInfo("Electric multipole of given order. Substructure contained in `EMultipoleParams`.", false), + ForkParams => EleParameterParamsInfo("Fork element parameters", false), + GirderParams => EleParameterParamsInfo("Girder parameters.", false), + InitParticleParams => EleParameterParamsInfo("Initial particle position and spin.", false), + TwissParams => EleParameterParamsInfo("Initial Twiss and coupling parameters.", false), + LengthParams => EleParameterParamsInfo("Length and s-position parameters.", true), + LordSlaveStatusParams => EleParameterParamsInfo("Element lord and slave status.", false), + MasterParams => EleParameterParamsInfo("Contains field_master parameter.", false), + OrientationParams => EleParameterParamsInfo("Global floor position and orientation.", true), + OriginEleParams => EleParameterParamsInfo("Defines coordinate origin for Girder, FloorShift and Fiducial elements.", false), + PatchParams => EleParameterParamsInfo("Patch parameters.", false), + ReferenceParams => EleParameterParamsInfo("Reference energy and species.", true), + RFParams => EleParameterParamsInfo("`RFCavity` and `LCavity` RF parameters.", true), + RFAutoParams => EleParameterParamsInfo("Contains `auto_amp`, and `auto_phase` related parameters.", false), + SolenoidParams => EleParameterParamsInfo("`Solenoid` parameters.", false), + TrackingParams => EleParameterParamsInfo("Default tracking settings.", false), ) #--------------------------------------------------------------------------------------------------- @@ -761,12 +772,12 @@ BRANCH_PARAM::Dict{Symbol,ParamInfo} = Dict{Symbol,ParamInfo}( ) #--------------------------------------------------------------------------------------------------- -# Bases.copy(x::T) where {T <: EleParameterGroup} +# Bases.copy(x::T) where {T <: EleParameterParams} """ Copy for a normal element parameter group is equivalent to a deep copy. The only reason not to have copy != deepcopy is when the group has a lot of data. Think field table. """ -Base.copy(x::T) where {T <: EleParameterGroup} = T([deepcopy(getfield(x, k)) for k ∈ fieldnames(T)]...) +Base.copy(x::T) where {T <: EleParameterParams} = T([deepcopy(getfield(x, k)) for k ∈ fieldnames(T)]...) diff --git a/src/show.jl b/src/show.jl index 5820a8d..d422c38 100644 --- a/src/show.jl +++ b/src/show.jl @@ -2,43 +2,43 @@ # show_column2 """ - show_column2 = Dict{Type{T} where T <: EleParameterGroup, Dict{Symbol,Symbol}} + show_column2 = Dict{Type{T} where T <: EleParameterParams, Dict{Symbol,Symbol}} Dict used by the `show(::ele)` command which contains the information as to what to put in the second column when displaying the elements of an element parameter group using the two column format. Example `show_column2` key/value pair: ```julia - OrientationGroup => Dict{Symbol,Symbol}( + OrientationParams => Dict{Symbol,Symbol}( :r => :q, :phi => :psi, ) ``` -In this example, when printing the `OrientationGroup`, in the line showing the `.r` component, +In this example, when printing the `OrientationParams`, 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. When defining custom parameter groups, key/value pairs can be added to `show_column2` as needed. -NOTE! For any show_column2[Group] dict, Output parameters may be a value (will appear in column 2) +NOTE! For any show_column2[Params] dict, Output parameters may be a value (will appear in column 2) but not a key. This restriction is not fundamental and could be remove with a little programming. """ show_column2 -show_column2 = Dict{Type{T} where T <: BaseEleParameterGroup, Dict{Symbol,Symbol}}( - BodyShiftGroup => Dict{Symbol,Symbol}( +show_column2 = Dict{Type{T} where T <: BaseEleParameterParams, Dict{Symbol,Symbol}}( + BodyShiftParams => Dict{Symbol,Symbol}( :offset => :offset_tot, :x_rot => :x_rot_tot, :y_rot => :y_rot_tot, :z_rot => :z_rot_tot, ), - ApertureGroup => Dict{Symbol,Symbol}( + ApertureParams => Dict{Symbol,Symbol}( :x_limit => :y_limit, :aperture_shape => :aperture_shifts_with_body, ), - BendGroup => Dict{Symbol,Symbol}( + BendParams => Dict{Symbol,Symbol}( :bend_type => :exact_multipoles, :g => :norm_bend_field, :angle => :rho, @@ -53,70 +53,70 @@ show_column2 = Dict{Type{T} where T <: BaseEleParameterGroup, Dict{Symbol,Symbol :eta => :etap, ), - OrientationGroup => Dict{Symbol,Symbol}( + OrientationParams => Dict{Symbol,Symbol}( :r => :q, ), - GirderGroup => Dict{Symbol,Symbol}( + GirderParams => Dict{Symbol,Symbol}( :origin_ele => :origin_ele_ref_pt, :dr => :dq, ), - LengthGroup => Dict{Symbol,Symbol}( + LengthParams => Dict{Symbol,Symbol}( :L => :orientation, :s => :s_downstream, ), - LordSlaveStatusGroup => Dict{Symbol,Symbol}( + LordSlaveStatusParams => Dict{Symbol,Symbol}( :lord_status => :slave_status, ), - MasterGroup => Dict{Symbol,Symbol}( + MasterParams => Dict{Symbol,Symbol}( :is_on => :field_master ), - PatchGroup => Dict{Symbol,Symbol}( + PatchParams => Dict{Symbol,Symbol}( :E_tot_offset => :t_offset, :E_tot_downstream => :pc_downstream, :flexible => :L_user, ), - DescriptionGroup => Dict{Symbol,Symbol}( + DescriptionParams => Dict{Symbol,Symbol}( :type => :ID, ), - DownstreamReferenceGroup => Dict{Symbol,Symbol}( + DownstreamReferenceParams => Dict{Symbol,Symbol}( :pc_ref_downstream => :E_tot_ref_downstream, :β_ref_downstream => :γ_ref_downstream, ), - InitParticleGroup => Dict{Symbol,Symbol}( + InitParticleParams => Dict{Symbol,Symbol}( ), - ReferenceGroup => Dict{Symbol,Symbol}( + ReferenceParams => Dict{Symbol,Symbol}( :species_ref => :extra_dtime_ref, :pc_ref => :E_tot_ref, :time_ref => :time_ref_downstream, :β_ref => :γ_ref, ), - RFGroup => Dict{Symbol,Symbol}( + RFParams => Dict{Symbol,Symbol}( :voltage => :gradient, :phase => :multipass_phase, :frequency => :harmon, :n_cell => :cavity_type, ), - RFAutoGroup => Dict{Symbol,Symbol}( + RFAutoParams => Dict{Symbol,Symbol}( :do_auto_amp => :do_auto_phase, :auto_amp => :auto_phase, ), - SolenoidGroup => Dict{Symbol,Symbol}( + SolenoidParams => Dict{Symbol,Symbol}( :Ksol => :Bsol, ), - TrackingGroup => Dict{Symbol,Symbol}( + TrackingParams => Dict{Symbol,Symbol}( :num_steps => :ds_step, ), @@ -126,7 +126,7 @@ show_column2 = Dict{Type{T} where T <: BaseEleParameterGroup, Dict{Symbol,Symbol :eta => :etap, ), - TwissGroup => Dict{Symbol,Symbol}( + TwissParams => Dict{Symbol,Symbol}( :beta_a => :beta_b, :alpha_a => :alpha_b, :gamma_a => :gamma_b, @@ -286,7 +286,7 @@ function show_ele(io::IO, ele::Ele, docstring = false) for key in sort(collect(keys(pdict))) if key in IGNORE_ELE_PDICT_KEY; continue; end val = pdict[key] - if typeof(val) <: EleParameterGroup || key == :changed; continue; end + if typeof(val) <: EleParameterParams || key == :changed; continue; end if key == :name; continue; end nn2 = max(nn, length(string(key))) param_name = rpad(string(key), nn2) @@ -301,12 +301,12 @@ function show_ele(io::IO, ele::Ele, docstring = false) # Print element parameter groups (does not include changed) for key in sort(collect(keys(pdict))) group = pdict[key] - if !(typeof(group) <: EleParameterGroup); continue; end - # Do not show if the group parameter values are the same as the ReferenceGroup - if key == :DownstreamReferenceGroup - rg = pdict[:ReferenceGroup] + if !(typeof(group) <: EleParameterParams); continue; end + # Do not show if the group parameter values are the same as the ReferenceParams + if key == :DownstreamReferenceParams + rg = pdict[:ReferenceParams] if group.species_ref_downstream == rg.species_ref && group.pc_ref_downstream == rg.pc_ref - println(io, " DownstreamReferenceGroup: Same energy and species values as ReferenceGroup") + println(io, " DownstreamReferenceParams: Same energy and species values as ReferenceParams") continue end end @@ -341,12 +341,12 @@ Base.show(io::IO, ::MIME"text/plain", ele::Ele) = show_ele(io, ele, false) # show_elegroup """ - Internal: show_elegroup(io::IO, group::EleParameterGroup, ele::Ele, docstring::Bool; indent = 0) + Internal: show_elegroup(io::IO, group::EleParameterParams, ele::Ele, docstring::Bool; indent = 0) Prints lattice element group info. Used by `show_ele`. """ show_elegroup -function show_elegroup(io::IO, group::EleParameterGroup, ele::Ele, docstring::Bool; indent = 0) +function show_elegroup(io::IO, group::EleParameterParams, ele::Ele, docstring::Bool; indent = 0) if docstring show_elegroup_with_doc(io, group, ele, indent = indent) else @@ -356,15 +356,15 @@ end #--------- -function show_elegroup(io::IO, group::BMultipoleGroup, ele::Ele, docstring::Bool; indent = 0) +function show_elegroup(io::IO, group::BMultipoleParams, ele::Ele, docstring::Bool; indent = 0) off_str = " "^indent if length(group.pole) == 0 - println(io, "$(off_str)BMultipoleGroup: No magnetic multipoles") + println(io, "$(off_str)BMultipoleParams: No magnetic multipoles") return end - println(io, "$(off_str)BMultipoleGroup:") + println(io, "$(off_str)BMultipoleParams:") tilt = "tilt (rad)" println(io, "$(off_str) Order integrated $(lpad(tilt,23))") for v in group.pole @@ -381,15 +381,15 @@ end #--------- -function show_elegroup(io::IO, group::EMultipoleGroup, ele::Ele, docstring::Bool; indent = 0) +function show_elegroup(io::IO, group::EMultipoleParams, ele::Ele, docstring::Bool; indent = 0) off_str = " "^indent if length(group.pole) == 0 - println(io, "$(off_str)EMultipoleGroup: No electric multipoles") + println(io, "$(off_str)EMultipoleParams: No electric multipoles") return end - println(io, "$(off_str)EMultipoleGroup:") + println(io, "$(off_str)EMultipoleParams:") println(io, "$(off_str) Order Eintegrated{lpad(\"Etilt (rad)\",23)}") for v in group.pole !isnothing(v.Eintegrated) && v.Eintegrated ? ol = "$(v.order)L" : ol = "$(v.order) " @@ -402,12 +402,12 @@ end # show_elegroup_with_doc """ - show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParameterGroup + show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParameterParams Single column printing of an element group with a docstring printed for each parameter. """ show_elegroup_with_doc -function show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParameterGroup +function show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParameterParams gtype = typeof(group) nn = max(18, maximum(length.(fieldnames(gtype)))) println(io, f" {gtype}:") @@ -423,12 +423,12 @@ end # show_elegroup_wo_doc """ - show_elegroup_wo_doc(io::IO, group::BaseEleParameterGroup, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) + show_elegroup_wo_doc(io::IO, group::BaseEleParameterParams, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) Two column printing of an element group without any docstring. """ show_elegroup_wo_doc -function show_elegroup_wo_doc(io::IO, group::BaseEleParameterGroup, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) +function show_elegroup_wo_doc(io::IO, group::BaseEleParameterParams, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) # If output field for column 1 or column 2 is wider than this, print the fields on two lines. col_width_cut = 55 @@ -481,7 +481,7 @@ function show_elegroup_wo_doc(io::IO, group::BaseEleParameterGroup, ele::Ele; in end else - if field_sym in fieldnames(gtype) && typeof(getfield(group, field_sym)) <: EleParameterSubGroup; continue; end + if field_sym in fieldnames(gtype) && typeof(getfield(group, field_sym)) <: EleParameterSubParams; continue; end field_name = rpad(full_parameter_name(field_sym, gtype), n1) vstr = ele_param_value_str(ele, field_sym) println(io, " "^indent * f" {field_name} {vstr} {units(field_sym)}") @@ -494,14 +494,14 @@ end # full_parameter_name """ - full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParameterGroup + full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParameterParams -For fields where the user name is different (EG: `r_floor` and `r` in a OrientationGroup), +For fields where the user name is different (EG: `r_floor` and `r` in a OrientationParams), return the string `struct_name (user_name)` (EG: `r (r_floor)`). Also add `(output)` to names of output parameters. """ full_parameter_name -function full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParameterGroup +function full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParameterParams pinfo = ele_param_info(field, throw_error = false) if !isnothing(pinfo) if !isnothing(pinfo.output_group); return "$field (output)"; end @@ -587,7 +587,7 @@ function Base.show(io::IO, branch::Branch) if branch.type == MultipassBranch end_str = f"{ele.L:11.6f}" if haskey(ele.pdict, :slaves); end_str = end_str * " "^28 * f" {ele_param_value_str(ele.pdict, :slaves, default = \"\")}"; end - elseif haskey(ele.pdict, :LengthGroup) + elseif haskey(ele.pdict, :LengthParams) s_str = ele_param_value_str(ele, :s, default = " "*"-"^7, format = "12.6f") s_down_str = ele_param_value_str(ele, :s_downstream, default = " "*"-"^7, format = "12.6f") end_str = f"{ele.L:12.6f}{s_str} ->{s_down_str}" @@ -686,7 +686,7 @@ end info(str::AbstractString) -> nothing # Info on element parameter string. EG: "angle", "Kn1", etc. info(ele_type::Type{T}) where T <: Ele # Info on a given element type. info(ele::Ele) # Info on typeof(ele) element type. - info(group::Type{T}) where T <: EleParameterGroup # Info on element parameter group. + info(group::Type{T}) where T <: EleParameterParams # Info on element parameter group. Prints information about: + The element parameter represented by `sym` or `str`. @@ -696,7 +696,7 @@ Prints information about: ## Examples info(:L) # Prints information on parameter `L`. info("L") # Same as above. - info(LengthGroup) # `LengthGroup` info. + info(LengthParams) # `LengthParams` info. """ info function info(sym::Symbol) @@ -752,7 +752,7 @@ end #---- -function info(group::Type{T}) where T <: EleParameterGroup +function info(group::Type{T}) where T <: EleParameterParams if group in keys(ELE_PARAM_GROUP_INFO) println("$(group): $(ELE_PARAM_GROUP_INFO[group].description)") else diff --git a/src/struct.jl b/src/struct.jl index 6826a13..ff60c0b 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -82,7 +82,7 @@ Element constructor Example: Result: The variable `q1` is a `Quadrupole` with the argument values put the the appropriate place. Note: All element parameter groups associated with the element type will be constructed. Thus, in the -above example,`q1` above will have `q1.LengthGroup` (equivalent to `q1.pdict[:LengthGroup]`) created. +above example,`q1` above will have `q1.LengthParams` (equivalent to `q1.pdict[:LengthParams]`) created. """ macro ele(expr) expr.head == :(=) || error("Missing equals sign '=' after element name. " * @@ -249,12 +249,12 @@ mutable struct BeamLine <: BeamLineItem end #--------------------------------------------------------------------------------------------------- -# EleParameterGroupInfo +# EleParameterParamsInfo """ - Internal: struct EleParameterGroupInfo + Internal: struct EleParameterParamsInfo -Struct holding information on a single `EleParameterGroup` group. +Struct holding information on a single `EleParameterParams` group. Used in constructing the `ELE_PARAM_GROUP_INFO` Dict. ## Contains @@ -262,42 +262,42 @@ Used in constructing the `ELE_PARAM_GROUP_INFO` Dict. • `bookkeeping_needed::Bool - If true, this indicates there exists a bookkeeping function for the \\ parameter group that needs to be called if a parameter of the group is changed. \\ """ -struct EleParameterGroupInfo +struct EleParameterParamsInfo description::String bookkeeping_needed::Bool end #--------------------------------------------------------------------------------------------------- -# EleParameterGroup +# EleParameterParams """ - abstract type BaseEleParameterGroup - abstract type EleParameterGroup <: BaseEleParameterGroup - abstract type EleParameterSubGroup <: BaseEleParameterGroup + abstract type BaseEleParameterParams + abstract type EleParameterParams <: BaseEleParameterParams + abstract type EleParameterSubParams <: BaseEleParameterParams -`EleParameterGroup` is the base type for all element parameter groups. -`EleParameterSubGroup` is the base type for structs that are used as components of an element +`EleParameterParams` is the base type for all element parameter groups. +`EleParameterSubParams` is the base type for structs that are used as components of an element parameter group. -To see in which element types contain a given parameter group, use the `info(::EleParameterGroup)` +To see in which element types contain a given parameter group, use the `info(::EleParameterParams)` method. To see what parameter groups are contained in a Example: ``` - info(BodyShiftGroup) # List element types that contain BodyShiftGroup + info(BodyShiftParams) # List element types that contain BodyShiftParams ``` -""" BaseEleParameterGroup, EleParameterGroup, EleParameterSubGroup +""" BaseEleParameterParams, EleParameterParams, EleParameterSubParams -abstract type BaseEleParameterGroup end -abstract type EleParameterGroup <: BaseEleParameterGroup end -abstract type EleParameterSubGroup <: BaseEleParameterGroup end +abstract type BaseEleParameterParams end +abstract type EleParameterParams <: BaseEleParameterParams end +abstract type EleParameterSubParams <: BaseEleParameterParams end #--------------------------------------------------------------------------------------------------- # BMultipole subgroup """ - mutable struct BMultipole <: EleParameterSubGroup + mutable struct BMultipole <: EleParameterSubParams Single magnetic multipole of a given order. -Used by `BMultipoleGroup`. +Used by `BMultipoleParams`. ## Fields @@ -310,7 +310,7 @@ Used by `BMultipoleGroup`. • `integrated::Union{Bool,Nothing}` - Integrated or not? \\ Also determines what stays constant with length changes. \\ """ -@kwdef mutable struct BMultipole <: EleParameterSubGroup # A single multipole +@kwdef mutable struct BMultipole <: EleParameterSubParams # A single multipole Kn::Number = 0.0 # EG: "Kn2", "Kn2L" Ks::Number = 0.0 # EG: "Ks2", "Ks2L" Bn::Number = 0.0 @@ -328,7 +328,7 @@ Dispersion parameters for a single axis. """ Dispersion1 -@kwdef mutable struct Dispersion1 <: EleParameterSubGroup +@kwdef mutable struct Dispersion1 <: EleParameterSubParams eta::Number = NaN # Position dispersion. etap::Number = NaN # Momentum dispersion. deta_ds::Number = NaN # Dispersion derivative. @@ -338,10 +338,10 @@ end # EMultipole subgroup """ - mutable struct EMultipole <: EleParameterSubGroup + mutable struct EMultipole <: EleParameterSubParams Single electric multipole of a given order. -Used by `EMultipoleGroup`. +Used by `EMultipoleParams`. ## Fields @@ -353,7 +353,7 @@ Used by `EMultipoleGroup`. Also determines what stays constant with length changes. \\ """ EMultipole -@kwdef mutable struct EMultipole <: EleParameterSubGroup +@kwdef mutable struct EMultipole <: EleParameterSubParams En::Number = 0.0 # EG: "En2", "En2L" Es::Number = 0.0 # EG: "Es2", "Es2L" Etilt::Number = 0.0 @@ -365,12 +365,12 @@ end # Twiss subgroup. """ - mutable struct Twiss <: EleParameterSubGroup + mutable struct Twiss <: EleParameterSubParams Twiss parameters for used for BeamBeam element to describe the strong beam. """ Twiss -@kwdef mutable struct Twiss <: EleParameterSubGroup +@kwdef mutable struct Twiss <: EleParameterSubParams beta_a::Number = NaN alpha_a::Number = NaN beta_b::Number = NaN @@ -381,13 +381,13 @@ end # Twiss1 subgroup """ - mutable struct Twiss1 <: EleParameterSubGroup + mutable struct Twiss1 <: EleParameterSubParams Twiss parameters for a single mode. """ Twiss1 -@kwdef mutable struct Twiss1 <: EleParameterSubGroup +@kwdef mutable struct Twiss1 <: EleParameterSubParams beta::Number = NaN # Beta Twiss alpha::Number = NaN # Alpha Twiss gamma::Number = NaN # Gamma Twiss @@ -401,7 +401,7 @@ end # Vertex1 subgroup """ - struct Vertex1 <: EleParameterSubGroup + struct Vertex1 <: EleParameterSubParams Single vertex. An array of vertices can be used to construct an aperture. If `radius_x`, and `radius_y` )and possibly `tilt`) are set, this specifies the shape of the elliptical arc @@ -415,7 +415,7 @@ If not set, the chamber wall from the vertex to the next vertex is a straight li • `tilt::Number` - Tilt of ellipse. \\ """ Vertex1 -@kwdef mutable struct Vertex1 <: EleParameterSubGroup +@kwdef mutable struct Vertex1 <: EleParameterSubParams r0::Vector{Number} = [NaN, NaN] radius_x::Number = NaN radius_y::Number = NaN @@ -429,7 +429,7 @@ Vertex1(r0::Vector{Number}, rx::Number = NaN, ry::Number = NaN) = # Wall2D subgroup """ - mutable struct Wall2D <: EleParameterSubGroup + mutable struct Wall2D <: EleParameterSubParams Vacuum chamber wall cross-section. @@ -438,7 +438,7 @@ Vacuum chamber wall cross-section. • `r0::Vector{Number}` - Origin point. \\ """ Wall2D -@kwdef mutable struct Wall2D <: EleParameterSubGroup +@kwdef mutable struct Wall2D <: EleParameterSubParams vertex::Vector{Vertex1} = Vector{Vertex1}() r0::Vector{Number} = [0.0, 0.0] end @@ -447,10 +447,10 @@ Wall2D(v::Vector{Vertex1}) = Wall2D(v, [0.0, 0.0]) #--------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------- -# ACKickerGroup +# ACKickerParams """ - mutable struct ACKickerGroup <: EleParameterGroup + mutable struct ACKickerParams <: EleParameterParams ACKicker parameters. @@ -460,17 +460,17 @@ ACKicker parameters. amp_function(time::Number) -> amplitude::Number ``` -""" ACKickerGroup +""" ACKickerParams -@kwdef mutable struct ACKickerGroup <: EleParameterGroup +@kwdef mutable struct ACKickerParams <: EleParameterParams amp_function::Union{Function, Nothing} = nothing end #--------------------------------------------------------------------------------------------------- -# ApertureGroup +# ApertureParams """ - mutable struct ApertureGroup <: EleParameterGroup + mutable struct ApertureParams <: EleParameterParams Vacuum chamber aperture struct. @@ -482,9 +482,9 @@ Vacuum chamber aperture struct. • `aperture_at::BodyLoc.T` - Where aperture is. Default is `BodyLoc.ENTRANCE_END`. \\ • `aperture_shifts_with_body:Bool` - Do element alignments shifts move the aperture? Default is `false`. \\ • `custom_aperture::Dict` - Custom aperture information. \\ -""" ApertureGroup +""" ApertureParams -@kwdef mutable struct ApertureGroup <: EleParameterGroup +@kwdef mutable struct ApertureParams <: EleParameterParams x_limit::Vector = [-Inf, Inf] y_limit::Vector = [-Inf, Inf] aperture_shape::typeof(ApertureShape) = ELLIPTICAL @@ -495,12 +495,12 @@ Vacuum chamber aperture struct. end #--------------------------------------------------------------------------------------------------- -# BeamBeamGroup +# BeamBeamParams #### This is incomplete #### """ - mutable struct BeamBeamGroup <: EleParameterGroup + mutable struct BeamBeamParams <: EleParameterParams ## Fields • `n_slice::Number` - Number of slices the Strong beam is divided into. \\ @@ -514,9 +514,9 @@ end • `sig_y::Number` - Strong beam vertical sigma at IP. \\ • `sig_z::Number` - Strong beam longitudinal sigma. \\ • `bbi_constant::Number` - BBI constant. Set by Bmad. See manual. \\ -""" BeamBeamGroup +""" BeamBeamParams -@kwdef mutable struct BeamBeamGroup <: EleParameterGroup +@kwdef mutable struct BeamBeamParams <: EleParameterParams n_slice::Number = 1 n_particle::Number = 0 species::Species = Species() @@ -531,10 +531,10 @@ end end #--------------------------------------------------------------------------------------------------- -# BendGroup +# BendParams """ - mutable struct BendGroup <: EleParameterGroup + mutable struct BendParams <: EleParameterParams ## Fields • `bend_type::BendType.T` - Is e or e_rect fixed? @@ -564,10 +564,10 @@ rectangular like (`BendType.RECTANGULAR`) bends. The `bend_type` switch is only bend angle or length is varied. See the documentation for details. Whether `bend_field_ref` or `g` is held constant when the reference energy is varied is -determined by the `field_master` setting in the MasterGroup struct. -""" BendGroup +determined by the `field_master` setting in the MasterParams struct. +""" BendParams -@kwdef mutable struct BendGroup <: EleParameterGroup +@kwdef mutable struct BendParams <: EleParameterParams bend_type::BendType.T = BendType.SECTOR angle::Number = 0.0 g::Number = 0.0 @@ -584,10 +584,10 @@ determined by the `field_master` setting in the MasterGroup struct. end #--------------------------------------------------------------------------------------------------- -# BMultipoleGroup +# BMultipoleParams """ - mutable struct BMultipoleGroup <: EleParameterGroup + mutable struct BMultipoleParams <: EleParameterParams Vector of magnetic multipoles. @@ -595,12 +595,12 @@ Vector of magnetic multipoles. • `pole::Vector{BMultipole}` - Vector of multipoles. \\ """ -@kwdef mutable struct BMultipoleGroup <: EleParameterGroup +@kwdef mutable struct BMultipoleParams <: EleParameterParams pole::Vector{BMultipole} = Vector{BMultipole}(undef,0) # Vector of multipoles. end #--------------------------------------------------------------------------------------------------- -# BodyShiftGroup +# BodyShiftParams """ mutable struct BodyShiftGroup <: EleParameterGroup @@ -630,7 +630,6 @@ non-tot fields if there is no `Girder`. • `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. \\ • `z_rot_tot::Number` - Rotation around the z-axis including Girder alignment shifts. \\ -""" BodyShiftGroup @kwdef mutable struct BodyShiftGroup <: EleParameterGroup offset::Vector = [0.0, 0.0, 0.0] @@ -643,7 +642,47 @@ end # DescriptionGroup """ - mutable struct DescriptionGroup <: EleParameterGroup + mutable struct BodyShiftParams <: EleParameterParams + +Defines the position and orientation of an element. + +- 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. + +## 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. \\ + +# 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. +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. +• `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. \\ +• `z_rot_tot::Number` - Rotation around the z-axis including Girder alignment shifts. \\ +""" BodyShiftParams + +@kwdef mutable struct BodyShiftParams <: EleParameterParams + offset::Vector = [0.0, 0.0, 0.0] + x_rot::Number = 0 + y_rot::Number = 0 + z_rot::Number = 0 +end + +#--------------------------------------------------------------------------------------------------- +# DescriptionParams + +""" + mutable struct DescriptionParams <: EleParameterParams Strings that can be set and used with element searches. These strings have no affect on tracking. @@ -653,26 +692,26 @@ These strings have no affect on tracking. • `type::String` \\ • `ID::String` \\ • `class::String` \\ -""" DescriptionGroup +""" DescriptionParams -@kwdef mutable struct DescriptionGroup <: EleParameterGroup +@kwdef mutable struct DescriptionParams <: EleParameterParams type::String = "" ID::String = "" class::String = "" end #--------------------------------------------------------------------------------------------------- -# DownstreamReferenceGroup +# DownstreamReferenceParams """ - mutable struct DownstreamReferenceGroup <: EleParameterGroup + mutable struct DownstreamReferenceParams <: EleParameterParams Downstream end of element reference energy and species. This group is useful for elements where the reference energy or species is not constant. Elements where this is true include `LCavity`, `Foil`, and `Converter`. -To simplify the lattice bookkeeping, all elements that have a `ReferenceGroup` also have -a `DownstreamReferenceGroup`. +To simplify the lattice bookkeeping, all elements that have a `ReferenceParams` also have +a `DownstreamReferenceParams`. ## Fields • `species_ref_downstream::Species` - Reference species exit end. \\ @@ -683,32 +722,32 @@ a `DownstreamReferenceGroup`. • `β_ref_downstream::Number` - Reference `v/c` upstream end. \\ • `γ_ref_downstream::Number` - Reference gamma factor downstream end. \\ """ -@kwdef mutable struct DownstreamReferenceGroup <: EleParameterGroup +@kwdef mutable struct DownstreamReferenceParams <: EleParameterParams species_ref_downstream::Species = Species() pc_ref_downstream::Number = NaN E_tot_ref_downstream::Number = NaN end #--------------------------------------------------------------------------------------------------- -# EMultipoleGroup +# EMultipoleParams """ - mutable struct EMultipoleGroup <: EleParameterGroup + mutable struct EMultipoleParams <: EleParameterParams Vector of Electric multipoles. ## Field • `pole::Vector{EMultipole}` - Vector of multipoles. \\ """ -@kwdef mutable struct EMultipoleGroup <: EleParameterGroup +@kwdef mutable struct EMultipoleParams <: EleParameterParams pole::Vector{EMultipole} = Vector{EMultipole}([]) # Vector of multipoles. end #--------------------------------------------------------------------------------------------------- -# ForkGroup +# ForkParams """ - mutable struct ForkGroup <: EleParameterGroup + mutable struct ForkParams <: EleParameterParams Fork element parameters. @@ -716,35 +755,35 @@ Fork element parameters. • `to_line::Union{BeamLine,Nothing}` - Beam line to fork to. \\ • `to_ele` - On input: Element ID or element itself. \\ • `direction::Int` - Longitudinal Direction of injected beam. \\ -""" ForkGroup +""" ForkParams -@kwdef mutable struct ForkGroup <: EleParameterGroup +@kwdef mutable struct ForkParams <: EleParameterParams to_line::Union{BeamLine,Nothing} = nothing to_ele::Union = "" direction::Int = +1 end #--------------------------------------------------------------------------------------------------- -# GirderGroup +# GirderParams """ - mutable struct GirderGroup <: EleParameterGroup + mutable struct GirderParams <: EleParameterParams Girder parameters. ## Fields • `supported:::Vector{Ele}` - Elements supported by girder. \\ -""" GirderGroup +""" GirderParams -@kwdef mutable struct GirderGroup <: EleParameterGroup +@kwdef mutable struct GirderParams <: EleParameterParams supported::Vector{Ele} = Ele[] end #--------------------------------------------------------------------------------------------------- -# InitParticleGroup +# InitParticleParams """ - mutable struct InitParticleGroup <: EleParameterGroup + mutable struct InitParticleParams <: EleParameterParams Initial particle position. @@ -752,16 +791,16 @@ Initial particle position. • `orbit::Vector{Number}` - Phase space 6-vector. \\ • `spin::Vector{Number}` - Spin 3-vector. \\ """ -@kwdef mutable struct InitParticleGroup <: EleParameterGroup +@kwdef mutable struct InitParticleParams <: EleParameterParams orbit::Vector{Number} = Vector{Number}([0,0,0,0,0,0]) # Phase space vector spin::Vector{Number} = Vector{Number}([0,0,0]) # Spin vector end #--------------------------------------------------------------------------------------------------- -# LengthGroup +# LengthParams """ - mutable struct LengthGroup <: EleParameterGroup + mutable struct LengthParams <: EleParameterParams Element length and s-positions. @@ -771,9 +810,9 @@ Element length and s-positions. • `s::Number` - Starting s-position. \\ • `s_downstream::Number` - Ending s-position. \\ • `orientation::Int` - Longitudinal orientation. +1 or -1. \\ -""" LengthGroup +""" LengthParams -@kwdef mutable struct LengthGroup <: EleParameterGroup +@kwdef mutable struct LengthParams <: EleParameterParams L::Number = 0.0 # Length of element s::Number = 0.0 # Starting s-position s_downstream::Number = 0.0 # Ending s-position @@ -781,10 +820,10 @@ Element length and s-positions. end #--------------------------------------------------------------------------------------------------- -# LordSlaveStatusGroup +# LordSlaveStatusParams """ - mutable struct LordSlaveStatusGroup <: EleParameterGroup + mutable struct LordSlaveStatusParams <: EleParameterParams Lord and slave status of an element. @@ -793,34 +832,34 @@ Lord and slave status of an element. • `slave_status::Slave.T` - Slave status. \\ """ -@kwdef mutable struct LordSlaveStatusGroup <: EleParameterGroup +@kwdef mutable struct LordSlaveStatusParams <: EleParameterParams lord_status::Lord.T = Lord.NOT slave_status::Slave.T = Slave.NOT end #--------------------------------------------------------------------------------------------------- -# MasterGroup +# MasterParams """ - mutable struct MasterGroup <: EleParameterGroup + mutable struct MasterParams <: EleParameterParams ## Fields • `is_on::Bool` - Turns on or off the fields in an element. When off, the element looks like a drift. \\ • `field_master::Bool` - The setting of this matters when there is a change in reference energy. \\ In this case, if `field_master` = true, magnetic multipoles and Bend unnormalized fields will be held constant and normalized field strengths willbe varied. And vice versa when `field_master` is `false`. \\ -""" MasterGroup +""" MasterParams -@kwdef mutable struct MasterGroup <: EleParameterGroup +@kwdef mutable struct MasterParams <: EleParameterParams is_on::Bool = true field_master::Bool = false # Does field or normalized field stay constant with energy changes? end #--------------------------------------------------------------------------------------------------- -# OrientationGroup +# OrientationParams """ - mutable struct OrientationGroup <: EleParameterGroup + mutable struct OrientationParams <: EleParameterParams Position and angular orientation. In a lattice element, this group gives the orientation at the entrance end of the element @@ -829,38 +868,38 @@ ignoring alignment shifts. # Fields • `r::Vector` - `[x,y,z]` position. \\ • `q::Quaternion{Number}` - Quaternion orientation. \\ -""" OrientationGroup +""" OrientationParams -@kwdef mutable struct OrientationGroup <: EleParameterGroup +@kwdef mutable struct OrientationParams <: EleParameterParams r::Vector = [0.0, 0.0, 0.0] q::Quaternion{Number} = Quaternion(1.0, 0.0, 0.0, 0.0) end #--------------------------------------------------------------------------------------------------- -# OriginEleGroup +# OriginEleParams """ - mutable struct OriginEleGroup <: EleParameterGroup + mutable struct OriginEleParams <: EleParameterParams Used with `Fiducial`, `FloorShift`, and `Girder` elements. -The `OriginEleGroup` is used to set the coordinate reference frame from which -the orientation set by the `BodyShiftGroup` is measured. +The `OriginEleParams` is used to set the coordinate reference frame from which +the orientation set by the `BodyShiftParams` is measured. ## Fields • `origin_ele::Ele` - Origin reference element. Default is NULL_ELE. \\ • `origin_ele_ref_pt::Loc.T` - Origin reference point. Default is `Loc.CENTER`. \\ -""" OriginEleGroup +""" OriginEleParams -@kwdef mutable struct OriginEleGroup <: EleParameterGroup +@kwdef mutable struct OriginEleParams <: EleParameterParams origin_ele::Ele = NULL_ELE origin_ele_ref_pt::Loc.T = Loc.CENTER end #--------------------------------------------------------------------------------------------------- -# PatchGroup +# PatchParams """ - mutable struct PatchGroup <: EleParameterGroup + mutable struct PatchParams <: EleParameterParams `Patch` element parameters. @@ -872,9 +911,9 @@ end • `flexible::Bool` - Flexible patch? Default is `false`. \\ • `L_user::Number` - User set Length? Default is `NaN` (length calculated by bookkeeping code). \\ • `ref_coords::BodyLoc.T` - Reference coordinate system used inside the patch. Default is `BodyLoc.EXIT_END`. \\ -""" PatchGroup +""" PatchParams -@kwdef mutable struct PatchGroup <: EleParameterGroup +@kwdef mutable struct PatchParams <: EleParameterParams t_offset::Number = 0.0 # Time offset E_tot_offset::Number = NaN E_tot_exit::Number = NaN # Reference energy at exit end @@ -885,13 +924,13 @@ end end #--------------------------------------------------------------------------------------------------- -# ReferenceGroup +# ReferenceParams """ - mutable struct ReferenceGroup <: EleParameterGroup + mutable struct ReferenceParams <: EleParameterParams Reference energy, time, species, etc at upstream end of an element. -See also `DownstreamReferenceGroup +See also `DownstreamReferenceParams ## Fields • `species_ref::Species` - Reference species entering end. \\ @@ -900,13 +939,13 @@ See also `DownstreamReferenceGroup • `time_ref::Number` - Reference time upstream end. \\ • `time_ref_downstream::Number` - Reference time downstream end. \\ • `extra_dtime_ref::Number` - User set additional time change. \\ -• `dE_ref`::Number - Sets the change in the reference energy. \\ +• `dE_ref`::Number - Sets the change in the reference energy. \\ ## Associated output parameters are • `β_ref::Number` - Reference `v/c` upstream end. \\ • `γ_ref::Number` - Reference gamma factor upstream end. \\ """ -@kwdef mutable struct ReferenceGroup <: EleParameterGroup +@kwdef mutable struct ReferenceParams <: EleParameterParams species_ref::Species = Species() pc_ref::Number = NaN E_tot_ref::Number = NaN @@ -917,12 +956,12 @@ See also `DownstreamReferenceGroup end #--------------------------------------------------------------------------------------------------- -# RFGroup +# RFParams """ - mutable struct RFGroup <: EleParameterGroup + mutable struct RFParams <: EleParameterParams -RF voltage parameters. Also see `RFAutoGroup`. +RF voltage parameters. Also see `RFAutoParams`. ## Fields @@ -934,9 +973,9 @@ RF voltage parameters. Also see `RFAutoGroup`. • `multipass_phase::Number` - RF Phase added to multipass elements. \\ • `cavity_type::Cavity.T` - Cavity type. Default is `Cavity.STANDING_WAVE`. \\ • `n_cell::Int` - Number of cavity cells. Default is `1`. \\ -""" RFGroup +""" RFParams -@kwdef mutable struct RFGroup <: EleParameterGroup +@kwdef mutable struct RFParams <: EleParameterParams frequency::Number = 0.0 harmon::Number = 0.0 voltage::Number = 0.0 @@ -948,12 +987,12 @@ RF voltage parameters. Also see `RFAutoGroup`. end #--------------------------------------------------------------------------------------------------- -# RFAutoGroup +# RFAutoParams """ - mutable struct RFAutoGroup <: EleParameterGroup + mutable struct RFAutoParams <: EleParameterParams -RF autoscale parameters. Also see `RFGroup`. +RF autoscale parameters. Also see `RFParams`. ## Fields @@ -961,9 +1000,9 @@ RF autoscale parameters. Also see `RFGroup`. • `do_auto_phase::Bool` - Will autoscaling set `auto_phase`? Default is `true`. \\ • `auto_amp::Number` - Auto RF field amplitude scale value. \\ • `auto_phase::Number` - Auto RF phase value. \\ -""" RFAutoGroup +""" RFAutoParams -@kwdef mutable struct RFAutoGroup <: EleParameterGroup +@kwdef mutable struct RFAutoParams <: EleParameterParams do_auto_amp::Bool = true do_auto_phase::Bool = true auto_amp::Number = 1.0 @@ -971,10 +1010,10 @@ RF autoscale parameters. Also see `RFGroup`. end #--------------------------------------------------------------------------------------------------- -# SolenoidGroup +# SolenoidParams """ - mutable struct SolenoidGroup <: EleParameterGroup + mutable struct SolenoidParams <: EleParameterParams Solenoid parameters. @@ -982,18 +1021,18 @@ Solenoid parameters. • `Ksol::Number` - Normalized solenoid strength. \\ • `Bsol::Number` - Solenoid field. \\ -""" SolenoidGroup +""" SolenoidParams -@kwdef mutable struct SolenoidGroup <: EleParameterGroup +@kwdef mutable struct SolenoidParams <: EleParameterParams Ksol::Number = 0.0 Bsol::Number = 0.0 end #--------------------------------------------------------------------------------------------------- -# TrackingGroup +# TrackingParams """ - mutable struct TrackingGroup <: EleParameterGroup + mutable struct TrackingParams <: EleParameterParams Sets the nominal values for tracking prameters. @@ -1001,9 +1040,9 @@ Sets the nominal values for tracking prameters. • `num_steps::Int` - Number of steps. \\ • `ds_step::Number` - Step length. \\ -""" TrackingGroup +""" TrackingParams -@kwdef mutable struct TrackingGroup <: EleParameterGroup +@kwdef mutable struct TrackingParams <: EleParameterParams num_steps::Int = -1 ds_step::Number = NaN end @@ -1011,16 +1050,16 @@ end #--------------------------------------------------------------------------------------------------- -# TwissGroup +# TwissParams """ - mutable struct TwissGroup <: EleParameterGroup + mutable struct TwissParams <: EleParameterParams Lattice element parameter group storing Twiss, dispersion and coupling parameters for an element. -""" TwissGroup +""" TwissParams -@kwdef mutable struct TwissGroup <: EleParameterGroup +@kwdef mutable struct TwissParams <: EleParameterParams a::Twiss1 = Twiss1() # a-mode b::Twiss1 = Twiss1() # b-mode x::Dispersion1 = Dispersion1() # x-axis @@ -1034,7 +1073,7 @@ end abstract type BaseOutput Abstract type from which output group structs inherit. -AcceleratorLattice defines `OutputGroup <: BaseOutput` which is used for output parameters +AcceleratorLattice defines `OutputParams <: BaseOutput` which is used for output parameters defined by AcceleratorLattice. Custom output parameters may be defined by defining a new output group struct and a new `output_parameter` function method. @@ -1042,28 +1081,28 @@ output group struct and a new `output_parameter` function method. abstract type BaseOutput end #--------------------------------------------------------------------------------------------------- -# OutputGroup +# OutputParams """ - struct OutputGroup <: BaseOutput + struct OutputParams <: BaseOutput Holy trait struct that is used to designate output element parameters. -""" OutputGroup +""" OutputParams -struct OutputGroup <: BaseOutput +struct OutputParams <: BaseOutput end #--------------------------------------------------------------------------------------------------- -# AllGroup +# AllParams """ - struct AllGroup + struct AllParams Struct used for element parameter bookkeeping whose presence represents that parameters in all parameter groups may have changed. -""" AllGroup +""" AllParams -struct AllGroup; end +struct AllParams; end #--------------------------------------------------------------------------------------------------- # AbstractLattice @@ -1190,17 +1229,18 @@ end Internal: mutable struct ChangedLedger When bookkeeping a branch, element-by-element, starting from the beginning of the branch, -the ledger keeps track of what has changed so that the change can propagate to the -following elements. +the ledger keeps track of "properties" that have changed since the last bookkeeping so that a +change in a property of one element can propagate to the following elements. Ledger parameters, when toggled to true, will never be reset for the remainder of the branch bookkeeping. -The exception is the `this_ele_length` parameter which is reset for each element. +The exception is the `this_ele_length` parameter which is reset after bookkeeping is done for +an element. # Fields -• `this_ele_length::Bool` \\ -• `s_position::Bool` \\ -• `ref_group::Bool` \\ -• `floor_position::Bool` \\ +• `this_ele_length::Bool` - The length of the current element has changed. \\ +• `s_position::Bool` - The longitudinal element position has changed. \\ +• `ref_group::Bool` - Reference property (species, energy, or time) has changed. \\ +• `floor_position::Bool` - The branch coordinate system has changed with respect to the floor coordinates. \\ """ ChangedLedger diff --git a/src/traversal.jl b/src/traversal.jl index 0ad0cd6..7003729 100644 --- a/src/traversal.jl +++ b/src/traversal.jl @@ -65,19 +65,19 @@ function Base.iterate(x::Region, ele::Ele) end #--------------------------------------------------------------------------------------------------- -# Base.iterate(::EleParameterGroup), Base.length(::EleParameterGroup) +# Base.iterate(::EleParameterParams), Base.length(::EleParameterParams) """ - Base.length(::EleParameterGroup) - Base.iterate(::EleParameterGroup) + Base.length(::EleParameterParams) + Base.iterate(::EleParameterParams) -Define `length` and `iterate` for `EleParameterGroup` structs so can use `collect` with these structs. -""" Base.iterate(::EleParameterGroup), Base.length(::EleParameterGroup) +Define `length` and `iterate` for `EleParameterParams` structs so can use `collect` with these structs. +""" Base.iterate(::EleParameterParams), Base.length(::EleParameterParams) -Base.length(x::Type{T}) where T <: EleParameterGroup = 1 -Base.iterate(x::Type{T}) where T <: EleParameterGroup = (x, x) -Base.iterate(x::Type{T}, y) where T <: EleParameterGroup = nothing +Base.length(x::Type{T}) where T <: EleParameterParams = 1 +Base.iterate(x::Type{T}) where T <: EleParameterParams = (x, x) +Base.iterate(x::Type{T}, y) where T <: EleParameterParams = nothing #--------------------------------------------------------------------------------------------------- # collect(::Branch) diff --git a/src/utilities.jl b/src/utilities.jl index 7a6fafe..2ee0ec9 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -23,7 +23,7 @@ function lat_sanity_check(lat::Lattice) if branch !== ele.branch; error("SanityCheck: Ele $(ele_name(ele)) has ele.branch not pointing to parient branch."); end if branch.type == TrackingBranch - if !haskey(ele.pdict, :LengthGroup) error("Sanity check: Ele $(ele_name(ele)) does not have a LengthGroup group."); end + if !haskey(ele.pdict, :LengthParams) error("Sanity check: Ele $(ele_name(ele)) does not have a LengthParams group."); end end end end @@ -34,13 +34,13 @@ end # Base.isless """ - Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParameterGroup, T2 <: EleParameterGroup} -> Bool + Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParameterParams, T2 <: EleParameterParams} -> Bool Base.isless(x::Type{T}, y::Type{U}) where {T <: Ele, U <: Ele} = isless(string(x), string(y)) -> Bool Used to sort output alphabetically by name. """ Base.isless -function Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParameterGroup, T2 <: EleParameterGroup} +function Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParameterParams, T2 <: EleParameterParams} return Symbol(a) < Symbol(b) end diff --git a/test/ToDo.list b/test/ToDo.list index 2fd96c7..ca0e3cd 100644 --- a/test/ToDo.list +++ b/test/ToDo.list @@ -1,3 +1,3 @@ * Test that PARAM_GROUPS_LIST keys cover all element types. -* Test that PARAM_GROUPS_LIST values are arrays of EleParameterGroup items. +* Test that PARAM_GROUPS_LIST values are arrays of EleParameterParams items. * Test that Param_group_info keys cover all parameter groups. \ No newline at end of file