Commit 71e46b84 authored by Jianjun Yang's avatar Jianjun Yang
Browse files

add a parameter SUPERPOSE for CYCLOTRON element to determine whether all the...

add a parameter SUPERPOSE for CYCLOTRON element to determine whether all the 3D electric field maps should be superposed (true) or only one is used for any position(false). If it is false, the priorty of the field maps is determined by the sequence in RFMAPFNvector, i.e. the first one has highest priorty. This parameter is only for the TYPE=BANRF
parent b8972c83
......@@ -68,6 +68,7 @@ Cyclotron::Cyclotron(const Cyclotron &right):
tcr2_m(right.tcr2_m),
mbtc_m(right.mbtc_m),
slptc_m(right.slptc_m),
superpose_m(right.superpose_m),
RFfilename_m(right.RFfilename_m) {
Bfield.bfld = 0;
Bfield.dbt = 0;
......@@ -132,21 +133,9 @@ void Cyclotron::accept(BeamlineVisitor &visitor) const {
visitor.visitCyclotron(*this);
}
/**
*
*
* @param rinit initial set the radius of the beam (m)
*/
void Cyclotron::setRinit(double rinit) {
rinit_m = rinit;
}
/**
*
*
*
* @return get the initial radius of the beam (m)
*/
double Cyclotron::getRinit() const {
return rinit_m;
......@@ -189,6 +178,14 @@ void Cyclotron::setRfFrequ(vector<double> f) {
rffrequ_m = f;
}
void Cyclotron::setSuperpose(bool flag) {
superpose_m = flag;
}
bool Cyclotron::getSuperpose() const {
return superpose_m;
}
void Cyclotron::setSymmetry(double s) {
symmetry_m = s;
}
......@@ -452,29 +449,28 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &centroid, const double
return true;
}
if(myBFieldType_m == BANDRF) {
/*
The RF field is suppose to be
sampled on a cartesian grid
*/
// loop over all field maps and superpose fields
//The RF field is suppose to be sampled on a cartesian grid
vector<Fieldmap *>::const_iterator fi = RFfields_m.begin();
vector<double>::const_iterator rffi = rffrequ_m.begin();
vector<double>::const_iterator rfphii = rfphi_m.begin();
vector<double>::const_iterator escali = escale_m.begin();
double xBegin(0), xEnd(0), yBegin(0), yEnd(0), zBegin(0), zEnd(0);
int fcount = 0;
for(; fi != RFfields_m.end(); ++fi, ++rffi, ++rfphii, ++escali, ++fcount) {
Vector_t tmpE(0.0, 0.0, 0.0), tmpB(0.0, 0.0, 0.0);
if(!(*fi)->getFieldstrength(R, tmpE, tmpB)) {
double phase = 2.0 * pi * 1E-3 * (*rffi) * t + *rfphii;
double ebscale = *escali;
E += ebscale * cos(phase) * tmpE;
B -= ebscale * sin(phase) * tmpB;
//INFOMSG("Field " << fcount << " BANDRF E= " << tmpE << " f= " << *rffi << " phi " << *rfphii << endl);
}
}
(*fi)->getFieldDimensions(xBegin, xEnd, yBegin, yEnd, zBegin, zEnd);
if (R(0) >= xBegin && R(0) <= xEnd && R(1) >= yBegin && R(1) <= yEnd && R(2) >= zBegin && R(2) <= zEnd) {
Vector_t tmpE(0.0, 0.0, 0.0), tmpB(0.0, 0.0, 0.0);
if(!(*fi)->getFieldstrength(R, tmpE, tmpB)) {
double phase = 2.0 * pi * 1E-3 * (*rffi) * t + *rfphii;
double ebscale = *escali;
E += ebscale * cos(phase) * tmpE;
B -= ebscale * sin(phase) * tmpB;
//INFOMSG("Field " << fcount << " BANDRF E= " << tmpE << " R= " << R << " phase " << phase << endl);
}
if (!superpose_m) break;
}
}
}
return false;
}
......@@ -1022,10 +1018,6 @@ void Cyclotron::getFieldFromFile_FFAG(const double &scaleFactor) {
void Cyclotron::getFieldFromFile_AVFEQ(const double &scaleFactor) {
FILE *f = NULL;
// int lpar;
// char fout[100];
// double dtmp;
*gmsg << "* ----------------------------------------------" << endl;
*gmsg << "* READ IN AVFEQ CYCLOTRON FIELD MAP " << endl;
*gmsg << "* ----------------------------------------------" << endl;
......@@ -1123,10 +1115,6 @@ void Cyclotron::getFieldFromFile_AVFEQ(const double &scaleFactor) {
void Cyclotron::getFieldFromFile_Carbon(const double &scaleFactor) {
FILE *f = NULL;
// int lpar;
// char fout[100];
// double dtmp;
*gmsg << "* ----------------------------------------------" << endl;
*gmsg << "* READ IN CARBON CYCLOTRON FIELD MAP " << endl;
*gmsg << "* ----------------------------------------------" << endl;
......@@ -1222,7 +1210,6 @@ void Cyclotron::getFieldFromFile_Carbon(const double &scaleFactor) {
void Cyclotron::getFieldFromFile_CYCIAE(const double &scaleFactor) {
FILE *f = NULL;
// int lpar;
char fout[100];
int dtmp;
......@@ -1309,7 +1296,7 @@ void Cyclotron::getFieldFromFile_BandRF(const double &scaleFactor) {
vector<double>::const_iterator rfphii = rfphi_m.begin();
vector<double>::const_iterator escali = escale_m.begin();
int fcount = 0;
for(; fm != RFfilename_m.end(); ++fm, ++rffi, ++rfphii, ++escali, ++fcount) {
msg << "Load field map " << fcount << " - " << *fm << endl;
Fieldmap *f = Fieldmap::getFieldmap(*fm, false);
......
......@@ -153,6 +153,9 @@ public:
void setSLPtc(double slptc);
virtual double getSLPtc() const;
void setSuperpose(bool flag);
virtual bool getSuperpose() const;
virtual bool apply(const int &i, const double &t, double E[], double B[]);
virtual bool apply(const int &i, const double &t, Vector_t &E, Vector_t &B);
......@@ -177,6 +180,7 @@ private:
std::vector<double> rffrequ_m;
std::vector<double> rfphi_m;
std::vector<double> escale_m; // a scale factor for the E-field
bool superpose_m; // electric fields are superposed or not
double symmetry_m;
......
......@@ -281,6 +281,10 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
string type = elptr->getType();
*gmsg << "* Type of cyclotron= " << type << " " << endl;
bool Sflag = elptr->getSuperpose();
*gmsg << "* Electric field map are superpoesed ? " << Sflag << " " << endl;
double h = elptr->getCyclHarm();
*gmsg << "* Harmonic number h= " << h << " " << endl;
......
......@@ -36,7 +36,7 @@ OpalCyclotron::OpalCyclotron():
itsAttr[RINIT] = Attributes::makeReal
("RINIT", "Initial radius of the reference particle [m]");
itsAttr[PRINIT] = Attributes::makeReal
("PRINIT", "Initial radial momentum of the reference particle, pr=beta_r*gamma []");
("PRINIT", "Initial radial momentum of the reference particle, pr=beta_r*gamma");
itsAttr[PHIINIT] = Attributes::makeReal
("PHIINIT", "Initial azimuth of the reference particle [deg]");
itsAttr[FMAPFN] = Attributes::makeString
......@@ -49,6 +49,9 @@ OpalCyclotron::OpalCyclotron():
itsAttr[ESCALE] = Attributes::makeRealArray
("ESCALE", "Scale factor for the RF field(s)");
itsAttr[SUPERPOSE] = Attributes::makeBool
("SUPERPOSE", "Option Whether all of the electric field maps are superposed, only used when TYPE = BANDRF", true);
itsAttr[RFMAPFN] = Attributes::makeStringArray
("RFMAPFN", "Filename for the RF fieldmap(s)");
......@@ -128,7 +131,8 @@ void OpalCyclotron::update() {
double tcr2 = Attributes::getReal(itsAttr[TCR2]);
double mbtc = Attributes::getReal(itsAttr[MBTC]);
double slptc = Attributes::getReal(itsAttr[SLPTC]);
bool superpose = Attributes::getBool(itsAttr[SUPERPOSE]);
cycl->setFieldMapFN(fmapfm);
cycl->setSymmetry(symmetry);
......@@ -144,6 +148,7 @@ void OpalCyclotron::update() {
cycl->setTCr2(tcr2);
cycl->setMBtc(mbtc);
cycl->setSLPtc(slptc);
cycl->setSuperpose(superpose);
std::vector<string> fm_str = Attributes::getStringArray(itsAttr[RFMAPFN]);
std::vector<double> scale_str = Attributes::getRealArray(itsAttr[ESCALE]);
......
......@@ -47,8 +47,8 @@ public:
MBTC, //max bfield of trim coil (kG)
SLPTC, //slope of the rising edge
RFPHI, // the initial phase of RF field
SUPERPOSE, // whether the electric field map are superposed or not
SIZE
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment