Commit 34b8cafa authored by snuverink_j's avatar snuverink_j
Browse files

add B-field threshold for applying trim coils (trim coils are typically on the magnets only)

parent 786b1516
...@@ -136,6 +136,14 @@ double Cyclotron::getPZinit() const { ...@@ -136,6 +136,14 @@ double Cyclotron::getPZinit() const {
return pzinit_m; return pzinit_m;
} }
void Cyclotron::setTrimCoilThreshold(double trimCoilThreshold) {
trimCoilThreshold_m = trimCoilThreshold;
}
double Cyclotron::getTrimCoilThreshold() const {
return trimCoilThreshold_m;
}
void Cyclotron::setSpiralFlag(bool spiral_flag) { void Cyclotron::setSpiralFlag(bool spiral_flag) {
spiral_flag_m = spiral_flag; spiral_flag_m = spiral_flag;
} }
...@@ -336,7 +344,7 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec ...@@ -336,7 +344,7 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec
/* if((R[0] > 0) && (R[1] >= 0)) tet = tempv; /* if((R[0] > 0) && (R[1] >= 0)) tet = tempv;
else*/ else*/
if((R[0] < 0) && (R[1] >= 0)) tet = pi + tempv; if ((R[0] < 0) && (R[1] >= 0)) tet = pi + tempv;
else if((R[0] < 0) && (R[1] <= 0)) tet = pi + tempv; else if((R[0] < 0) && (R[1] <= 0)) tet = pi + tempv;
else if((R[0] > 0) && (R[1] <= 0)) tet = 2.0 * pi + tempv; else if((R[0] > 0) && (R[1] <= 0)) tet = 2.0 * pi + tempv;
else if((R[0] == 0) && (R[1] > 0)) tet = pi / 2.0; else if((R[0] == 0) && (R[1] > 0)) tet = pi / 2.0;
...@@ -443,6 +451,7 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec ...@@ -443,6 +451,7 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec
// bt = -( btf - btcub ); // bt = -( btf - btcub );
bt = - btf; bt = - btf;
if (std::abs(br) > trimCoilThreshold_m || std::abs(bz) > trimCoilThreshold_m)
applyTrimCoil(rad, R[2], &br, &bz); applyTrimCoil(rad, R[2], &br, &bz);
/* Br Btheta -> Bx By */ /* Br Btheta -> Bx By */
...@@ -456,7 +465,10 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec ...@@ -456,7 +465,10 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec
return true; return true;
} }
if(myBFieldType_m == SYNCHRO || myBFieldType_m == BANDRF) { if(myBFieldType_m != SYNCHRO && myBFieldType_m != BANDRF) {
return false;
}
//The RF field is supposed to be sampled on a cartesian grid //The RF field is supposed to be sampled on a cartesian grid
vector<Fieldmap *>::const_iterator fi = RFfields_m.begin(); vector<Fieldmap *>::const_iterator fi = RFfields_m.begin();
vector<double>::const_iterator rffi = rffrequ_m.begin(); vector<double>::const_iterator rffi = rffrequ_m.begin();
...@@ -550,7 +562,6 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec ...@@ -550,7 +562,6 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec
waiting_for_gap = 0; waiting_for_gap = 0;
} }
} }
}
return false; return false;
} }
......
...@@ -179,6 +179,9 @@ public: ...@@ -179,6 +179,9 @@ public:
void setFMHighE(double e); void setFMHighE(double e);
virtual double getFMHighE() const; virtual double getFMHighE() const;
void setTrimCoilThreshold(double);
virtual double getTrimCoilThreshold() const;
void setSpiralFlag(bool spiral_flag); void setSpiralFlag(bool spiral_flag);
virtual bool getSpiralFlag() const; virtual bool getSpiralFlag() const;
...@@ -235,6 +238,7 @@ private: ...@@ -235,6 +238,7 @@ private:
double pzinit_m; double pzinit_m;
bool spiral_flag_m; bool spiral_flag_m;
double trimCoilThreshold_m; ///< B-field threshold for applying trim coil
std::string type_m; /* what type of field we use */ std::string type_m; /* what type of field we use */
double harm_m; double harm_m;
......
...@@ -111,6 +111,9 @@ OpalCyclotron::OpalCyclotron(): ...@@ -111,6 +111,9 @@ OpalCyclotron::OpalCyclotron():
itsAttr[SPIRAL] = Attributes::makeBool itsAttr[SPIRAL] = Attributes::makeBool
("SPIRAL","Flag whether or not this is a spiral inflector simulation", false); ("SPIRAL","Flag whether or not this is a spiral inflector simulation", false);
itsAttr[TRIMCOILTHRESHOLD] = Attributes::makeReal
("TRIMCOILTHRESHOLD","Minimum magnetic field [T] for which trim coils are applied", 0.0);
itsAttr[TRIMCOIL] = Attributes::makeStringArray itsAttr[TRIMCOIL] = Attributes::makeStringArray
("TRIMCOIL", "List of trim coils"); ("TRIMCOIL", "List of trim coils");
...@@ -138,6 +141,7 @@ OpalCyclotron::OpalCyclotron(): ...@@ -138,6 +141,7 @@ OpalCyclotron::OpalCyclotron():
registerRealAttribute("MAXR"); registerRealAttribute("MAXR");
registerRealAttribute("FMLOWE"); registerRealAttribute("FMLOWE");
registerRealAttribute("FMHIGHE"); registerRealAttribute("FMHIGHE");
registerRealAttribute("TRIMCOILTHRESHOLD");
registerOwnership(); registerOwnership();
...@@ -192,6 +196,7 @@ void OpalCyclotron::update() { ...@@ -192,6 +196,7 @@ void OpalCyclotron::update() {
double fmHighE = Attributes::getReal(itsAttr[FMHIGHE]); double fmHighE = Attributes::getReal(itsAttr[FMHIGHE]);
bool spiral_flag = Attributes::getBool(itsAttr[SPIRAL]); bool spiral_flag = Attributes::getBool(itsAttr[SPIRAL]);
double trimCoilThreshold = Attributes::getReal(itsAttr[TRIMCOILTHRESHOLD]);
cycl->setFieldMapFN(fmapfm); cycl->setFieldMapFN(fmapfm);
cycl->setSymmetry(symmetry); cycl->setSymmetry(symmetry);
...@@ -216,6 +221,7 @@ void OpalCyclotron::update() { ...@@ -216,6 +221,7 @@ void OpalCyclotron::update() {
cycl->setFMHighE(fmHighE); cycl->setFMHighE(fmHighE);
cycl->setSpiralFlag(spiral_flag); cycl->setSpiralFlag(spiral_flag);
cycl->setTrimCoilThreshold(trimCoilThreshold);
std::vector<std::string> fm_str = Attributes::getStringArray(itsAttr[RFMAPFN]); std::vector<std::string> fm_str = Attributes::getStringArray(itsAttr[RFMAPFN]);
std::vector<std::string> rffcfn_str = Attributes::getStringArray(itsAttr[RFFCFN]); std::vector<std::string> rffcfn_str = Attributes::getStringArray(itsAttr[RFFCFN]);
......
...@@ -59,6 +59,7 @@ public: ...@@ -59,6 +59,7 @@ public:
FMLOWE, // minimal energy of the field map FMLOWE, // minimal energy of the field map
FMHIGHE, // maximal energy of the field map FMHIGHE, // maximal energy of the field map
SPIRAL, // flag whether or not this is a spiral inflector simulation SPIRAL, // flag whether or not this is a spiral inflector simulation
TRIMCOILTHRESHOLD, // minimum B-field for which trim coils are applied
TRIMCOIL, // list of trim coils TRIMCOIL, // list of trim coils
SIZE 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