OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Twiss.h
Go to the documentation of this file.
1 #ifndef OPAL_Twiss_HH
2 #define OPAL_Twiss_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Twiss.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Twiss
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2001/08/13 15:25:22 $
17 // $Author: jowett $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "AbstractObjects/Table.h"
24 #include "Beamlines/TBeamline.h"
25 #include "FixedAlgebra/FMatrix.h"
26 #include "FixedAlgebra/FVector.h"
27 #include <iosfwd>
28 #include <vector>
29 
30 class AbstractMapper;
31 class Beam;
32 class PartData;
33 class PlaceRep;
34 class RangeRep;
35 
36 
38 // ------------------------------------------------------------------------
40 
41 class Twiss: public Table {
42 
43  friend class Insertion;
44  friend class Period;
45 
46 public:
47 
49  class Row: public FlaggedElmPtr {
50 
51  friend class Insertion;
52  friend class Period;
53  friend class Twiss;
54 
55  public:
56 
57  Row(ElementBase *, int);
58  explicit Row(const FlaggedElmPtr &);
59  ~Row();
60 
62  const FVector<double, 6> &getCO() const;
63 
65  const FMatrix<double, 6, 6> &getMatrix() const;
66 
68  double getS() const;
69 
71  double getMUi(int i) const;
72 
73  private:
74 
77 
80 
82  double arc;
83 
85  double mu[3];
86  };
87 
88  // The contained beamline type.
90 
91  virtual ~Twiss();
92 
94  // Version for constant table.
95  TLine::const_iterator begin() const;
96 
98  // Version for non-constant table.
100 
102  // Version for constant table.
103  TLine::const_iterator end() const;
104 
106  // Version for non-constant table.
108 
110  virtual void execute();
111 
113  virtual double getCell(const PlaceRep &row, const std::string &col);
114 
116  virtual CellArray getDefault() const;
117 
119  virtual std::vector<double>
120  getColumn(const RangeRep &range, const std::string &col);
121 
123  const Row &getCurrent() const;
124 
126  double getEX() const;
127 
129  double getEY() const;
130 
132  double getET() const;
133 
135  virtual double getLength();
136 
138  virtual const Beamline *getLine() const;
139 
141  virtual std::vector<double>
142  getRow(const PlaceRep &, const std::vector<std::string> &);
143 
145  // Return true, if this table depends on the named object.
146  virtual bool isDependent(const std::string &name) const;
147 
149  // Return an expression which denotes a column of the twiss table,
150  // identified by its name.
152  makeColumnExpression(const std::string &colName) const;
153 
155  // True, if [b]rhs[/b] is derived from [b]Twiss[/b].
156  virtual bool matches(Table *rhs) const;
157 
159  void printTableBody(std::ostream &, const CellArray &) const;
160 
162  void printTableTitle(std::ostream &, const char *title) const;
163 
164  // Access to items in the table.
165  // ----------------------------------------------------------------------
168 
170  FMatrix<double, 6, 6> getCurlyA(const Row &) const;
171 
173  FMatrix<double, 6, 6> getMatrix(const Row &) const;
174 
177 
179  FVector<double, 6> getOrbit(const Row &) const;
180 
183 
185  FMatrix<double, 6, 6> getSigma(const Row &) const;
186 
187 
189  double getS(const Row &, int = 0, int = 0) const;
190 
192  // Index (0 ... 2) is mode.
193  double getMUi(const Row &, int i1, int = 0) const;
194  double getBETi(const Row &, int i1, int = 0) const;
195  double getALFi(const Row &, int i1, int = 0) const;
196 
198  // First index (0 ... 2) is plane, second index (0 ... 2) is mode.
199  double getBETik(const Row &, int i1, int i2) const;
200 
202  // First index (0 ... 2) is plane, second index (0 ... 2) is mode.
203  double getALFik(const Row &, int i1, int i2) const;
204 
206  // First index (0 ... 2) is plane, second index (0 ... 2) is mode.
207  double getGAMik(const Row &, int i1, int i2) const;
208 
210  // Index (0 ... 5) is plane.
211  double getCO(const Row &, int i1, int = 0) const;
212 
214  // Index (0 ... 5) is plane.
215  double getDisp(const Row &, int i1, int = 0) const;
216 
218  // First index (0 ... 5) is plane, second index (0 ... 5) is column.
219  double getEigen(const Row &, int i1, int i2) const;
220 
222  // Both indices (0 ... 5) refer to planes.
223  double getSigma(const Row &, int i1, int i2) const;
224 
226  // First index (0 ... 5) is row, second index (0 ... 5) is column.
227  double getMatrix(const Row &, int i1, int i2) const;
228 
229 protected:
230 
232  // Must be accessible to classes Insertion and Period.
233  enum {
234  // User-definable attributes:
235  LINE, // The beam line for the table,
236  BEAM, // The beam to be used.
237  RANGE, // The range in the lattice.
238  ORDER, // The order for the calculation.
239  STATIC, // The flag for suppressing recalculation.
240  METHOD, // the algorithm for filling
241  REVBEAM, // If true, beam runs backwrads.
242  REVTRACK, // If true, track lattice functions against the beam.
243 
244  // Read-only attributes:
245  BETXMAX, // Maximum beta functions
247  XCMAX, // Maximum closed orbit excursion
249  XCRMS, // R.M.S. closed orbit excursion
251  DXMAX, // Maximum dispersion
253  DXRMS, // R.M.S. dispersion
256  };
257 
259  Twiss(int size, const char *name, const char *help);
260 
262  Twiss(const std::string &name, Twiss *parent);
263 
264 
266  static const int numColumns = 11;
267 
270 
273 
274 private:
275 
276  // Not implemented.
277  Twiss(const Twiss &);
278  void operator=(const Twiss &);
279 
280  // Return the table row.
281  Row &findRow(const PlaceRep &row);
282 
283  // This method is called to fill the table after initialising.
284  void put();
285 
286  // Access to current table row.
287  mutable TLine::const_iterator current;
288 
289  // The table contents.
291 
292  // Pointer to the filling algorithm.
294 
295  // The attached beam.
296  const Beam *beam;
297 
298  // The particle reference data.
300 
301  // The truncation order (1 for LINEAR, 2 for all other).
302  int order;
303 
304  // The direction flags.
305  bool revBeam; // true, if beam runs from right (s=C) to left (s=0).
306  bool revTrack; // true, if tracking against the beam.
307  bool revPath; // true, if tracking from right (s=C) to left (s=0).
308 
309  // The name of the analysed line.
310  std::string itsLine;
311 };
312 
313 #endif // OPAL_Twiss_HH
Build transfer map.
static const int numColumns
Number of table columns.
Definition: Twiss.h:266
virtual ~Twiss()
Definition: Twiss.cpp:476
bool revBeam
Definition: Twiss.h:305
std::vector< Cell > CellArray
An array of cell descriptors.
Definition: Table.h:63
virtual bool matches(Table *rhs) const
Check compatibility.
Definition: Twiss.cpp:781
virtual bool isDependent(const std::string &name) const
Check dependency.
Definition: Twiss.cpp:760
virtual Expressions::PtrToScalar< double > makeColumnExpression(const std::string &colName) const
Return column expression.
Definition: Twiss.cpp:775
TLine::const_iterator current
Definition: Twiss.h:287
double arc
The accumulated arc length.
Definition: Twiss.h:82
Interface for basic beam line object.
Definition: ElementBase.h:128
double getET() const
Return emittance for mode 3.
Definition: Twiss.cpp:689
TLine::const_iterator end() const
Access to last row.
Definition: Twiss.cpp:561
double getEY() const
Return emittance for mode 2.
Definition: Twiss.cpp:684
FMatrix< double, 6, 6 > getSigma() const
Initial envelope (Sigma) matrix.
double getGAMik(const Row &, int i1, int i2) const
Mais-Ripken gamma functions.
Definition: Twiss.cpp:1210
bool revPath
Definition: Twiss.h:307
FVector< double, 6 > orbit
The closed orbit after the element.
Definition: Twiss.h:76
TLine::const_iterator begin() const
Access to first row.
Definition: Twiss.cpp:551
double mu[3]
Phases for the three modes.
Definition: Twiss.h:85
virtual std::vector< double > getRow(const PlaceRep &, const std::vector< std::string > &)
Return a table row, possible user-defined.
Definition: Twiss.cpp:738
Row(ElementBase *, int)
Definition: Twiss.cpp:369
double getBETik(const Row &, int i1, int i2) const
Mais-Ripken beta functions.
Definition: Twiss.cpp:1164
std::string itsLine
Definition: Twiss.h:310
The TWISS command.
Definition: Period.h:28
Particle reference data.
Definition: PartData.h:38
const FVector< double, 6 > & getCO() const
Closed orbit.
Definition: Twiss.cpp:384
Row & findRow(const PlaceRep &row)
Definition: Twiss.cpp:861
double getEigen(const Row &, int i1, int i2) const
Eigenvectors.
Definition: Twiss.cpp:1248
const Beam * beam
Definition: Twiss.h:296
TLine * itsTable
Definition: Twiss.h:290
const Row & getCurrent() const
Return current table row in iteration.
Definition: Twiss.cpp:664
void printTableBody(std::ostream &, const CellArray &) const
Print the body to this TWISS table.
Definition: Twiss.cpp:786
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
FMatrix< double, 6, 6 > curly_A
The initial curly A matrix.
Definition: Twiss.h:272
Twiss(int size, const char *name, const char *help)
Exemplar constructor.
Definition: Twiss.cpp:407
double getMUi(const Row &, int i1, int=0) const
Three modes, &quot;naive&quot; Twiss functions.
Definition: Twiss.cpp:1106
void operator=(const Twiss &)
FMatrix< double, 6, 6 > matrix
The transfer matrix up to and including the element.
Definition: Twiss.h:79
virtual CellArray getDefault() const
Return the default print columns.
Definition: Twiss.cpp:633
virtual std::vector< double > getColumn(const RangeRep &range, const std::string &col)
Return column [b]col[/b] of this table, limited by [b]range[/b].
Definition: Twiss.cpp:645
virtual double getLength()
Return the length of the table.
Definition: Twiss.cpp:694
virtual double getCell(const PlaceRep &row, const std::string &col)
Return a selected value in a selected row.
Definition: Twiss.cpp:626
virtual void execute()
Check validity of the table definition.
Definition: Twiss.cpp:566
double getBETi(const Row &, int i1, int=0) const
Definition: Twiss.cpp:1111
FVector< double, 6 > orbit
The initial closed orbit.
Definition: Twiss.h:269
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
Class Twiss.
Definition: Twiss.h:41
An abstract sequence of beam line components.
Definition: Beamline.h:37
double getDisp(const Row &, int i1, int=0) const
Dispersion.
Definition: Twiss.cpp:1234
const FMatrix< double, 6, 6 > & getMatrix() const
Transfer matrix.
Definition: Twiss.cpp:389
TBeamline< Row > TLine
Definition: Twiss.h:89
Structure for a row of the Twiss table.
Definition: Twiss.h:49
double getEX() const
Return emittance for mode 1.
Definition: Twiss.cpp:679
const PartData * reference
Definition: Twiss.h:299
AbstractMapper * itsMapper
Definition: Twiss.h:293
double getCO(const Row &, int i1, int=0) const
Closed orbit.
Definition: Twiss.cpp:1229
The BEAM definition.
Definition: Beam.h:35
const std::string name
double getS() const
Arc length.
Definition: Twiss.cpp:394
int order
Definition: Twiss.h:302
void printTableTitle(std::ostream &, const char *title) const
Print standard information about the TWISS table.
Definition: Twiss.cpp:847
FMatrix< double, 6, 6 > getMatrix(const Row &) const
Accumulated transfer map.
Definition: Twiss.cpp:704
FMatrix< double, 6, 6 > getCurlyA() const
Return initial curly A matrix.
Definition: Twiss.cpp:669
virtual const Beamline * getLine() const
Return embedded CLASSIC beamline.
Definition: Twiss.cpp:699
std::string::iterator iterator
Definition: MSLang.h:16
double getALFik(const Row &, int i1, int i2) const
Mais-Ripken alpha functions.
Definition: Twiss.cpp:1183
bool revTrack
Definition: Twiss.h:306
FVector< double, 6 > getOrbit() const
Return initial closed orbit.
Definition: Twiss.cpp:714
The TWISSTRACK command.
Definition: Insertion.h:28
The base class for all OPAL tables.
Definition: Table.h:42
double getALFi(const Row &, int i1, int=0) const
Definition: Twiss.cpp:1137
double getS(const Row &, int=0, int=0) const
Arc length for given row.
Definition: Twiss.cpp:1101
void put()
Definition: Twiss.cpp:878
A section of a beam line.
Definition: FlaggedElmPtr.h:36
double getMUi(int i) const
Phase for mode i.
Definition: Twiss.cpp:399