Skip to content

Commit

Permalink
Changed TwissParams -> BeginningParams. (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Jan 5, 2025
1 parent eefb380 commit 2e7f65b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/AcceleratorLattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export EMultipole, EMultipoleParams, BendParams, ApertureParams, DescriptionPara
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 BeginningParams, 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
Expand Down
2 changes: 1 addition & 1 deletion src/accessor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ end
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
itself. However, for example, for the parameter `eta_a`, `group` will be a `BeginningParams` instance
and returned is the sub group `group.a`.
""" base_field(group::EleParams, pinfo::ParamInfo)

Expand Down
46 changes: 23 additions & 23 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ ELE_PARAM_INFO_DICT = Dict(
:wall => ParamInfo(ApertureParams, Wall2D, "Wall defined by array of aperture vertices."),
:custom_aperture => ParamInfo(ApertureParams, Dict, "Custom aperture info."),

:beta_a => ParamInfo(BeginningParams, Number, "A-mode beta Twiss parameter.", "m", nothing, :beta, :a),
:alpha_a => ParamInfo(BeginningParams, Number, "A-mode alpha Twiss parameter.", "", nothing, :alpha, :a),
:gamma_a => ParamInfo(BeginningParams, Number, "A-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :a),
:phi_a => ParamInfo(BeginningParams, Number, "A-mode betatron phase.", "rad", nothing, :phi, :a),

:beta_b => ParamInfo(BeginningParams, Number, "B-mode beta Twiss parameter.", "m", nothing, :beta, :b),
:alpha_b => ParamInfo(BeginningParams, Number, "B-mode alpha Twiss parameter.", "", nothing, :alpha, :b),
:gamma_b => ParamInfo(BeginningParams, Number, "B-mode gamma Twiss parameter.", "1/m", nothing, :gamma, :b),
:phi_b => ParamInfo(BeginningParams, Number, "B-mode betatron phase.", "rad", nothing, :phi, :b),

:eta_x => ParamInfo(BeginningParams, Number, "X-mode position dispersion.", "m", nothing, :eta, :x),
:etap_x => ParamInfo(BeginningParams, Number, "X-mode momentum dispersion.", "", nothing, :etap, :x),
:deta_ds_x => ParamInfo(BeginningParams, Number, "X-mode dispersion derivative.", "", nothing, :deta_ds, :x),

:eta_y => ParamInfo(BeginningParams, Number, "Y-mode position dispersion.", "m", nothing, :eta, :y),
:etap_y => ParamInfo(BeginningParams, Number, "Y-mode momentum dispersion.", "", nothing, :etap, :y),
:deta_ds_y => ParamInfo(BeginningParams, Number, "Y-mode dispersion derivative.", "", nothing, :deta_ds, :y),

:angle => ParamInfo(BendParams, Number, "Reference bend angle", "rad"),
:bend_field_ref => ParamInfo(BendParams, Number, "Reference bend field corresponding to g bending strength", "T"),
:g => ParamInfo(BendParams, Number, "Reference bend strength (1/rho)", "1/m"),
Expand Down Expand Up @@ -213,24 +231,6 @@ ELE_PARAM_INFO_DICT = Dict(
:eta => ParamInfo(Twiss1, Number, "Position dispersion.", "m"),
:etap => ParamInfo(Twiss1, Number, "Momentum dispersion.", ""),
:deta_ds => ParamInfo(Twiss1, Number, "Dispersion derivative.", ""),

: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(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(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(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
Expand Down Expand Up @@ -292,9 +292,9 @@ 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 TwissParams \\
• `beta_b` - maps to `b.beta` in a TwissParams \\
• `beta_c` - maps to `c.beta` in a TwissParams \\
• `beta_a` - maps to `a.beta` in a BeginningParams \\
• `beta_b` - maps to `b.beta` in a BeginningParams \\
• `beta_c` - maps to `c.beta` in a BeginningParams \\
• `beta` - maps to `beta` in a Twiss1Params \\
""" ele_param_struct_field_to_user_sym

Expand Down Expand Up @@ -613,7 +613,7 @@ 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],
BeginningEle => [base_group_list..., BeginningParams, InitParticleParams],
Bend => [BendParams, general_group_list...],
Collimator => [base_group_list...],
Converter => [base_group_list...],
Expand Down Expand Up @@ -665,7 +665,7 @@ ELE_PARAM_GROUP_INFO = Dict(
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),
BeginningParams => EleParamsInfo("Initial Twiss and coupling parameters.", false),
LengthParams => EleParamsInfo("Length and s-position parameters.", true),
LordSlaveStatusParams => EleParamsInfo("Element lord and slave status.", false),
MasterParams => EleParamsInfo("Contains field_master parameter.", false),
Expand Down
2 changes: 1 addition & 1 deletion src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}(
:eta => :etap,
),

TwissParams => Dict{Symbol,Symbol}(
BeginningParams => Dict{Symbol,Symbol}(
:beta_a => :beta_b,
:alpha_a => :alpha_b,
:gamma_a => :gamma_b,
Expand Down
11 changes: 5 additions & 6 deletions src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1010,23 +1010,22 @@ Sets the nominal values for tracking prameters.
ds_step::Number = NaN
end



#---------------------------------------------------------------------------------------------------
# TwissParams
# BeginningParams

"""
mutable struct TwissParams <: EleParams
mutable struct BeginningParams <: EleParams
Lattice element parameter struct storing Twiss, dispersion and coupling parameters
for an element.
""" TwissParams
""" BeginningParams

@kwdef mutable struct TwissParams <: EleParams
@kwdef mutable struct BeginningParams <: EleParams
a::Twiss1 = Twiss1() # a-mode
b::Twiss1 = Twiss1() # b-mode
x::Dispersion1 = Dispersion1() # x-axis
y::Dispersion1 = Dispersion1() # y-axis
inherit_s_from_fork::Bool = false
end

#---------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 2e7f65b

Please sign in to comment.