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
12 changes: 6 additions & 6 deletions manual/coordinates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,17 @@ \section{Global Coordinates}
%
\item[$\theta(s)$ Azimuth (yaw) angle:]
Angle in the $(X, Z)$ plane between the $Z$--axis and the projection of the $z$--axis onto the $(X,
Z)$ plane. Corresponds to the \vn{y_rot} element attribute (\sref{s:offset}). A positive angle of
Z)$ plane. Corresponds to the \vn{y_rot} element parameter (\sref{s:offset}). A positive angle of
$\theta = \pi/2$ corresponds to the projected $z$--axis pointing in the negative $X$-direction.
%
\item[$\phi(s)$ Pitch (elevation) angle:]
Angle between the $z$--axis and the $(X,Z)$ plane. Corresponds to the \vn{x_rot} element attribute
Angle between the $z$--axis and the $(X,Z)$ plane. Corresponds to the \vn{x_rot} element parameter
(\sref{s:offset}). A positive angle of $\phi = \pi/2$ corresponds to the $z$--axis pointing in the
positive $Y$ direction.
%
\item[$\psi(s)$ Roll angle:]
Angle of the $x$--axis with respect to the line formed by the intersection of the $(X, Z)$ plane
with the $(x, y)$ plane. Corresponds to the \vn{tilt} element attribute (\sref{s:offset}). A
with the $(x, y)$ plane. Corresponds to the \vn{tilt} element parameter (\sref{s:offset}). A
positive $\psi$ forms a right--handed screw with the $z$--axis.
\end{description}

Expand Down Expand Up @@ -714,8 +714,8 @@ \subsection{Bend Element Misalignment Transformation}

\index{rbend!coordinate transformation}\index{sbend!coordinate transformation}
\index{roll!coordinate transformation}\index{tilt!coordinate transformation}
For \vn{rbend} and \vn{sbend} elements there is no \vn{tilt} attribute. Rather, there is the
\vn{roll} attribute and a \vn{ref_tilt} attribute. The latter affects both the reference orbit and
For \vn{rbend} and \vn{sbend} elements there is no \vn{tilt} parameter. Rather, there is the
\vn{roll} parameter and a \vn{ref_tilt} parameter. The latter affects both the reference orbit and
the bend position (\sref{s:bend.orient}). Furthermore, \vn{ref_tilt} is calculated with respect to
the coordinates at the beginning of the bend while, like straight elements, \vn{roll}, \vn{x_rot},
\vn{y_rot}, and offsets are calculated with respect to the center of the bend. The different reference frame used
Expand Down Expand Up @@ -821,7 +821,7 @@ \subsection{Reference Particle, Reference Energy, and Reference Time}
is equal to the reference energy. The energy of the particle at the downstream end is the reference
energy of the element. Note: Tracking through an element to determine the reference energy is always
done with the element turned on independent of the setting of the element's \vn{is_on}
(\sref{s:is.on}) parameter. Reference energy tracking is also done ignoring any orientation attributes
(\sref{s:is.on}) parameter. Reference energy tracking is also done ignoring any orientation parameters
(\sref{s:offset}) and errors like \vn{voltage_err}.

\index{wiggler!reference time}
Expand Down
8 changes: 4 additions & 4 deletions manual/multipass.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ \section{Multipass Fundamentals}
These types of elements are known as \vn{multipass_slave} elements. In
addition to the \vn{multipass_slave} elements there will be a \vn{multipass_lord} element (that doesn't
get tracked through) called \vn{RF1} in the \vn{multipass_lord} branch of the lattice (\sref{s:lord.slave}).
Changes to the attributes of the lord \vn{RF1} element will be passed to the slave elements by the \accellat
Changes to the parameters of the lord \vn{RF1} element will be passed to the slave elements by the \accellat
bookkeeping routines. Assuming that the phase of \vn{RF1!mp1} gives acceleration, to make \vn{RF1!mp2}
decelerate, the \vn{multipass_phase} attribute of \vn{RF1!mp2} is set to pi. This is the one attribute
that \accellat's bookkeeping routines will not touch when transferring attribute values from \vn{RF1} to
its slaves. Notice that the \vn{multipass_phase} attribute had to be set after the lattice is formed
decelerate, the \vn{multipass_phase} parameter of \vn{RF1!mp2} is set to pi. This is the one parameter
that \accellat's bookkeeping routines will not touch when transferring parameter values from \vn{RF1} to
its slaves. Notice that the \vn{multipass_phase} parameter had to be set after the lattice is formed
using the \vn{expand} function (\sref{s:expand}). This is true since
\vn{RF1!mp2} does not exist before the lattice is expanded. \vn{multipass_phase} is useful with
relative time tracking \sref{s:rf.time}. However, \vn{multipass_phase} is ``unphysical'' and is just
Expand Down
20 changes: 10 additions & 10 deletions manual/superimpose.tex
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ \section{Superposition on a Drift}
superimpose!(ss, ref_ele, offset = 0.2)
\end{example}

attribute of element \vn{S} superimposes \vn{S} over the lattice \vn{(Q,
parameter of element \vn{S} superimposes \vn{S} over the lattice \vn{(Q,
D)}. The placement of \vn{S} is such that the beginning of \vn{S} is coincident with the center of
\vn{Q} (this is is explained in more detail below). Additionally, a marker \vn{M} is superimposed at
a distance of +1~meter from the center of \vn{S}. The tracking part of the lattice
Expand Down Expand Up @@ -188,7 +188,7 @@ \section{Superposition on a Drift}

The placement of a superimposed element is illustrated in \fig{f:superimpose}. The placement of a
superimposed element is determined by three factors: An origin point on the superimposed element, an
origin point on the reference element, and an offset between the points. The attributes that
origin point on the reference element, and an offset between the points. The parameters that
determine these three quantities are:
\index{ref}\index{offset}
\index{ref_origin}\index{ele_origin}
Expand Down Expand Up @@ -237,7 +237,7 @@ \section{Superposition on a Drift}
The element begin superimposed may be any type of element except \vn{drift}, \vn{group},
\vn{overlay}, and \vn{girder} control elements. The reference element used to position a
superimposed element may be a \vn{group} or \vn{overlay} element as long as the \vn{group} or
\vn{overlay} controls the attributes of exactly one element. In this case, the controlled element is
\vn{overlay} controls the parameters of exactly one element. In this case, the controlled element is
used as the reference element.

\index{geometry}\index{open}
Expand Down Expand Up @@ -338,10 +338,10 @@ \section{Superposition on a Drift}
my_oct: octupole, ..., superimpose, ref = a_drft##2 ! This is an error
\end{example}

When the attributes of a super_slave are computed from the attributes of its super_lords, some types
of attributes may be ``missing''. For example, it is, in general, not possible to set appropriate
aperture attributes (\sref{s:limit}) of a super_slave if the lords of the slave have differing
aperture settings. When doing calculations, \bmad will use the corresponding attributes stored in
When the parameters of a super_slave are computed from the parameters of its super_lords, some types
of parameters may be ``missing''. For example, it is, in general, not possible to set appropriate
aperture parameters (\sref{s:limit}) of a super_slave if the lords of the slave have differing
aperture settings. When doing calculations, \bmad will use the corresponding parameters stored in
the lord elements to correctly calculate things.

When superposition is done in a line where there is \vn{element reversal} (\sref{s:ele.reverse}),
Expand Down Expand Up @@ -434,8 +434,8 @@ \section{Jumbo Super_Slaves}
\index{lord_pad1}\index{lord_pad2}
\vn{Q} and part of \vn{S} have been combined into a jumbo \vn{super_slave} named \vn{Q{\B}S}. Since
the \vn{super_lord} elements of a jumbo \vn{super_slave} may not completely span the slave two
attributes of each lord will be set to show the position of the lord within the slave. These two
attributes are
parameters of each lord will be set to show the position of the lord within the slave. These two
parameters are
\begin{example}
lord_pad1 ! offset at upstream end
lord_pad2 ! offset at downstream end
Expand Down Expand Up @@ -464,7 +464,7 @@ \section{Jumbo Super_Slaves}

\index{field_overlaps}
Another possible way to handle overlapping fields is to use the \vn{field_overlaps} element
attribute as discussed in \sref{s:overlap}.
parameter as discussed in \sref{s:overlap}.

%-----------------------------------------------------------------------------
\section{Changing Element Lengths when there is Superposition}
Expand Down
68 changes: 0 additions & 68 deletions src/core.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
#---------------------------------------------------------------------------------------------------
# holly_type

"""
holly_type(atype::AbstractString, ctypes::Vector)

Makes an abstract type from the first word and makes concrete types that inherit from the abstract type
from the other words in the string.
""" holly_type

function holly_type(atype::AbstractString, ctypes::Vector)
eval( Meta.parse("abstract type $atype end") )
eval( Meta.parse("export $atype") )

for ct in ctypes
eval( Meta.parse("struct $ct <: $atype; end") )
end
end

holly_type("EleGeometrySwitch", ["Straight", "Circular", "ZeroLength",
"PatchGeom", "GirderGeom", "CrystalGeom", "MirrorGeom"])

#---------------------------------------------------------------------------------------------------
# Exceptions

Expand All @@ -39,49 +17,3 @@ eval_str(str::AbstractString) = eval(Meta.parse(str))

field_names(x) = fieldnames(typeof(x))

#---------------------------------------------------------------------------------------------------
# it_ismutable & it_isimmutable

"""
function it_ismutable(x)

Work around for the problem that ismutable returns True for strings.
See: https://github.com/JuliaLang/julia/issues/30210
""" it_ismutable

function it_ismutable(x)
if typeof(x) <: AbstractString; return false; end
return ismutable(x)
end

"""
function it_isimmutable(x)

Work around for the problem that isimmutable returns True for strings.
See: https://github.com/JuliaLang/julia/issues/30210
""" it_isimmutable

function it_isimmutable(x)
if typeof(x) <: AbstractString; return true; end
return isimmutable(x)
end

#---------------------------------------------------------------------------------------------------

function integer(str::AbstractString, default::Number)
try
ix = parse(Int, str)
return ix
catch
return default
end
end

function float(str::AbstractString, default::Number)
try
flt = parse(Float, str)
return ix
catch
return default
end
end
31 changes: 26 additions & 5 deletions src/enum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ return `OPEN` and `CLOSED`.

macro enumit(str::AbstractString)
eval( Meta.parse("@enumx $str") )
str_split = split(str)
str2 = join(str_split, ',')
str_words = split(str)
str2 = join(str_words, ',')
eval( Meta.parse("export $str2") )
s = "Base.string(z::$(str_split[1]).T) = \"$(str_split[1]).\" * string(Symbol(z))"
if str_split[1] != "BranchGeometry"; eval( Meta.parse(s) ); end
s = "Base.string(z::$(str_words[1]).T) = \"$(str_words[1]).\" * string(Symbol(z))"
if str_words[1] != "BranchGeometry"; eval( Meta.parse(s) ); end
end

@enumit("ApertureShape RECTANGULAR ELLIPTICAL")
@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") # See core.jl
@enumit("Cavity STANDING_WAVE TRAVELING_WAVE")
@enumit("SlaveControl DELTA ABSOLUTE NOT_SET")
@enumit("FieldCalc MAP STANDARD")
Expand All @@ -42,3 +41,25 @@ CLOSED::BranchGeometry.T = BranchGeometry.CLOSED
OPEN::BranchGeometry.T = BranchGeometry.OPEN


#---------------------------------------------------------------------------------------------------
# holly_type

"""
holly_type(atype::AbstractString, ctypes::Vector)

Makes an abstract type from the first word and makes concrete types that inherit from the abstract type
from the other words in the string.
""" holly_type

function holly_type(atype::AbstractString, ctypes::Vector)
eval( Meta.parse("abstract type $atype end") )
eval( Meta.parse("export $atype") )

for ct in ctypes
eval( Meta.parse("struct $ct <: $atype; end") )
end
end

holly_type("EleGeometrySwitch", ["Straight", "Circular", "ZeroLength",
"PatchGeom", "GirderGeom", "CrystalGeom", "MirrorGeom"])

Loading
Loading