30 double det = -
pow(c_prim, 3) *
pow(s, 3) + 3 * c * s_prim *
pow(c_prim, 2)
31 *
pow(s, 2) - 3 *
pow(c, 2) * c_prim * s *
pow(s_prim, 2) +
pow(c, 3) *
pow(s_prim, 3);
33 M(0, 0) = (-c_prim * s *
pow(s_prim, 2) + c *
pow(s_prim, 3)) / det;
34 M(0, 1) = (-2 * c_prim *
pow(s, 2) * s_prim + 2 * c * s *
pow(s_prim, 2)) / det;
35 M(0, 2) = (-c_prim *
pow(s, 3) + c *
pow(s, 2) * s_prim) / det;
36 M(1, 0) = (-
pow(c_prim, 2) * s * s_prim + c * c_prim *
pow(s_prim, 2)) / det;
37 M(1, 1) = (-
pow(c_prim, 2) *
pow(s, 2) +
pow(c, 2) *
pow(s_prim, 2)) / det;
38 M(1, 2) = (-c * c_prim *
pow(s, 2) +
pow(c, 2) * s * s_prim) / det;
39 M(2, 0) = (-
pow(c_prim, 3) * s + c *
pow(c_prim, 2) * s_prim) / det;
40 M(2, 1) = (-2 * c *
pow(c_prim, 2) * s + 2 *
pow(c, 2) * c_prim * s_prim) / det;
41 M(2, 2) = (-
pow(c, 2) * c_prim * s +
pow(c, 3) * s_prim) / det;
55 int printWidth, printPrecision;
63 const ColDesc allColumns[] = {
73 const ColDesc defaultColumns[] = {
80 const ColDesc *findCol(
const MSplit &table,
const std::string &colName) {
81 for(
const ColDesc *col = allColumns; col->colName; ++col) {
82 if(colName == col->colName) {
89 "\" has no column named \"" + colName +
"\".");
104 Column(
const MSplit &tab,
const std::string &colName,
const ColDesc &desc);
106 Column(
const Column &);
113 virtual double evaluate()
const;
116 virtual void print(std::ostream &os,
int precedence = 99)
const;
122 const Column &operator=(
const Column &);
141 Column::Column(
const MSplit &tab,
const std::string &colName,
const ColDesc &desc):
142 itsTable(tab), colName(colName),
143 get(desc.get), ind_1(desc.ind_1), ind_2(desc.ind_2)
147 Column::Column(
const Column &rhs):
148 Expressions::Scalar<double>(rhs),
149 itsTable(rhs.itsTable), colName(rhs.colName),
150 get(rhs.get), ind_1(rhs.ind_1), ind_2(rhs.ind_2)
159 return new Column(*
this);
163 double Column::evaluate()
const {
164 return (itsTable.*
get)(itsTable.getCurrent(), ind_1, ind_2);
168 void Column::print(std::ostream &os,
int)
const {
176 Table(
SIZE,
"SPLIT",
"help"), itsTable() {
178 (
"LINE",
"The beam line use to filling");
180 (
"BEAM",
"The beam to be used",
"UNNAMED_BEAM");
182 (
"NSLICE",
"the number of slices of the interpolation inside the optic element", 10);
184 (
"STATIC",
"recalculation if static equal false",
true);
186 (
"FILE",
"Name of file to receive SPLIT output",
"SPLIT.dat");
192 Table(name, parent), itsTable(name)
198 return Interpol[ind].Beta_x;
201 return Interpol[ind].Beta_y;
204 return Interpol[ind].Alpha_x;
207 return Interpol[ind].Alpha_y;
210 return Interpol[ind].Disp_x;
213 return Interpol[ind].Disp_x_prim;
216 return Interpol[ind].Disp_y;
219 return Interpol[ind].Disp_y_prim;
240 for(
int i = 1;
i < nslice; ++
i) {
250 for(
int i = 1;
i < nslice; ++
i) {
259 double K = f.
normal(2) * 0.299792458;
286 double K = f.
normal(2) * 0.299792458;
298 ERRORMSG(
"MSplit::visitCyclotron(const Cyclotron &cy) not implemented");
312 double K = f.
normal(2) * 0.299792458;
364 if(
data.
type.compare(
"rbend") == 0) {
412 }
else if(
data.
type.compare(
"sbend") == 0) {
463 for(
int j = 1; j <= nslice - 1; ++j) {
489 for(
int j = 1; j <= nslice - 1; ++j) {
511 for(
int j = 1; j <= nslice - 1; ++j) {
532 for(
int j = 1; j <= nslice - 1; ++j) {
555 for(
int j = 1; j <= nslice - 1; ++j) {
577 for(
int j = 1; j <= nslice - 1; ++j) {
599 for(
int j = 0; j < nslice; ++j) {
637 ofstream outFile(file.c_str());
639 cerr <<
"MSplit: Cannot open output file."
644 outFile.setf(std::ios::scientific, std::ios::floatfield);
648 outFile <<
"@ DATE %s " << timer.
date() <<
endl;
649 outFile <<
"@ TIME %s " << timer.
time() <<
endl;
650 outFile <<
"@ ORIGIN %s OPAL_9.5/7\n";
651 outFile <<
"@ COMMENT %s " <<
endl;
653 outFile <<
"*" << setw(15) <<
"NAME" << setw(15) <<
"S"
654 << setw(15) <<
"L" << setw(15) <<
"angle" << setw(15) <<
"K1"
655 << setw(15) <<
"BETX" << setw(15) <<
"BETY" << setw(15)
656 <<
"ALFX" << setw(15) <<
"ALFY" << setw(15) <<
"DX"
658 << setw(15) <<
"DY" << setw(15) <<
"DPY" <<
endl;
660 outFile <<
"$" << setw(15) <<
"%23s" << setw(15) <<
"%e" << setw(15) <<
"%e"
661 << setw(15) <<
"%e" << setw(15) <<
"%e" << setw(15) <<
"%e"
662 << setw(15) <<
"%e" << setw(15) <<
"%e" << setw(15)
663 <<
"%e" << setw(15) <<
"%e" << setw(15) <<
"%e" << setw(15) <<
"%e"
664 << setw(15) <<
"%e" <<
endl;
686 const ColDesc *col = findCol(*
this, colName);
687 return (this->*(col->get))(row, col->ind_1, col->ind_2);
694 for(
const ColDesc *col = defaultColumns; col->colName; ++col) {
696 new Column(*
this, col->colName, *col);
697 columns.push_back(
Cell(expr, col->printWidth, col->printPrecision));
703 const ColDesc *col = findCol(*
this, colName);
706 std::vector<double> column;
708 for(A_Tline::const_iterator row =
begin(); row !=
end(); ++row) {
711 column.push_back((this->*(col->get))(*row, col->ind_1, col->ind_2));
719 std::vector<std::string> &cols) {
721 std::vector<double> result;
725 for(
const ColDesc *col = defaultColumns; col->colName != 0; ++col) {
726 result.push_back((this->*col->get)(row, col->ind_1, col->ind_2));
730 for(std::vector<std::string>::const_iterator iter = cols.begin();
731 iter != cols.end(); ++iter) {
732 const ColDesc *col = findCol(*
this, *iter);
733 result.push_back((this->*(col->get))(row, col->ind_1, col->ind_2));
741 if(
itsLine == name)
return true;
744 for(A_Tline::const_iterator row =
begin(); row !=
end(); ++row) {
745 if(row->getElement()->getName() ==
name)
return true;
753 const ColDesc *col = findCol(*
this, colname);
754 return new Column(*
this, colname, *col);
757 return new MSplit(name,
this);
772 std::ostringstream os;
773 os << row << std::ends;
774 throw OpalException(
"MSplit::findRow()",
"A_row \"" + os.str() +
775 "\" not found in twiss table \"" +
getOpalName() +
"\".");
virtual double getExitFaceRotation() const =0
Get exit pole face rotation.
std::vector< Cell > CellArray
An array of cell descriptors.
virtual BMultipoleField & getField() override=0
Get multipole expansion of field.
virtual void fill()=0
Refill the buffer.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
constexpr double e
The value of .
Interface for basic beam line object.
TLine::const_iterator end() const
Access to last row.
double normal(int) const
Get component.
double getBETYMAX(const A_row &, int i1=0, int i2=0) const
virtual std::vector< double > getColumn(const RangeRep &rng, const std::string &colName)
Return column [b]col[/b] of this table, limited by [b]range[/b].
virtual BMultipoleField & getField() override=0
Get multipole expansion of field.
A templated representation for matrices.
virtual Expressions::PtrToScalar< double > makeColumnExpression(const std::string &colname) const
virtual BMultipoleField & getField() override=0
Get multipole field.
T det(const AntiSymTenzor< T, 3 > &t)
Interface for a Cyclotron.
TLine::const_iterator begin() const
Access to first row.
double getBeta_y(int ind)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void leave(const FlaggedElmPtr &) const
Leave an element or line.
virtual bool matches(Table *rhs) const
Check that [b]rhs[/b] is of same type as [b]this[/b].
A simple arc in the XZ plane.
The base class for all OPAL exceptions.
virtual void applyDefault(const ElementBase &)
Tps< T > sin(const Tps< T > &x)
Sine.
virtual std::vector< double > getRow(const PlaceRep &pos, const std::vector< std::string > &cols)
Return a table row.
A_Tline::const_iterator end() const
virtual double getElementLength() const
Get design length.
void enter(const FlaggedElmPtr &) const
Enter an element or line.
virtual PlanarArcGeometry & getGeometry() override=0
Get SBend geometry.
virtual bool isDependent(const std::string &name) const
Find out if table depends on the object identified by [b]name[/b].
Tps< T > tan(const Tps< T > &x)
Tangent.
virtual double getEntryFaceRotation() const =0
Get pole entry face rotation.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
bool isActive() const
Return status.
bool dynamic
Flag dynamic table.
Interface for general multipole.
std::string date() const
Return date.
bool getBool(const Attribute &attr)
Return logical value.
bool isActive() const
Test for active range.
Tps< T > cosh(const Tps< T > &x)
Hyperbolic cosine.
virtual double getExitFaceRotation() const =0
Get exit pole face rotation.
double getBendAngle() const
Get angle.
Representation of a place within a beam line or sequence.
virtual double getLength()
Return the length of the table.
const std::string & getOpalName() const
Return object name.
void initialize()
Initialise data for search.
virtual void printTable(std::ostream &, const CellArray &) const
Print list for the table.
A_Tline::const_iterator begin() const
double getAlpha_y(int ind)
virtual Object * clone(const std::string &name)
Return a clone.
double skew(int) const
Get component.
FVector< double, 3 > Euler_y
virtual double getElementLength() const
Get design length.
virtual CellArray getDefault() const
Return the default print columns.
FVector< double, 3 > Euler_x
void enter(const FlaggedElmPtr &) const
Enter an element or line.
constexpr double c
The velocity of light in m/s.
static Beam * find(const std::string &name)
Find named BEAM.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
double getBeta_x(int ind)
double getDisp_x(int ind)
FVector< double, 2 > Dispy
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
static Table * find(const std::string &name)
Find named Table.
double getBETi(const Row &, int i1, int=0) const
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
void initialize()
Initialise data for search.
Representation of a range within a beam line or sequence.
void leave(const FlaggedElmPtr &) const
Leave an element or line.
virtual double getElementLength() const
Get element length.
An abstract sequence of beam line components.
std::vector< pt_interpol > Interpol
virtual double getElementLength() const
Get element length.
double getDisp(const Row &, int i1, int=0) const
Dispersion.
double getAlpha_x(int ind)
virtual void fill()
Refill the buffer.
Tps< T > sqrt(const Tps< T > &x)
Square root.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
virtual double getEntryFaceRotation() const =0
Get pole entry face rotation.
The geometry for a RBend element.
double getP() const
The constant reference momentum per particle.
A_row & findRow(const PlaceRep &row)
double getBETXMAX(const A_row &, int i1=0, int i2=0) const
The magnetic field of a multipole.
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
std::string time() const
Return time.
A_Tline::const_iterator current
const PartData & getReference() const
Return the embedded CLASSIC PartData.
void calcul(Twiss::TLine::iterator i, A_row &a, int order, Twiss *tp)
The base class for all OPAL objects.
Tps< T > cos(const Tps< T > &x)
Cosine.
virtual void visitCyclotron(const Cyclotron &)
Apply the algorithm to an cyclotron.
FVector< double, 2 > Dispx
void execute()
Apply the algorithm to the top-level beamline.
double getDisp_x_prim(int ind)
Attribute makeBool(const std::string &name, const std::string &help)
Make logical attribute.
Descriptor for printing a table cell.
virtual double getCell(const PlaceRep &place, const std::string &colName)
Return value in selected table cell.
virtual void append(const T &)
Append a T object.
virtual const Beamline * getLine() const
Return embedded CLASSIC beamline.
double getDisp_y(int ind)
const A_row & getCurrent() const
virtual RBendGeometry & getGeometry() override=0
Get RBend geometry.
virtual double getBendAngle() const
Get angle.
std::string::iterator iterator
double getReal(const Attribute &attr)
Return real value.
double getDisp_y_prim(int ind)
The base class for all OPAL tables.
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
double getALFi(const Row &, int i1, int=0) const
Attribute makeReal(const std::string &name, const std::string &help)
Make real attribute.
FMatrix< double, 6, 6 > Transf_mat
Tps< T > sinh(const Tps< T > &x)
Hyperbolic sine.
Inform & endl(Inform &inf)
A section of a beam line.
std::string getString(const Attribute &attr)
Get string value.