48 "The \"TWISS\" command defines a table of lattice functions\n"
49 "which can be matched or tabulated over a periodic line.") {
51 (
"MICADO",
"Number of iterations for MICADO algorithm", 0.0);
53 (
"CORRECTORS",
"Number of correctors for MICADO algorithm", 0.0);
55 (
"THREAD",
"Name of method for closed orbit threader");
57 (
"TOLQ",
"Tolerance for positions in closed orbit threader", 1.0
e-3);
59 (
"TOLP",
"Tolerance for momenta in closed orbit threader", 1.0
e-3);
63 (
"CIRCUM",
"Circumference in m");
67 (
"FREQ0",
"Revolution frequency in Hz");
71 (
"Q1",
"Tune for mode 1");
75 (
"Q2",
"Tune for mode 2");
79 (
"Q3",
"Tune for mode 3");
83 (
"U0",
"Energy loss per turn in MeV");
87 (
"J1",
"Damping partition number for mode 1");
91 (
"J2",
"Damping partition number for mode 2");
95 (
"J3",
"Damping partition number for mode 3");
99 (
"DELTAP",
"Differential momentum variation");
116 return new Period(name,
this);
136 for(
int i = 0; i < 6; ++i) map[i][0] = 0.0;
151 for(
int i =
order; i >= 3; --i) {
162 for(
int i =
order; i >= 3; --i) {
168 std::cerr <<
"\n### Warning ### Momentum is not constant, "
169 <<
"Twiss is three-dimensional.\n" <<
std::endl;
180 double arc =
getS(row);
196 std::streamsize old_prec = os.precision(6);
197 os.setf(std::ios::fixed, std::ios::floatfield);
207 os <<
"Period length = " << setw(16)
209 <<
" Qx = " << setw(16) <<
getMUi(row, 0)
210 <<
" Qy = " << setw(16) <<
getMUi(row, 1)
212 <<
"DeltaP = " << setw(16)
214 <<
" BetaX(max) = " << setw(16)
216 <<
" BetaY(max) = " << setw(16)
219 <<
" x(max) = " << setw(16)
221 <<
" y(max) = " << setw(16)
224 <<
" x(rms) = " << setw(16)
226 <<
" y(rms) = " << setw(16)
229 <<
" Dx(max) = " << setw(16)
231 <<
" Dy(max) = " << setw(16)
234 <<
" Dx(rms) = " << setw(16)
236 <<
" Dy(rms) = " << setw(16)
240 os.precision(old_prec);
241 os.setf(std::ios::fixed, std::ios::floatfield);
247 static const int iteration_limit = 20;
248 static const double itsTolerance = 1.0e-8;
263 for(
int count = 0; count < iteration_limit; ++count) {
279 double errold = error;
288 if(mapAtEnd[5] == nrgy + deltap) {
291 for(
int i = 0; i < 4; i++) {
293 if(
abs(Error(i)) > error) error =
abs(Error(i));
295 for(
int i = 4; i < 6; i++) {
296 for(
int j = 0; j < 6; j++) A(i, j) = A(j, i) = 0.0;
303 for(
int i = 0; i < 6; i++) {
305 if(
abs(Error(i)) > error) error =
abs(Error(i));
323 if(count && (error == 0.0 || (error < itsTolerance && error >= errold)))
break;
void setReal(Attribute &attr, double val)
Set real value.
std::vector< Cell > CellArray
An array of cell descriptors.
virtual void fill()
Fill the buffer using the defined algorithm.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
Static fixed point of a Truncated power series map.
constexpr double e
The value of .
virtual void printTable(std::ostream &, const CellArray &) const
Print the table on an ASCII stream.
Period()
Exemplar constructor.
virtual Period * clone(const std::string &name)
Make clone.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
double getBeta() const
The relativistic beta per particle.
static LinearFun makeVariable(int var)
Make variable.
const FVps< double, N > & getFixedPoint() const
Get the transformation to the fixed point.
const FMatrix< double, N, N > & eigenVectors() const
Get eigenvectors of the linear part in packed form.
void printTableBody(std::ostream &, const CellArray &) const
Print the body to this TWISS table.
FMatrix< double, 6, 6 > curly_A
The initial curly A matrix.
double getMUi(const Row &, int i1, int=0) const
Three modes, "naive" Twiss functions.
FVector< T, N > constantTerm(const FVector< T, N > &P) const
Evaluate map at point [b]P[/b].
A templated representation of a LU-decomposition.
FVector< T, N > constantTerm() const
Extract the constant part of the map.
FVector< double, 6 > fixPoint
const FVps< double, N > & getFixedPointMap() const
Get the map around the fixed point.
constexpr double c
The velocity of light in m/s.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
const FTps< double, N > & normalisingMap() const
Get normalising map as a Lie transform.
void backSubstitute(FVector< T, N > &B) const
Back substitution.
FVps< T, N > ExpMap(const FTps< T, N > &H, int trunc=FTps< T, N >::EXACT)
Build the exponential series.
FVector< double, 6 > orbit
The initial closed orbit.
virtual void setMap(const LinearMap< double, 6 > &)=0
Reset the linear part of the accumulated map for restart.
Normal form of a truncated Taylor series map.
virtual void execute()
Apply the algorithm to the top-level beamline.
FMatrix< T, N, N > linearTerms() const
Extract the linear part of the map.
Structure for a row of the Twiss table.
FTps filter(int minOrder, int maxOrder, int trcOrder=EXACT) const
Extract given range of orders, with truncation.
const PartData * reference
AbstractMapper * itsMapper
FMatrix< T, N, N > linearTerms() const
Extract linear terms at origin.
void printTableTitle(std::ostream &, const char *title) const
Print standard information about the TWISS table.
Linear function in N variables of type T.
double getReal(const Attribute &attr)
Return real value.
FVps substitute(const FMatrix< T, N, N > &M, int n) const
Substitute.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
double getS(const Row &, int=0, int=0) const
Arc length for given row.
virtual void getMap(LinearMap< double, 6 > &) const =0
Return the linear part of the accumulated map.
Inform & endl(Inform &inf)