diff --git a/manual/ele-anatomy.tex b/manual/ele-anatomy.tex index 8e71970..c8bca5e 100644 --- a/manual/ele-anatomy.tex +++ b/manual/ele-anatomy.tex @@ -63,11 +63,11 @@ \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{EleParameterParams}. +structs which inherit from the abstract type \vn{EleParams}. 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(EleParameterParams) + julia> subtypes(EleParams) 28-element Vector{Any}: BodyShiftParams ApertureParams @@ -103,7 +103,7 @@ \section{Element Parameters} For example, the \vn{LengthParams} holds the length and s-positions of the element and is defined by: \begin{example} - @kwdef struct LengthParams <: EleParameterParams + @kwdef struct LengthParams <: EleParams L::Number = 0.0 # Length of element s::Number = 0.0 # Starting s-position s_downstream::Number = 0.0 # Ending s-position diff --git a/manual/ele-param-groups.tex b/manual/ele-param-groups.tex index cc63390..694621f 100644 --- a/manual/ele-param-groups.tex +++ b/manual/ele-param-groups.tex @@ -31,17 +31,17 @@ \chapter{Element Parameter Paramss} \label{t:ele.param.g} \end{table} -Element parameter groups inherit from the abstract type \vn{EleParameterParams} which -in turn inherits from \vn{BaseEleParameterParams}. Some +Element parameter groups inherit from the abstract type \vn{EleParams} which +in turn inherits from \vn{BaseEleParams}. Some parameter groups have sub-group components. -These sub-groups also inherit from \vn{BaseEleParameterParams}: +These sub-groups also inherit from \vn{BaseEleParams}: \begin{example} - abstract type BaseEleParameterParams end - abstract type EleParameterParams <: BaseEleParameterParams end - abstract type EleParameterSubParams <: BaseEleParameterParams end + abstract type BaseEleParams end + abstract type EleParams <: BaseEleParams end + abstract type EleParameterSubParams <: BaseEleParams end \end{example} -To see which element types contain a given group, use the \vn{info(::EleParameterParams)} +To see which element types contain a given group, use the \vn{info(::EleParams)} method. Example: \begin{example} julia> info(BodyShiftParams) diff --git a/manual/enums.tex b/manual/enums.tex index 4bcaad4..2868827 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 ApertureParams <: EleParameterParams + struct ApertureParams <: EleParams aperture_type::ApertureShape.T = ApertureShape.ELLIPTICAL aperture_at::BodyLoc.T = BodyLoc.ENTRANCE_END ... diff --git a/src/AcceleratorLattice.jl b/src/AcceleratorLattice.jl index f7485e5..73283a8 100644 --- a/src/AcceleratorLattice.jl +++ b/src/AcceleratorLattice.jl @@ -69,7 +69,7 @@ export split!, construct_ele_type, ele_at_s, toggle_integrated! export eles_search, eles_substitute_lords!, eles_sort! export next_ele, ele_at_offset, ele_param_value_str, strip_AL, ele_param_group_symbols export branch, matches_branch, create_ele_vars, eval_str, Vertex1, LatticeGlobal -export EleParameterParams, BodyShiftParams, OrientationParams, BMultipole, BMultipoleParams, BeamBeamParams +export EleParams, BodyShiftParams, OrientationParams, BMultipole, BMultipoleParams, BeamBeamParams export EMultipole, EMultipoleParams, BendParams, ApertureParams, DescriptionParams, RFParams, SolenoidParams export TrackingParams, LengthParams, ReferenceParams, DownstreamReferenceParams, ForkParams export MasterParams, LordSlaveStatusParams, ACKickerParams diff --git a/src/accessor.jl b/src/accessor.jl index 8c4de3e..ed11dbd 100644 --- a/src/accessor.jl +++ b/src/accessor.jl @@ -305,7 +305,7 @@ end # get_elegroup_param """ - Internal: get_elegroup_param(ele::Ele, group::EleParameterParams, pinfo::ParamInfo) + Internal: get_elegroup_param(ele::Ele, group::EleParams, 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::EleParameterParams, pinfo::ParamInfo) +function get_elegroup_param(ele::Ele, group::EleParams, pinfo::ParamInfo) if pinfo.parent_group == pinfo.paramkind # Example see: ParamInfo(:twiss) return group else @@ -357,11 +357,11 @@ end # set_elegroup_param! """ - Internal: set_elegroup_param!(ele::Ele, group::EleParameterParams, pinfo::ParamInfo, value) + Internal: set_elegroup_param!(ele::Ele, group::EleParams, pinfo::ParamInfo, value) """ set_elegroup_param -function set_elegroup_param!(ele::Ele, group::EleParameterParams, pinfo::ParamInfo, value) +function set_elegroup_param!(ele::Ele, group::EleParams, pinfo::ParamInfo, value) if !isnothing(pinfo.sub_struct) # Example see: ParamInfo(:a_beta) return setfield!(pinfo.sub_struct(group), pinfo.struct_sym, value) else @@ -421,14 +421,14 @@ end # base_field(group, pinfo) """ - base_field(group::EleParameterParams, pinfo::ParamInfo) -> BaseEleParameterParams + base_field(group::EleParams, pinfo::ParamInfo) -> BaseEleParams 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 `TwissParams` instance and returned is the sub group `group.a`. -""" base_field(group::EleParameterParams, pinfo::ParamInfo) +""" base_field(group::EleParams, pinfo::ParamInfo) -function base_field(group::EleParameterParams, pinfo::ParamInfo) +function base_field(group::EleParams, pinfo::ParamInfo) if isnothing(pinfo.sub_struct) return group else # Example see: ParamInfo(:a_beta) diff --git a/src/bookkeeper.jl b/src/bookkeeper.jl index d204f73..a64e374 100644 --- a/src/bookkeeper.jl +++ b/src/bookkeeper.jl @@ -387,7 +387,7 @@ 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 <: EleParameterParams + previous_ele::Ele) where T <: EleParams clear_changed!(ele, group) return end @@ -785,12 +785,12 @@ end # has_changed """ - has_changed(ele::Ele, group::Type{T}) where T <: EleParameterParams -> Bool + has_changed(ele::Ele, group::Type{T}) where T <: EleParams -> Bool Has any parameter in `group` changed since the last bookkeeping? """ -function has_changed(ele::Ele, group::Type{T}) where T <: EleParameterParams +function has_changed(ele::Ele, group::Type{T}) where T <: EleParams if ele.slave_status == Slave.SUPER lord = ele.super_lords[1] # UnionEle slave handled elsewhere. for param in keys(lord.changed) @@ -817,7 +817,7 @@ end # clear_changed! """ - clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParameterParams + clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParams 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 <: EleParameterParams +function clear_changed!(ele::Ele, group::Type{T}; clear_lord::Bool = false) where T <: EleParams 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 <: EleParameterParams +function reinstate_changed!(ele::Ele, group::Type{T}) where T <: EleParams for param in keys(ele.changed) info = ele_param_info(param, ele, throw_error = false) if isnothing(info) || info.parent_group != group; continue; end diff --git a/src/output_lat.jl b/src/output_lat.jl index a1f3c3f..ff62d97 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::EleParameterParams) +function Base.write(io::IO, group::EleParams) end diff --git a/src/parameters.jl b/src/parameters.jl index 08e7846..7cd4107 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -250,7 +250,7 @@ If the "user name" is different from the group field name, the user name is used For example, for a `OrientationParams`, `r_floor` will be in the name list instead of `r`. """ associated_names -function associated_names(group::Type{T}) where T <: EleParameterParams +function associated_names(group::Type{T}) where T <: EleParams 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 <: BaseEleParameterParams +function has_parent_group(pinfo::ParamInfo, group::Type{T}) where T <: BaseEleParams if typeof(pinfo.parent_group) <: Vector return group in pinfo.parent_group else @@ -614,17 +614,6 @@ PARAM_GROUPS_LIST = Dict( 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] -general_group_list = [base_group_list..., multipole_group_list...] - -PARAM_GROUPS_LIST = Dict( - ACKicker => [general_group_list..., ACKickerGroup], - BeamBeam => [base_group_list..., BeamBeamGroup], - BeginningEle => [base_group_list..., TwissGroup, InitParticleGroup], - Bend => [BendGroup, general_group_list...], Collimator => [base_group_list...], Converter => [base_group_list...], CrabCavity => [base_group_list...], @@ -661,32 +650,32 @@ end ELE_PARAM_GROUP_INFO = Dict( - 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), + ACKickerParams => EleParamsInfo("ACKicker element parameters.", false), + BodyShiftParams => EleParamsInfo("Element position/orientation shift.", false), + ApertureParams => EleParamsInfo("Vacuum chamber aperture.", false), + BeamBeamParams => EleParamsInfo("BeamBeam element parameters.", false), + BendParams => EleParamsInfo("Bend element parameters.", true), + BMultipoleParams => EleParamsInfo("Magnetic multipoles.", true), + BMultipole => EleParamsInfo("Magnetic multipole of given order. Substructure contained in `BMultipoleParams`", false), + DescriptionParams => EleParamsInfo("Informational strings.", false), + DownstreamReferenceParams => EleParamsInfo("Downstream element end reference energy and species.", false), + EMultipoleParams => EleParamsInfo("Electric multipoles.", false), + EMultipole => EleParamsInfo("Electric multipole of given order. Substructure contained in `EMultipoleParams`.", false), + ForkParams => EleParamsInfo("Fork element parameters", false), + GirderParams => EleParamsInfo("Girder parameters.", false), + InitParticleParams => EleParamsInfo("Initial particle position and spin.", false), + TwissParams => EleParamsInfo("Initial Twiss and coupling parameters.", false), + LengthParams => EleParamsInfo("Length and s-position parameters.", true), + LordSlaveStatusParams => EleParamsInfo("Element lord and slave status.", false), + MasterParams => EleParamsInfo("Contains field_master parameter.", false), + OrientationParams => EleParamsInfo("Global floor position and orientation.", true), + OriginEleParams => EleParamsInfo("Defines coordinate origin for Girder, FloorShift and Fiducial elements.", false), + PatchParams => EleParamsInfo("Patch parameters.", false), + ReferenceParams => EleParamsInfo("Reference energy and species.", true), + RFParams => EleParamsInfo("`RFCavity` and `LCavity` RF parameters.", true), + RFAutoParams => EleParamsInfo("Contains `auto_amp`, and `auto_phase` related parameters.", false), + SolenoidParams => EleParamsInfo("`Solenoid` parameters.", false), + TrackingParams => EleParamsInfo("Default tracking settings.", false), ) #--------------------------------------------------------------------------------------------------- @@ -772,12 +761,12 @@ BRANCH_PARAM::Dict{Symbol,ParamInfo} = Dict{Symbol,ParamInfo}( ) #--------------------------------------------------------------------------------------------------- -# Bases.copy(x::T) where {T <: EleParameterParams} +# Bases.copy(x::T) where {T <: EleParams} """ 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 <: EleParameterParams} = T([deepcopy(getfield(x, k)) for k ∈ fieldnames(T)]...) +Base.copy(x::T) where {T <: EleParams} = T([deepcopy(getfield(x, k)) for k ∈ fieldnames(T)]...) diff --git a/src/show.jl b/src/show.jl index d422c38..f3103b4 100644 --- a/src/show.jl +++ b/src/show.jl @@ -2,7 +2,7 @@ # show_column2 """ - show_column2 = Dict{Type{T} where T <: EleParameterParams, Dict{Symbol,Symbol}} + show_column2 = Dict{Type{T} where T <: EleParams, 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. @@ -24,7 +24,7 @@ NOTE! For any show_column2[Params] dict, Output parameters may be a value (will 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 <: BaseEleParameterParams, Dict{Symbol,Symbol}}( +show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}( BodyShiftParams => Dict{Symbol,Symbol}( :offset => :offset_tot, :x_rot => :x_rot_tot, @@ -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) <: EleParameterParams || key == :changed; continue; end + if typeof(val) <: EleParams || key == :changed; continue; end if key == :name; continue; end nn2 = max(nn, length(string(key))) param_name = rpad(string(key), nn2) @@ -301,7 +301,7 @@ 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) <: EleParameterParams); continue; end + if !(typeof(group) <: EleParams); continue; end # Do not show if the group parameter values are the same as the ReferenceParams if key == :DownstreamReferenceParams rg = pdict[:ReferenceParams] @@ -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::EleParameterParams, ele::Ele, docstring::Bool; indent = 0) + Internal: show_elegroup(io::IO, group::EleParams, ele::Ele, docstring::Bool; indent = 0) Prints lattice element group info. Used by `show_ele`. """ show_elegroup -function show_elegroup(io::IO, group::EleParameterParams, ele::Ele, docstring::Bool; indent = 0) +function show_elegroup(io::IO, group::EleParams, ele::Ele, docstring::Bool; indent = 0) if docstring show_elegroup_with_doc(io, group, ele, indent = indent) else @@ -402,12 +402,12 @@ end # show_elegroup_with_doc """ - show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParameterParams + show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParams 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 <: EleParameterParams +function show_elegroup_with_doc(io::IO, group::T; ele::Ele, indent = 0) where T <: EleParams 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::BaseEleParameterParams, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) + show_elegroup_wo_doc(io::IO, group::BaseEleParams, 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::BaseEleParameterParams, ele::Ele; indent = 0, group_show_name::Symbol = :NONE) +function show_elegroup_wo_doc(io::IO, group::BaseEleParams, 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 @@ -494,14 +494,14 @@ end # full_parameter_name """ - full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParameterParams + full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParams For fields where the user name is different (EG: `r_floor` and `r` in a OrientationParams), 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 <: BaseEleParameterParams +function full_parameter_name(field::Symbol, group::Type{T}) where T <: BaseEleParams pinfo = ele_param_info(field, throw_error = false) if !isnothing(pinfo) if !isnothing(pinfo.output_group); return "$field (output)"; end @@ -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 <: EleParameterParams # Info on element parameter group. + info(group::Type{T}) where T <: EleParams # Info on element parameter group. Prints information about: + The element parameter represented by `sym` or `str`. @@ -752,7 +752,7 @@ end #---- -function info(group::Type{T}) where T <: EleParameterParams +function info(group::Type{T}) where T <: EleParams 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 ff60c0b..6549916 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -249,12 +249,12 @@ mutable struct BeamLine <: BeamLineItem end #--------------------------------------------------------------------------------------------------- -# EleParameterParamsInfo +# EleParamsInfo """ - Internal: struct EleParameterParamsInfo + Internal: struct EleParamsInfo -Struct holding information on a single `EleParameterParams` group. +Struct holding information on a single `EleParams` group. Used in constructing the `ELE_PARAM_GROUP_INFO` Dict. ## Contains @@ -262,33 +262,33 @@ 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 EleParameterParamsInfo +struct EleParamsInfo description::String bookkeeping_needed::Bool end #--------------------------------------------------------------------------------------------------- -# EleParameterParams +# EleParams """ - abstract type BaseEleParameterParams - abstract type EleParameterParams <: BaseEleParameterParams - abstract type EleParameterSubParams <: BaseEleParameterParams + abstract type BaseEleParams + abstract type EleParams <: BaseEleParams + abstract type EleParameterSubParams <: BaseEleParams -`EleParameterParams` is the base type for all element parameter groups. +`EleParams` 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(::EleParameterParams)` +To see in which element types contain a given parameter group, use the `info(::EleParams)` method. To see what parameter groups are contained in a Example: ``` info(BodyShiftParams) # List element types that contain BodyShiftParams ``` -""" BaseEleParameterParams, EleParameterParams, EleParameterSubParams +""" BaseEleParams, EleParams, EleParameterSubParams -abstract type BaseEleParameterParams end -abstract type EleParameterParams <: BaseEleParameterParams end -abstract type EleParameterSubParams <: BaseEleParameterParams end +abstract type BaseEleParams end +abstract type EleParams <: BaseEleParams end +abstract type EleParameterSubParams <: BaseEleParams end #--------------------------------------------------------------------------------------------------- # BMultipole subgroup @@ -450,7 +450,7 @@ Wall2D(v::Vector{Vertex1}) = Wall2D(v, [0.0, 0.0]) # ACKickerParams """ - mutable struct ACKickerParams <: EleParameterParams + mutable struct ACKickerParams <: EleParams ACKicker parameters. @@ -462,7 +462,7 @@ ACKicker parameters. """ ACKickerParams -@kwdef mutable struct ACKickerParams <: EleParameterParams +@kwdef mutable struct ACKickerParams <: EleParams amp_function::Union{Function, Nothing} = nothing end @@ -470,7 +470,7 @@ end # ApertureParams """ - mutable struct ApertureParams <: EleParameterParams + mutable struct ApertureParams <: EleParams Vacuum chamber aperture struct. @@ -484,7 +484,7 @@ Vacuum chamber aperture struct. • `custom_aperture::Dict` - Custom aperture information. \\ """ ApertureParams -@kwdef mutable struct ApertureParams <: EleParameterParams +@kwdef mutable struct ApertureParams <: EleParams x_limit::Vector = [-Inf, Inf] y_limit::Vector = [-Inf, Inf] aperture_shape::typeof(ApertureShape) = ELLIPTICAL @@ -500,7 +500,7 @@ end #### This is incomplete #### """ - mutable struct BeamBeamParams <: EleParameterParams + mutable struct BeamBeamParams <: EleParams ## Fields • `n_slice::Number` - Number of slices the Strong beam is divided into. \\ @@ -516,7 +516,7 @@ end • `bbi_constant::Number` - BBI constant. Set by Bmad. See manual. \\ """ BeamBeamParams -@kwdef mutable struct BeamBeamParams <: EleParameterParams +@kwdef mutable struct BeamBeamParams <: EleParams n_slice::Number = 1 n_particle::Number = 0 species::Species = Species() @@ -534,7 +534,7 @@ end # BendParams """ - mutable struct BendParams <: EleParameterParams + mutable struct BendParams <: EleParams ## Fields • `bend_type::BendType.T` - Is e or e_rect fixed? @@ -567,7 +567,7 @@ Whether `bend_field_ref` or `g` is held constant when the reference energy is va determined by the `field_master` setting in the MasterParams struct. """ BendParams -@kwdef mutable struct BendParams <: EleParameterParams +@kwdef mutable struct BendParams <: EleParams bend_type::BendType.T = BendType.SECTOR angle::Number = 0.0 g::Number = 0.0 @@ -587,7 +587,7 @@ end # BMultipoleParams """ - mutable struct BMultipoleParams <: EleParameterParams + mutable struct BMultipoleParams <: EleParams Vector of magnetic multipoles. @@ -595,7 +595,7 @@ Vector of magnetic multipoles. • `pole::Vector{BMultipole}` - Vector of multipoles. \\ """ -@kwdef mutable struct BMultipoleParams <: EleParameterParams +@kwdef mutable struct BMultipoleParams <: EleParams pole::Vector{BMultipole} = Vector{BMultipole}(undef,0) # Vector of multipoles. end @@ -603,7 +603,7 @@ end # BodyShiftParams """ - mutable struct BodyShiftGroup <: EleParameterGroup + mutable struct BodyShiftParams <: EleParams Defines the position and orientation of an element. @@ -615,63 +615,26 @@ 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. \\ +• `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. \\ - -@kwdef mutable struct BodyShiftGroup <: EleParameterGroup - offset::Vector = [0.0, 0.0, 0.0] - x_rot::Number = 0 - y_rot::Number = 0 - z_rot::Number = 0 -end - -#--------------------------------------------------------------------------------------------------- -# DescriptionGroup +## Associated Output Parameters -""" - 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 +@kwdef mutable struct BodyShiftParams <: EleParams offset::Vector = [0.0, 0.0, 0.0] x_rot::Number = 0 y_rot::Number = 0 @@ -682,7 +645,7 @@ end # DescriptionParams """ - mutable struct DescriptionParams <: EleParameterParams + mutable struct DescriptionParams <: EleParams Strings that can be set and used with element searches. These strings have no affect on tracking. @@ -694,7 +657,7 @@ These strings have no affect on tracking. • `class::String` \\ """ DescriptionParams -@kwdef mutable struct DescriptionParams <: EleParameterParams +@kwdef mutable struct DescriptionParams <: EleParams type::String = "" ID::String = "" class::String = "" @@ -704,7 +667,7 @@ end # DownstreamReferenceParams """ - mutable struct DownstreamReferenceParams <: EleParameterParams + mutable struct DownstreamReferenceParams <: EleParams Downstream end of element reference energy and species. This group is useful for elements where the reference energy or species is not constant. @@ -722,7 +685,7 @@ a `DownstreamReferenceParams`. • `β_ref_downstream::Number` - Reference `v/c` upstream end. \\ • `γ_ref_downstream::Number` - Reference gamma factor downstream end. \\ """ -@kwdef mutable struct DownstreamReferenceParams <: EleParameterParams +@kwdef mutable struct DownstreamReferenceParams <: EleParams species_ref_downstream::Species = Species() pc_ref_downstream::Number = NaN E_tot_ref_downstream::Number = NaN @@ -732,14 +695,14 @@ end # EMultipoleParams """ - mutable struct EMultipoleParams <: EleParameterParams + mutable struct EMultipoleParams <: EleParams Vector of Electric multipoles. ## Field • `pole::Vector{EMultipole}` - Vector of multipoles. \\ """ -@kwdef mutable struct EMultipoleParams <: EleParameterParams +@kwdef mutable struct EMultipoleParams <: EleParams pole::Vector{EMultipole} = Vector{EMultipole}([]) # Vector of multipoles. end @@ -747,7 +710,7 @@ end # ForkParams """ - mutable struct ForkParams <: EleParameterParams + mutable struct ForkParams <: EleParams Fork element parameters. @@ -757,7 +720,7 @@ Fork element parameters. • `direction::Int` - Longitudinal Direction of injected beam. \\ """ ForkParams -@kwdef mutable struct ForkParams <: EleParameterParams +@kwdef mutable struct ForkParams <: EleParams to_line::Union{BeamLine,Nothing} = nothing to_ele::Union = "" direction::Int = +1 @@ -767,7 +730,7 @@ end # GirderParams """ - mutable struct GirderParams <: EleParameterParams + mutable struct GirderParams <: EleParams Girder parameters. @@ -775,7 +738,7 @@ Girder parameters. • `supported:::Vector{Ele}` - Elements supported by girder. \\ """ GirderParams -@kwdef mutable struct GirderParams <: EleParameterParams +@kwdef mutable struct GirderParams <: EleParams supported::Vector{Ele} = Ele[] end @@ -783,7 +746,7 @@ end # InitParticleParams """ - mutable struct InitParticleParams <: EleParameterParams + mutable struct InitParticleParams <: EleParams Initial particle position. @@ -791,7 +754,7 @@ Initial particle position. • `orbit::Vector{Number}` - Phase space 6-vector. \\ • `spin::Vector{Number}` - Spin 3-vector. \\ """ -@kwdef mutable struct InitParticleParams <: EleParameterParams +@kwdef mutable struct InitParticleParams <: EleParams 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 @@ -800,7 +763,7 @@ end # LengthParams """ - mutable struct LengthParams <: EleParameterParams + mutable struct LengthParams <: EleParams Element length and s-positions. @@ -812,7 +775,7 @@ Element length and s-positions. • `orientation::Int` - Longitudinal orientation. +1 or -1. \\ """ LengthParams -@kwdef mutable struct LengthParams <: EleParameterParams +@kwdef mutable struct LengthParams <: EleParams L::Number = 0.0 # Length of element s::Number = 0.0 # Starting s-position s_downstream::Number = 0.0 # Ending s-position @@ -823,7 +786,7 @@ end # LordSlaveStatusParams """ - mutable struct LordSlaveStatusParams <: EleParameterParams + mutable struct LordSlaveStatusParams <: EleParams Lord and slave status of an element. @@ -832,7 +795,7 @@ Lord and slave status of an element. • `slave_status::Slave.T` - Slave status. \\ """ -@kwdef mutable struct LordSlaveStatusParams <: EleParameterParams +@kwdef mutable struct LordSlaveStatusParams <: EleParams lord_status::Lord.T = Lord.NOT slave_status::Slave.T = Slave.NOT end @@ -841,7 +804,7 @@ end # MasterParams """ - mutable struct MasterParams <: EleParameterParams + mutable struct MasterParams <: EleParams ## Fields • `is_on::Bool` - Turns on or off the fields in an element. When off, the element looks like a drift. \\ @@ -850,7 +813,7 @@ In this case, if `field_master` = true, magnetic multipoles and Bend unnormalize and normalized field strengths willbe varied. And vice versa when `field_master` is `false`. \\ """ MasterParams -@kwdef mutable struct MasterParams <: EleParameterParams +@kwdef mutable struct MasterParams <: EleParams is_on::Bool = true field_master::Bool = false # Does field or normalized field stay constant with energy changes? end @@ -859,7 +822,7 @@ end # OrientationParams """ - mutable struct OrientationParams <: EleParameterParams + mutable struct OrientationParams <: EleParams Position and angular orientation. In a lattice element, this group gives the orientation at the entrance end of the element @@ -870,7 +833,7 @@ ignoring alignment shifts. • `q::Quaternion{Number}` - Quaternion orientation. \\ """ OrientationParams -@kwdef mutable struct OrientationParams <: EleParameterParams +@kwdef mutable struct OrientationParams <: EleParams r::Vector = [0.0, 0.0, 0.0] q::Quaternion{Number} = Quaternion(1.0, 0.0, 0.0, 0.0) end @@ -879,7 +842,7 @@ end # OriginEleParams """ - mutable struct OriginEleParams <: EleParameterParams + mutable struct OriginEleParams <: EleParams Used with `Fiducial`, `FloorShift`, and `Girder` elements. The `OriginEleParams` is used to set the coordinate reference frame from which @@ -890,7 +853,7 @@ the orientation set by the `BodyShiftParams` is measured. • `origin_ele_ref_pt::Loc.T` - Origin reference point. Default is `Loc.CENTER`. \\ """ OriginEleParams -@kwdef mutable struct OriginEleParams <: EleParameterParams +@kwdef mutable struct OriginEleParams <: EleParams origin_ele::Ele = NULL_ELE origin_ele_ref_pt::Loc.T = Loc.CENTER end @@ -899,7 +862,7 @@ end # PatchParams """ - mutable struct PatchParams <: EleParameterParams + mutable struct PatchParams <: EleParams `Patch` element parameters. @@ -913,7 +876,7 @@ end • `ref_coords::BodyLoc.T` - Reference coordinate system used inside the patch. Default is `BodyLoc.EXIT_END`. \\ """ PatchParams -@kwdef mutable struct PatchParams <: EleParameterParams +@kwdef mutable struct PatchParams <: EleParams t_offset::Number = 0.0 # Time offset E_tot_offset::Number = NaN E_tot_exit::Number = NaN # Reference energy at exit end @@ -927,7 +890,7 @@ end # ReferenceParams """ - mutable struct ReferenceParams <: EleParameterParams + mutable struct ReferenceParams <: EleParams Reference energy, time, species, etc at upstream end of an element. See also `DownstreamReferenceParams @@ -945,7 +908,7 @@ See also `DownstreamReferenceParams • `β_ref::Number` - Reference `v/c` upstream end. \\ • `γ_ref::Number` - Reference gamma factor upstream end. \\ """ -@kwdef mutable struct ReferenceParams <: EleParameterParams +@kwdef mutable struct ReferenceParams <: EleParams species_ref::Species = Species() pc_ref::Number = NaN E_tot_ref::Number = NaN @@ -959,7 +922,7 @@ end # RFParams """ - mutable struct RFParams <: EleParameterParams + mutable struct RFParams <: EleParams RF voltage parameters. Also see `RFAutoParams`. @@ -975,7 +938,7 @@ RF voltage parameters. Also see `RFAutoParams`. • `n_cell::Int` - Number of cavity cells. Default is `1`. \\ """ RFParams -@kwdef mutable struct RFParams <: EleParameterParams +@kwdef mutable struct RFParams <: EleParams frequency::Number = 0.0 harmon::Number = 0.0 voltage::Number = 0.0 @@ -990,7 +953,7 @@ end # RFAutoParams """ - mutable struct RFAutoParams <: EleParameterParams + mutable struct RFAutoParams <: EleParams RF autoscale parameters. Also see `RFParams`. @@ -1002,7 +965,7 @@ RF autoscale parameters. Also see `RFParams`. • `auto_phase::Number` - Auto RF phase value. \\ """ RFAutoParams -@kwdef mutable struct RFAutoParams <: EleParameterParams +@kwdef mutable struct RFAutoParams <: EleParams do_auto_amp::Bool = true do_auto_phase::Bool = true auto_amp::Number = 1.0 @@ -1013,7 +976,7 @@ end # SolenoidParams """ - mutable struct SolenoidParams <: EleParameterParams + mutable struct SolenoidParams <: EleParams Solenoid parameters. @@ -1023,7 +986,7 @@ Solenoid parameters. • `Bsol::Number` - Solenoid field. \\ """ SolenoidParams -@kwdef mutable struct SolenoidParams <: EleParameterParams +@kwdef mutable struct SolenoidParams <: EleParams Ksol::Number = 0.0 Bsol::Number = 0.0 end @@ -1032,7 +995,7 @@ end # TrackingParams """ - mutable struct TrackingParams <: EleParameterParams + mutable struct TrackingParams <: EleParams Sets the nominal values for tracking prameters. @@ -1042,7 +1005,7 @@ Sets the nominal values for tracking prameters. """ TrackingParams -@kwdef mutable struct TrackingParams <: EleParameterParams +@kwdef mutable struct TrackingParams <: EleParams num_steps::Int = -1 ds_step::Number = NaN end @@ -1053,13 +1016,13 @@ end # TwissParams """ - mutable struct TwissParams <: EleParameterParams + mutable struct TwissParams <: EleParams Lattice element parameter group storing Twiss, dispersion and coupling parameters for an element. """ TwissParams -@kwdef mutable struct TwissParams <: EleParameterParams +@kwdef mutable struct TwissParams <: EleParams a::Twiss1 = Twiss1() # a-mode b::Twiss1 = Twiss1() # b-mode x::Dispersion1 = Dispersion1() # x-axis diff --git a/src/traversal.jl b/src/traversal.jl index 7003729..921ed42 100644 --- a/src/traversal.jl +++ b/src/traversal.jl @@ -65,19 +65,19 @@ function Base.iterate(x::Region, ele::Ele) end #--------------------------------------------------------------------------------------------------- -# Base.iterate(::EleParameterParams), Base.length(::EleParameterParams) +# Base.iterate(::EleParams), Base.length(::EleParams) """ - Base.length(::EleParameterParams) - Base.iterate(::EleParameterParams) + Base.length(::EleParams) + Base.iterate(::EleParams) -Define `length` and `iterate` for `EleParameterParams` structs so can use `collect` with these structs. -""" Base.iterate(::EleParameterParams), Base.length(::EleParameterParams) +Define `length` and `iterate` for `EleParams` structs so can use `collect` with these structs. +""" Base.iterate(::EleParams), Base.length(::EleParams) -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 +Base.length(x::Type{T}) where T <: EleParams = 1 +Base.iterate(x::Type{T}) where T <: EleParams = (x, x) +Base.iterate(x::Type{T}, y) where T <: EleParams = nothing #--------------------------------------------------------------------------------------------------- # collect(::Branch) diff --git a/src/utilities.jl b/src/utilities.jl index 2ee0ec9..6265fa4 100644 --- a/src/utilities.jl +++ b/src/utilities.jl @@ -34,13 +34,13 @@ end # Base.isless """ - Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParameterParams, T2 <: EleParameterParams} -> Bool + Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParams, T2 <: EleParams} -> 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 <: EleParameterParams, T2 <: EleParameterParams} +function Base.isless(a::Type{T1}, b::Type{T2}) where {T1 <: EleParams, T2 <: EleParams} return Symbol(a) < Symbol(b) end diff --git a/test/ToDo.list b/test/ToDo.list index ca0e3cd..ed026d3 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 EleParameterParams items. +* Test that PARAM_GROUPS_LIST values are arrays of EleParams items. * Test that Param_group_info keys cover all parameter groups. \ No newline at end of file