Skip to content

Commit

Permalink
Devel/106 (#190)
Browse files Browse the repository at this point in the history
* Minor Fork devel.
  • Loading branch information
DavidSagan authored Jan 31, 2025
1 parent 6aeed82 commit da1a20d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
18 changes: 16 additions & 2 deletions src/bookkeeper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,24 @@ function ele_paramgroup_bookkeeper!(ele::Ele, group::Type{ForkParams},
changed::ChangedLedger, previous_ele::Ele)
fg = ele.ForkParams
rg = ele.ReferenceParams
clear_changed!(ele, ForkParams)

to_ele = fg.to_ele
to_ele.ix_ele != 1 && return
if to_ele.ix_ele != 1
clear_changed!(ele, ForkParams)
return
end

# Transfer FloorPrams

if has_changed(ele, FloorParams)
to_ele.FloorParams = copy(ele.FloorPrams)
to_ele.pdict[:changed][FloorParams] = true
set_branch_min_max_changed!(to_ele.branch, 1)
end

# Transfer ReferenceParams

clear_changed!(ele, ForkParams)

if !fg.propagate_reference && !is_null(to_ele.species_ref) && (!isnan(to_ele.E_tot_ref) || !isnan(to_ele.pc_ref))
return
Expand Down
9 changes: 5 additions & 4 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ELE_PARAM_INFO_DICT = Dict(
:wall => ParamInfo(ApertureParams, Wall2D, "Wall defined by array of aperture vertices."),
:custom_aperture => ParamInfo(ApertureParams, Dict, "Custom aperture info."),

:inherit_s_from_fork => ParamInfo(BeginningParams, Bool, "Use the s-position at Fork for start of branch?"),
: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),
Expand Down Expand Up @@ -147,6 +148,10 @@ ELE_PARAM_INFO_DICT = Dict(
: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),

:subtype => ParamInfo(DescriptionParams, String, "Type of element."),
:ID => ParamInfo(DescriptionParams, String, "Identification name."),
:class => ParamInfo(DescriptionParams, String, "Classification of element."),

: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."),
Expand Down Expand Up @@ -223,10 +228,6 @@ ELE_PARAM_INFO_DICT = Dict(
:spin => ParamInfo(InitParticleParams, Vector{Number}, "Initial particle spin"),
:orbit => ParamInfo(InitParticleParams, Vector{Number}, "Initial particle position."),

: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.", ""),
:gamma => ParamInfo(Twiss1, Number, "Gamma Twiss parameter.", "1/m"),
Expand Down
2 changes: 1 addition & 1 deletion src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ show_column2 = Dict{Type{T} where T <: BaseEleParams, Dict{Symbol,Symbol}}(
),

DescriptionParams => Dict{Symbol,Symbol}(
:type => :ID,
:subtype => :ID,
),

Dispersion1 => Dict{Symbol,Symbol}(
Expand Down
2 changes: 1 addition & 1 deletion src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ These strings have no affect on tracking.
""" DescriptionParams

@kwdef mutable struct DescriptionParams <: EleParams
type::String = ""
subtype::String = ""
ID::String = ""
class::String = ""
end
Expand Down
10 changes: 5 additions & 5 deletions test/accessor_test.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using AcceleratorLattice, Test

@ele beginning = BeginningEle(s = 0.3, pc_ref = 1e7, species_ref = Species("electron"))
@ele qf = Quadrupole(L = 0.6, ID = "z1", type = "abc", class = "xyt")
@ele qf = Quadrupole(L = 0.6, ID = "z1", subtype = "abc", class = "xyt")
@ele d = Drift(L = 0.4);
@ele d2 = Drift(L = -1.5);
@ele d3 = Drift(L = 2);
@ele b1 = Bend(L = 1.2);
@ele s1 = Sextupole(type = "abc", Kn0 = 1, Ks1 = 2, Kn2L = 3, Ks3L = 4,
@ele s1 = Sextupole(subtype = "abc", Kn0 = 1, Ks1 = 2, Kn2L = 3, Ks3L = 4,
Bn4 = 5, Bs5 = 6, Bn6L = 7, Bs70L = 8,
En80 = 9, Es9 = 10, En10L = 11, Es11L = 12,
tilt2 = 20, Etilt2 = 30);
@ele z1 = Bend(L = 0.02);
@ele z2 = Sextupole(L = 2.2, type = "abc");
@ele m1 = Marker(type = "qf");
@ele z2 = Sextupole(L = 2.2, subtype = "abc");
@ele m1 = Marker(subtype = "qf");

bl = BeamLine
ln3 = bl([beginning, d, b1, m1, d3], name = "ln3")
Expand All @@ -29,7 +29,7 @@ bele = lat.branch[1].ele[1]
@test [s1.En80, s1.Es9, s1.En10L, s1.Es11L] == [9, 10, 11, 12]
@test [s1.tilt2, s1.Etilt2] == [20, 30]
@test [s1.integrated0, s1.integrated2, s1.Eintegrated80, s1.Eintegrated10] == [false, true, false, true]
@test [qf.ID, qf.type, qf.class] == ["z1", "abc", "xyt"]
@test [qf.ID, qf.subtype, qf.class] == ["z1", "abc", "xyt"]
@test lat.name == "honeybee"
@test lat.branch[1].name == "ln3"
@test ln3.name == "ln3"
Expand Down
6 changes: 3 additions & 3 deletions test/find_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ using AcceleratorLattice, Test
@ele d2 = Drift(L = -1.5);
@ele d3 = Drift(L = 2);
@ele b1 = Bend(L = 1.2);
@ele s1 = Sextupole(type = "abc");
@ele s1 = Sextupole(subtype = "abc");
@ele z1 = Bend(L = 0.02);
@ele z2 = Sextupole(L = 2.2, type = "abc");
@ele m1 = Marker(type = "qf");
@ele z2 = Sextupole(L = 2.2, subtype = "abc");
@ele m1 = Marker(subtype = "qf");

bl = BeamLine
ln3 = bl([beginning, d, b1, m1, d3], name = "ln3")
Expand Down

0 comments on commit da1a20d

Please sign in to comment.