Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions manual/ele-anatomy.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions manual/ele-param-groups.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion manual/enums.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
Expand Down
2 changes: 1 addition & 1 deletion src/AcceleratorLattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/accessor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/bookkeeper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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`.
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/output_lat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

71 changes: 30 additions & 41 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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...],
Expand Down Expand Up @@ -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),
)

#---------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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)]...)

Loading
Loading