diff --git a/src/enum.jl b/src/enum.jl index 75e4aa4..81649dd 100644 --- a/src/enum.jl +++ b/src/enum.jl @@ -23,14 +23,15 @@ end @enumit("BendType SECTOR RECTANGULAR") @enumit("BodyLoc ENTRANCE_END CENTER EXIT_END BOTH_ENDS NOWHERE EVERYWHERE") @enumit("BranchGeometry OPEN CLOSED") -## @enumit("EleGeometry STRAIGHT CIRCULAR ZEROLENGTH PATCH GIRDER CRYSTAL MIRROR") +## @enumit("EleGeometry STRAIGHT CIRCULAR ZEROLENGTH PATCH GIRDER CRYSTAL MIRROR") # See core.jl @enumit("Cavity STANDING_WAVE TRAVELING_WAVE") @enumit("SlaveControl DELTA ABSOLUTE NOT_SET") @enumit("FieldCalc MAP STANDARD") @enumit("Interpolation LINEAR SPLINE") @enumit("Lord NOT SUPER MULTIPASS GOVERNOR") @enumit("Slave NOT SUPER MULTIPASS") -@enumit("StreamLoc UPSTREAM_END CENTER INSIDE DOWNSTREAM_END") +@enumit("Loc UPSTREAM_END CENTER INSIDE DOWNSTREAM_END") +@enumit("Select UPSTREAM DOWNSTREAM") @enumit("TrackingMethod RUNGE_KUTTA TIME_RUNGE_KUTTA STANDARD") @enumit("ParticleState PREBORN ALIVE PRETRACK LOST LOST_NEG_X LOST_POS_X LOST_NEG_Y LOST_POS_Y LOST_PZ LOST_Z") diff --git a/src/find.jl b/src/find.jl index 2368a72..2c67d12 100644 --- a/src/find.jl +++ b/src/find.jl @@ -40,7 +40,7 @@ function ele_at_offset(reference::Union{Ele,Branch}, offset::Int, wrap::Bool) error("Non-zero offset ($offset) not allowed for Governor reference elements ($reference.name).") elseif branch.type == SuperLordBranch - if offset > 0 ? ref = reference.slaves[end] : ref = reference.slaves[1]; end + offset > 0 ? ref = reference.slaves[end] : ref = reference.slaves[1] branch = ref.branch indx = ref.ix_ele + offset @@ -305,7 +305,7 @@ end # ele_at_s """ - ele_at_s(branch::Branch, s::Real; choose::StreamLoc.T = StreamLoc.UPSTREAM_END, ele_near::ELE = NULL_ELE) + ele_at_s(branch::Branch, s::Real; select::Select.T = Select.UPSTREAM, ele_near::ELE = NULL_ELE) -> ele_overlap::Ele Returns lattice element `ele_overlap` that overlaps a given longitudinal s-position. @@ -315,9 +315,9 @@ That is, `s` will be in the interval `[ele_overlap.s, ele_overlap.s_downstream]` - `branch` Lattice `Branch` to search. - `s` Longitudinal position to match to. - - `choose` If there is a choice of elements, which can happen if `s` corresponds to a boundary - point between two elements, `choose` is used to pick either the `StreamLoc.UPSTREAM_END` - element (default) or `StreamLoc.DOWNSTREAM_END` element. + - `select` If there is a choice of elements, which can happen if `s` corresponds to a boundary + point between two elements, `select` is used to pick either the `Select.UPSTREAM` + element (default) or `Select.DOWNSTREAM` element. - `ele_near` If there are elements with negative drift lengths (generally this will be a `drift` or `patch` element), there might be multiple solutions. If `ele_near` is specified, this routine will choose the solution nearest `ele_near`. @@ -328,9 +328,9 @@ That is, `s` will be in the interval `[ele_overlap.s, ele_overlap.s_downstream]` """ ele_at_s -function ele_at_s(branch::Branch, s::Real; choose::StreamLoc.T = StreamLoc.UPSTREAM_END, ele_near::Ele = NULL_ELE) +function ele_at_s(branch::Branch, s::Real; select::Select.T = Select.UPSTREAM, ele_near::Ele = NULL_ELE) check_if_s_in_branch_range(branch, s) - if choose != StreamLoc.UPSTREAM_END && choose != StreamLoc.DOWNSTREAM_END; error("Bad `choose` argument: $choose"); end + if select != Select.UPSTREAM && select != Select.DOWNSTREAM; error("Bad `select` argument: $select"); end # If ele_near is not set if is_null(ele_near) @@ -340,11 +340,11 @@ function ele_at_s(branch::Branch, s::Real; choose::StreamLoc.T = StreamLoc.UPSTR while true if n3 == n1 + 1; break; end n2 = div(n1 + n3, 2) - s < branch.ele[n2].s || (choose == StreamLoc.UPSTREAM_END && branch.ele[n2].s == s) ? n3 = n2 : n1 = n2 + s < branch.ele[n2].s || (select == Select.UPSTREAM && branch.ele[n2].s == s) ? n3 = n2 : n1 = n2 end # Solution is n1 except in one case. - if choose == StreamLoc.DOWNSTREAM_END && branch.ele[n3].s == s + if select == Select.DOWNSTREAM && branch.ele[n3].s == s return branch.ele[n3] else return branch.ele[n1] @@ -354,19 +354,19 @@ function ele_at_s(branch::Branch, s::Real; choose::StreamLoc.T = StreamLoc.UPSTR # If ele_near is used ele = ele_near if ele.branch.type <: LordBranch - choose == StreamLoc.DOWNSTREAM_END ? ele = ele.slaves[end] : ele = ele.slaves[1] + select == Select.DOWNSTREAM ? ele = ele.slaves[end] : ele = ele.slaves[1] end - if s > ele.s_downstream || (choose == StreamLoc.DOWNSTREAM_END && s == ele.s_downstream) + if s > ele.s_downstream || (select == Select.DOWNSTREAM && s == ele.s_downstream) while true ele = next_ele(ele) - if s < ele.s_downstream || (s == ele.s_downstream && choose == StreamLoc.UPSTREAM_END); return ele; end + if s < ele.s_downstream || (s == ele.s_downstream && select == Select.UPSTREAM); return ele; end end else while true - if s > ele.s || (choose == StreamLoc.DOWNSTREAM_END && ele.s == s); return ele; end + if s > ele.s || (select == Select.DOWNSTREAM && ele.s == s); return ele; end ele = next_ele(ele, -1) end end diff --git a/src/manipulation.jl b/src/manipulation.jl index 0b6dc1c..6a7e978 100644 --- a/src/manipulation.jl +++ b/src/manipulation.jl @@ -92,7 +92,7 @@ end # split! """ - split!(branch::Branch, s_split::Real; choose::StreamLoc.T = StreamLoc.UPSTREAM_END, ele_near::Ele = NULL_ELE) + split!(branch::Branch, s_split::Real; select::Select.T = Select.UPSTREAM, ele_near::Ele = NULL_ELE) Routine to split an lattice element of a branch into two to create a branch that has an element boundary at the point s = `s_split`. @@ -110,13 +110,13 @@ than 2*`LatticeGlobal.significant_length`. ### Input - `branch` -- Lattice branch - `s_split` -- Position at which branch is to be split. -- `choose` -- logical, optional: If no splitting of an element is needed, that is, +- `select` -- logical, optional: If no splitting of an element is needed, that is, `s_split` is at an element boundary, there can be multiple possible `ele_split` elements to return if there exist zero length elements at the split location. - If `choose` = `StreamLoc.DOWNSTREAM_END`, the returned `ele_split` element will be chosen to be - at the maximal downstream element. If `choose` = `StreamLoc.UPSTREAM_END`, the returned `ele_split` element + If `select` = `Select.DOWNSTREAM`, the returned `ele_split` element will be chosen to be + at the maximal downstream element. If `select` = `Select.UPSTREAM`, the returned `ele_split` element will be chosen to be the maximal upstream location. - If `s_split` is not at an element boundary, the setting of `choose` is immaterial. + If `s_split` is not at an element boundary, the setting of `select` is immaterial. - `ele_near` -- Element near the point to be split. `ele_near` is useful in the case where there is a patch with a negative length which can create an ambiguity as to where to do the split In this case `ele_near` will remove the ambiguity. Also useful to ensure where to split if there @@ -127,18 +127,18 @@ than 2*`LatticeGlobal.significant_length`. - `split_done` -- true if lat was split, false otherwise. """ split!(branch::Branch) -function split!(branch::Branch, s_split::Real; choose::StreamLoc.T = StreamLoc.UPSTREAM_END, ele_near::Ele = NULL_ELE) +function split!(branch::Branch, s_split::Real; select::Select.T = Select.UPSTREAM, ele_near::Ele = NULL_ELE) check_if_s_in_branch_range(branch, s_split) - if choose != StreamLoc.UPSTREAM_END && choose != StreamLoc.DOWNSTREAM_END; error("Bad `choose` argument: $choose"); end - slave1 = ele_at_s(branch, s_split, choose = choose, ele_near = ele_near) + if select != Select.UPSTREAM && select != Select.DOWNSTREAM; error("Bad `select` argument: $select"); end + slave1 = ele_at_s(branch, s_split, select = select, ele_near = ele_near) # Make sure split does create an element that is less than min_len in length. min_len = min_ele_length(branch.lat) - if choose == StreamLoc.UPSTREAM_END && slave1.s > s_split-min_len - slave1 = ele_at_s(branch, slave1.s, choose = StreamLoc.DOWNSTREAM_END) + if select == Select.UPSTREAM && slave1.s > s_split-min_len + slave1 = ele_at_s(branch, slave1.s, select = Select.DOWNSTREAM) s_split = slave1.s_downstream - elseif choose == StreamLoc.DOWNSTREAM_END && slave1.s_downstream < s_split+min_len - slave1 = ele_at_s(branch, slave1.s_downstream, choose = StreamLoc.DOWNSTREAM_END) + elseif select == Select.DOWNSTREAM && slave1.s_downstream < s_split+min_len + slave1 = ele_at_s(branch, slave1.s_downstream, select = Select.DOWNSTREAM) s_split = slave1.s end diff --git a/src/parameters.jl b/src/parameters.jl index 841a3b2..3faeb96 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -162,7 +162,7 @@ ele_param_info_dict = Dict( :psi_floor => ParamInfo(FloorPositionGroup, Number, "Element floor psi angle orientation", "rad", :psi), :origin_ele => ParamInfo(GirderGroup, Ele, "Coordinate reference element."), - :origin_ele_ref_pt => ParamInfo(GirderGroup, StreamLoc.T, "Reference location on reference element. Default is StreamLoc.CENTER."), + :origin_ele_ref_pt => ParamInfo(GirderGroup, Loc.T, "Reference location on reference element. Default is Loc.CENTER."), :dr_girder => ParamInfo(GirderGroup, Vector{Number}, "3-vector of girder position with respect to ref ele.", "m", :dr), :dtheta_girder => ParamInfo(GirderGroup, Number, "Theta angle orientation with respect to ref ele.", "rad", :dtheta), :dphi_girder => ParamInfo(GirderGroup, Number, "Phi angle orientation with respect to ref ele.", "rad", :dphi), diff --git a/src/query.jl b/src/query.jl index 11a2064..d363286 100644 --- a/src/query.jl +++ b/src/query.jl @@ -2,7 +2,7 @@ # machine_location """ - machine_location(loc::BodyLoc.T, orientation::Int)::StreamLoc.T + machine_location(loc::BodyLoc.T, orientation::Int)::Loc.T Given a location with respect to an element's `local` orientation and the element's `orientation`, return the equivalent location in machine coordinates. @@ -17,16 +17,16 @@ The reverse function is body_location. ### Output - - Returns: `StreamLoc.UPSTREAM_END`, `StreamLoc.CENTER`, or `StreamLoc.DOWNSTREAM_END` (a `StreamLoc.T` value). + - Returns: `Loc.UPSTREAM_END`, `Loc.CENTER`, or `Loc.DOWNSTREAM_END` (a `Loc.T` value). """ machine_location -function machine_location(loc::BodyLoc.T, orientation::Int)::StreamLoc.T - if loc == BodyLoc.CENTER; return StreamLoc.CENTER; end +function machine_location(loc::BodyLoc.T, orientation::Int)::Loc.T + if loc == BodyLoc.CENTER; return Loc.CENTER; end if loc == BodyLoc.ENTRANCE_END - orientation == 1 ? (return StreamLoc.UPSTREAM_END) : return StreamLoc.DOWNSTREAM_END + orientation == 1 ? (return Loc.UPSTREAM_END) : return Loc.DOWNSTREAM_END elseif loc == BodyLoc.EXIT_END - orientation == 1 ? (return StreamLoc.DOWNSTREAM_END) : return StreamLoc.UPSTREAM_END + orientation == 1 ? (return Loc.DOWNSTREAM_END) : return Loc.UPSTREAM_END else error(f"loc argument values limited to `BodyLoc.ENTRANCE_END`, `BodyLoc.CENTER`, or `BodyLoc.EXIT_END`. Not: {loc}") end @@ -36,7 +36,7 @@ end # body_location """ - body_location(loc::StreamLoc.T, orientation::Int)::BodyLoc.T + body_location(loc::Loc.T, orientation::Int)::BodyLoc.T Given an element location with respect to machine coordinates, along with the element's orientation with respect to machine coordinates, @@ -46,20 +46,20 @@ The reverse function is machine_location. ### Input - - `loc` Possible values: `StreamLoc.UPSTREAM_END`, `StreamLoc.CENTER`, or `StreamLoc.DOWNSTREAM_END` . + - `loc` Possible values: `Loc.UPSTREAM_END`, `Loc.CENTER`, or `Loc.DOWNSTREAM_END` . - `orientation` Possible values: -1 or +1. ### Output - - Returns: `BodyLoc.entrance_end`, `StreamLoc.CENTER`, `BodyLoc.EXIT_END`. + - Returns: `BodyLoc.entrance_end`, `Loc.CENTER`, `BodyLoc.EXIT_END`. """ body_location -function body_location(loc::StreamLoc.T, orientation::Int) - if loc == StreamLoc.CENTER; return b_enter; end +function body_location(loc::Loc.T, orientation::Int) + if loc == Loc.CENTER; return b_enter; end - if loc == StreamLoc.UPSTREAM_END + if loc == Loc.UPSTREAM_END orientation == 1 ? (return BodyLoc.ENTRANCE_END) : return BodyLoc.EXIT_END - elseif loc == StreamLoc.DOWNSTREAM_END + elseif loc == Loc.DOWNSTREAM_END orientation == 1 ? (return BodyLoc.EXIT_END) : return BodyLoc.ENTRANCE_END else error(f"ConfusedError: Should not be here! Please report this!") diff --git a/src/struct.jl b/src/struct.jl index a8584e5..e877abe 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -343,7 +343,7 @@ end @kwdef mutable struct BeamBeamGroup <: EleParameterGroup n_slice::Number = 1 - z0_crossing::Number = 0 # Weak particle phase space z when strong beam StreamLoc.CENTER passes + z0_crossing::Number = 0 # Weak particle phase space z when strong beam Loc.CENTER passes # the BeamBeam element. repetition_freq:: Number = 0 # Strong beam repetition rate. twiss::Twiss = Twiss() # Strong beam Twiss. @@ -477,7 +477,7 @@ Girder parameter struct. """ @kwdef mutable struct GirderGroup <: EleParameterGroup origin_ele::Ele = NullEle - origin_ele_ref_pt::StreamLoc.T = StreamLoc.CENTER + origin_ele_ref_pt::Loc.T = Loc.CENTER dr::Vector = [0.0, 0.0, 0.0] dtheta::Number = 0.0 dphi::Number = 0.0 diff --git a/src/superimpose.jl b/src/superimpose.jl index 32e8c38..67e420f 100644 --- a/src/superimpose.jl +++ b/src/superimpose.jl @@ -48,7 +48,7 @@ Thus, a positive `offset` will displace the superposition location downstream if a normal orientation and vice versa for a reversed orientation. - When `offset` = 0, for zero length `super_ele` elements the superposition location is at the -entrance end of `ref` except if `ref_origin` is set to `StreamLoc.DOWNSTREAM_END` in which case the +entrance end of `ref` except if `ref_origin` is set to `BodyLoc.EXIT_END` in which case the superposition location is at the exit end of `ref`. - The superimposed element will inherit the orientation of the `ref` element. @@ -87,11 +87,11 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE # Insertion of zero length element with zero offset at edge of an element. if L_super == 0 && offset == 0 - if machine_ref_origin == StreamLoc.UPSTREAM_END || (machine_ref_origin == StreamLoc.CENTER && ref_ele.L == 0) + if machine_ref_origin == Loc.UPSTREAM_END || (machine_ref_origin == Loc.CENTER && ref_ele.L == 0) ix_insert = max(ref_ix_ele, 2) insert!(branch, ix_insert, super_ele) continue - elseif machine_ref_origin == StreamLoc.DOWNSTREAM_END + elseif machine_ref_origin == Loc.DOWNSTREAM_END ix_insert = min(ref_ix_ele+1, length(ref_ele.branch.ele)) insert!(branch, ix_insert, super_ele) continue @@ -100,19 +100,19 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE # Super_ele end locations: s1 and s2. if branch.type <: LordBranch - if machine_ref_origin == StreamLoc.UPSTREAM_END; s1 = ref_ele.slaves[1].s - elseif machine_ref_origin == StreamLoc.CENTER; s1 = 0.5 * (ref_ele.slaves[1].s + ref_ele.slaves[end].s_downstream) + if machine_ref_origin == Loc.UPSTREAM_END; s1 = ref_ele.slaves[1].s + elseif machine_ref_origin == Loc.CENTER; s1 = 0.5 * (ref_ele.slaves[1].s + ref_ele.slaves[end].s_downstream) else; s1 = ref_ele.slaves[end].s_downstream end else # Not a lord branch - if machine_ref_origin == StreamLoc.UPSTREAM_END; s1 = ref_ele.s - elseif machine_ref_origin == StreamLoc.CENTER; s1 = 0.5 * (ref_ele.s + ref_ele.s_downstream) + if machine_ref_origin == Loc.UPSTREAM_END; s1 = ref_ele.s + elseif machine_ref_origin == Loc.CENTER; s1 = 0.5 * (ref_ele.s + ref_ele.s_downstream) else; s1 = ref_ele.s_downstream end end - if machine_ele_origin == StreamLoc.UPSTREAM_END; s1 = s1 + offset - elseif machine_ele_origin == StreamLoc.CENTER; s1 = s1 + offset - 0.5 * L_super + if machine_ele_origin == Loc.UPSTREAM_END; s1 = s1 + offset + elseif machine_ele_origin == Loc.CENTER; s1 = s1 + offset - 0.5 * L_super else; s1 = s1 + offset - L_super end @@ -120,8 +120,11 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE # If super_ele has zero length just insert it. if L_super == 0 - machine_ref_origin == StreamLoc.DOWNSTREAM_END ? choose = StreamLoc.UPSTREAM_END : choose = StreamLoc.DOWNSTREAM_END - ele_at, _ = split!(branch, s1, choose = choose, ele_near = ref_ele) + if machine_ref_origin == Loc.DOWNSTREAM_END + ele_at, _ = split!(branch, s1, select = Select.DOWNSTREAM, ele_near = ref_ele) + else + ele_at, _ = split!(branch, s1, select = Select.UPSTREAM, ele_near = ref_ele) + end insert!(branch, ele_at.ix_ele, super_ele) continue end @@ -149,8 +152,8 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE # Split points are chosen to avoid creating elements with non-zero length below the minimum. # And super_lord length will be adjusted accordingly. - ele1 = ele_at_s(branch, s1, choose = StreamLoc.UPSTREAM_END, ele_near = ref_ele) - ele2 = ele_at_s(branch, s2, choose = StreamLoc.DOWNSTREAM_END, ele_near = ref_ele) + ele1 = ele_at_s(branch, s1, select = Select.UPSTREAM, ele_near = ref_ele) + ele2 = ele_at_s(branch, s2, select = Select.DOWNSTREAM, ele_near = ref_ele) min_len = min_ele_length(branch.lat) @@ -170,11 +173,11 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE super_ele.L = super_ele.L + ele2.s_downstream - s2 end - # `choose` is set to minimize number of elements in the superposition region. + # `select` is set to minimize number of elements in the superposition region. # The superposition region is from beginning of ele1 to the beginning of ele2. - ele2, _ = split!(branch, s2, choose = StreamLoc.UPSTREAM_END) # Notice that s2 split must be done first! - ele1, _ = split!(branch, s1, choose = StreamLoc.DOWNSTREAM_END) + ele2, _ = split!(branch, s2, select = Select.UPSTREAM) # Notice that s2 split must be done first! + ele1, _ = split!(branch, s1, select = Select.DOWNSTREAM) # If there are just drifts here then no superimpose needed. # Note: In this case there cannot be wrap around. @@ -219,6 +222,7 @@ function superimpose!(super_ele::Ele, ref::T; ele_origin::BodyLoc.T = BodyLoc.CE ele2.L = ele.L ele2.pdict[:super_lords] = Vector{Ele}([lord1]) push!(lord1.slaves, ele2) + set_drift_slice_names(ele) elseif ele.slave_status != Slave.SUPER lord2 = ele diff --git a/src/tracking.jl b/src/tracking.jl index 95fb493..d75a8f2 100644 --- a/src/tracking.jl +++ b/src/tracking.jl @@ -19,5 +19,5 @@ abstract type AbstractTrackPoint end direction::Int = 1 time_dir::Float64 = 1 species::Species = Species("not_set") - location::StreamLoc.T = StreamLoc.UPSTREAM_END + location::Loc.T = Loc.UPSTREAM_END end diff --git a/test/find_test.jl b/test/find_test.jl index 638f419..0e4985a 100644 --- a/test/find_test.jl +++ b/test/find_test.jl @@ -20,36 +20,36 @@ fodo = beamline("fodo", [b1, s1, -2*ln1, m1, m1, ln2, reverse(qf), reverse(ln2), lat = expand("mylat", [(beginning, fodo), (beginning, ln2), ln3]); -#superimpose!(z2, lat.branch[3], offset = 0.1, ele_origin = BodyLoc.ENTRANCE_END) +superimpose!(z2, lat.branch[3], offset = 0.1, ele_origin = BodyLoc.ENTRANCE_END) superimpose!(z1, eles(lat, "1>>d#1"), offset = 0.1) +eles(lat, "z1+1") #--------------------------------------------------------------------------------------------------- # Notice element d2 has a negative length b = lat.branch[1] -if false @testset "ele_at_s" begin - @test ele_at_s(b, b.ele[4].s, choose = StreamLoc.UPSTREAM_END).ix_ele == 2 - @test ele_at_s(b, b.ele[4].s, choose = StreamLoc.DOWNSTREAM_END).ix_ele == 4 - @test ele_at_s(b, b.ele[end].s_downstream, choose = StreamLoc.UPSTREAM_END).ix_ele == length(b.ele)-1 - @test ele_at_s(b, b.ele[end].s_downstream, choose = StreamLoc.DOWNSTREAM_END).ix_ele == length(b.ele) - @test ele_at_s(b, b.ele[15].s, choose = StreamLoc.UPSTREAM_END, ele_near = b.ele[11]).ix_ele == 14 - @test ele_at_s(b, b.ele[15].s, choose = StreamLoc.DOWNSTREAM_END, ele_near = b.ele[11]).ix_ele == 15 - @test ele_at_s(b, b.ele[19].s, choose = StreamLoc.UPSTREAM_END, ele_near = b.ele[21]).ix_ele == 18 - @test ele_at_s(b, b.ele[19].s, choose = StreamLoc.DOWNSTREAM_END, ele_near = b.ele[21]).ix_ele == 19 + @test ele_at_s(b, b.ele[4].s, select = Select.UPSTREAM).ix_ele == 2 + @test ele_at_s(b, b.ele[4].s, select = Select.DOWNSTREAM).ix_ele == 4 + @test ele_at_s(b, b.ele[end].s_downstream, select = Select.UPSTREAM).ix_ele == length(b.ele)-1 + @test ele_at_s(b, b.ele[end].s_downstream, select = Select.DOWNSTREAM).ix_ele == length(b.ele) + @test ele_at_s(b, b.ele[17].s, select = Select.UPSTREAM, ele_near = b.ele[11]).ix_ele == 16 + @test ele_at_s(b, b.ele[17].s, select = Select.DOWNSTREAM, ele_near = b.ele[11]).ix_ele == 17 + @test ele_at_s(b, b.ele[21].s, select = Select.UPSTREAM, ele_near = b.ele[21]).ix_ele == 20 + @test ele_at_s(b, b.ele[21].s, select = Select.DOWNSTREAM, ele_near = b.ele[21]).ix_ele == 21 end @testset "eles" begin - @test [e.ix_ele for e in eles(lat, "d")] == [4, 6, 18, 2] - @test [e.ix_ele for e in eles(lat, "Marker::*")] == [8, 9, 21, 5] - @test [e.ix_ele for e in eles(lat, "Marker::*-1")] == [7, 8, 20, 4] - @test [e.ix_ele for e in eles(lat, "m1#2")] == [9] - @test [e.ix_ele for e in eles(lat, "m1#2+1")] == [10] - @test [e.ix_ele for e in eles(lat.branch[4], "d")] == [2] - @test [(e.branch.ix_branch, e.ix_ele) for e in eles(lat, "multipass_lord>>d")] == [(4, 2)] - @test [e.ix_ele for e in eles(lat, "%d")] == [20, 1, 3] + @test [e.ix_ele for e in eles(lat, "d")] == [8, 20, 2] + @test [e.ix_ele for e in eles(lat, "Marker::*")] == [10, 11, 23, 5, 5, 8] + @test [e.ix_ele for e in eles(lat, "Marker::*-1")] == [9, 10, 22, 4, 4, 7] + @test [e.ix_ele for e in eles(lat, "m1#2")] == [11] + @test [e.ix_ele for e in eles(lat, "m1#2+1")] == [12] + @test [e.ix_ele for e in eles(lat.branch[5], "d")] == [2] + @test [(e.branch.ix_branch, e.ix_ele) for e in eles(lat, "multipass_lord>>d")] == [(5, 2)] + @test [e.ix_ele for e in eles(lat, "%d")] == [22, 1, 3] # @test [e.ix_ele for e in ] == [] # @test [e.ix_ele for e in ] == [] # @test [e.ix_ele for e in ] == [] @@ -62,5 +62,3 @@ end # @test [e.ix_ele for e in ] == [] # @test [e.ix_ele for e in ] == [] end - -end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index ffd9f8e..4e2717d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,17 +9,17 @@ using AcceleratorLattice, Test println("##### done (took $t seconds).") end - @testset "lat_construction_test" begin - println("##### Testing lat_construction_test.jl...") - t = @elapsed include("lat_construction_test.jl") - println("##### done (took $t seconds).") - end +# @testset "lat_construction_test" begin +# println("##### Testing lat_construction_test.jl...") +# t = @elapsed include("lat_construction_test.jl") +# println("##### done (took $t seconds).") +# end - @testset "superimpose_test" begin - println("##### Testing superimpose_test.jl...") - t = @elapsed include("superimpose_test.jl") - println("##### done (took $t seconds).") - end +# @testset "superimpose_test" begin +# println("##### Testing superimpose_test.jl...") +# t = @elapsed include("superimpose_test.jl") +# println("##### done (took $t seconds).") +# end println("##### Running all AcceleratorLattice tests took $(time() - t0) seconds.") end