Commit 09b2b8ad authored by kraus's avatar kraus Committed by kraus

fixing 3DDynamic field map; cleaning up Collimator class

parent af9160f9
...@@ -208,17 +208,13 @@ inline bool Collimator::isInColl(Vector_t R, Vector_t P, double recpgamma) { ...@@ -208,17 +208,13 @@ inline bool Collimator::isInColl(Vector_t R, Vector_t P, double recpgamma) {
} }
} }
return !alive; return !alive;
} else if(isASlit_m) { } else if(isASlit_m || isARColl_m) {
return (R(0) <= -getXsize() || R(1) <= -getYsize() || R(0) >= getXsize() || R(1) >= getYsize()); return (std::abs(R(0)) >= getXsize() || std::abs(R(1)) >= getYsize());
} else if (isARColl_m) {
return (R(0) <= -getXsize() || R(1) <= -getYsize() || R(0) >= getXsize() || R(1) >= getYsize());
} else if(isAWire_m) { } else if(isAWire_m) {
ERRORMSG("Not yet implemented"); ERRORMSG("Not yet implemented");
} else { } else {
// case of an elliptic collimator // case of an elliptic collimator
const double trm1 = ((R(0)*R(0))/(getXsize()*getXsize())); return (std::pow(R(0) / getXsize(), 2.0) + std::pow(R(1) / getYsize(), 2.0)) >= 1.0;
const double trm2 = ((R(1)*R(1))/(getYsize()*getYsize()));
return (trm1 + trm2) > 1.0;
} }
} }
return false; return false;
...@@ -342,39 +338,7 @@ void Collimator::finalise() ...@@ -342,39 +338,7 @@ void Collimator::finalise()
} }
void Collimator::goOnline(const double &) { void Collimator::goOnline(const double &) {
if(RefPartBunch_m == NULL) { print();
if(!informed_m) {
std::string errormsg = Fieldmap::typeset_msg("BUNCH SIZE NOT SET", "warning");
ERRORMSG(errormsg << endl);
if(Ippl::myNode() == 0) {
ofstream omsg("errormsg.txt", ios_base::app);
omsg << errormsg << endl;
omsg.close();
}
informed_m = true;
}
return;
}
*gmsg << level3;
if(isAPepperPot_m)
*gmsg << "* Pepperpot x= " << a_m << " y= " << b_m << " r= " << rHole_m
<< " nx= " << nHolesX_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
else if(isASlit_m)
*gmsg << "* Slit x= " << getXsize() << " Slit y= " << getYsize()
<< " start= " << position_m << " fn= " << filename_m << endl;
else if(isARColl_m)
*gmsg << "* RCollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m
<< " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
else if(isACColl_m)
*gmsg << "* CCollimator angle start " << xstart_m << " (Deg) angle end " << ystart_m << " (Deg) "
<< "R start " << xend_m << " (mm) R rend " << yend_m << " (mm)" << endl;
else if(isAWire_m)
*gmsg << "* Wire x= " << x0_m << " y= " << y0_m << endl;
else
*gmsg << "* ECollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m
<< " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
PosX_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum())); PosX_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum()));
PosY_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum())); PosY_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum()));
...@@ -391,8 +355,7 @@ void Collimator::print() { ...@@ -391,8 +355,7 @@ void Collimator::print() {
if(RefPartBunch_m == NULL) { if(RefPartBunch_m == NULL) {
if(!informed_m) { if(!informed_m) {
std::string errormsg = Fieldmap::typeset_msg("BUNCH SIZE NOT SET", "warning"); std::string errormsg = Fieldmap::typeset_msg("BUNCH SIZE NOT SET", "warning");
*gmsg << errormsg << "\n" ERRORMSG(errormsg << endl);
<< endl;
if(Ippl::myNode() == 0) { if(Ippl::myNode() == 0) {
ofstream omsg("errormsg.txt", ios_base::app); ofstream omsg("errormsg.txt", ios_base::app);
omsg << errormsg << endl; omsg << errormsg << endl;
...@@ -403,19 +366,25 @@ void Collimator::print() { ...@@ -403,19 +366,25 @@ void Collimator::print() {
return; return;
} }
*gmsg << level3;
if(isAPepperPot_m) if(isAPepperPot_m)
*gmsg << "Pepperpot x= " << a_m << " y= " << b_m << " r= " << rHole_m << " nx= " << nHolesX_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl; *gmsg << "* Pepperpot x= " << a_m << " y= " << b_m << " r= " << rHole_m
<< " nx= " << nHolesX_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
else if(isASlit_m) else if(isASlit_m)
*gmsg << "Slit x= " << getXsize() << " Slit y= " << getYsize() << " start= " << position_m << " fn= " << filename_m << endl; *gmsg << "* Slit x= " << getXsize() << " Slit y= " << getYsize()
<< " start= " << position_m << " fn= " << filename_m << endl;
else if(isARColl_m) else if(isARColl_m)
*gmsg << "RCollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m << " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl; *gmsg << "* RCollimator a= " << getXsize() << " b= " << getYsize()
<< " start= " << position_m << " fn= " << filename_m
<< " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
else if(isACColl_m) else if(isACColl_m)
*gmsg << "CCollimator angstart= " << xstart_m << " angend " << ystart_m << " rstart " << xend_m << " rend " << yend_m << endl; *gmsg << "* CCollimator angle start " << xstart_m << " (Deg) angle end " << ystart_m << " (Deg) "
<< "R start " << xend_m << " (mm) R rend " << yend_m << " (mm)" << endl;
else if(isAWire_m) else if(isAWire_m)
*gmsg << "Wire x= " << x0_m << " y= " << y0_m << endl; *gmsg << "* Wire x= " << x0_m << " y= " << y0_m << endl;
else else
*gmsg << "ECollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m << " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl; *gmsg << "* ECollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m
<< " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
} }
void Collimator::goOffline() { void Collimator::goOffline() {
......
...@@ -242,7 +242,6 @@ void FM2DDynamic::setFrequency(double freq) { ...@@ -242,7 +242,6 @@ void FM2DDynamic::setFrequency(double freq) {
void FM2DDynamic::getOnaxisEz(std::vector<std::pair<double, double> > & F) { void FM2DDynamic::getOnaxisEz(std::vector<std::pair<double, double> > & F) {
double dz = (zend_m - zbegin_m) / (num_gridpz_m - 1); double dz = (zend_m - zbegin_m) / (num_gridpz_m - 1);
std::string tmpString;
F.resize(num_gridpz_m); F.resize(num_gridpz_m);
for(int i = 0; i < num_gridpz_m; ++ i) { for(int i = 0; i < num_gridpz_m; ++ i) {
......
This diff is collapsed.
...@@ -14,6 +14,7 @@ public: ...@@ -14,6 +14,7 @@ public:
virtual void getInfo(Inform *msg); virtual void getInfo(Inform *msg);
virtual double getFrequency() const; virtual double getFrequency() const;
virtual void setFrequency(double freq); virtual void setFrequency(double freq);
virtual void getOnaxisEz(std::vector<std::pair<double, double> > & F);
private: private:
FM3DDynamic(std::string aFilename); FM3DDynamic(std::string aFilename);
...@@ -43,9 +44,9 @@ private: ...@@ -43,9 +44,9 @@ private:
double hx_m; /**< length between points in grid, x-direction */ double hx_m; /**< length between points in grid, x-direction */
double hy_m; /**< length between points in grid, y-direction */ double hy_m; /**< length between points in grid, y-direction */
double hz_m; /**< length between points in grid, z-direction */ double hz_m; /**< length between points in grid, z-direction */
int num_gridpx_m; /**< Read in number of points after 0(not counted here) in grid, r-direction*/ unsigned int num_gridpx_m; /**< Read in number of points after 0(not counted here) in grid, r-direction*/
int num_gridpy_m; /**< Read in number of points after 0(not counted here) in grid, r-direction*/ unsigned int num_gridpy_m; /**< Read in number of points after 0(not counted here) in grid, r-direction*/
int num_gridpz_m; /**< Read in number of points after 0(not counted here) in grid, z-direction*/ unsigned int num_gridpz_m; /**< Read in number of points after 0(not counted here) in grid, z-direction*/
bool swap_m; bool swap_m;
friend class Fieldmap; friend class Fieldmap;
......
...@@ -675,6 +675,7 @@ void Fieldmap::SetFieldGap(double gap) { ...@@ -675,6 +675,7 @@ void Fieldmap::SetFieldGap(double gap) {
} }
REGISTER_PARSE_TYPE(int); REGISTER_PARSE_TYPE(int);
REGISTER_PARSE_TYPE(unsigned int);
REGISTER_PARSE_TYPE(double); REGISTER_PARSE_TYPE(double);
REGISTER_PARSE_TYPE(std::string); REGISTER_PARSE_TYPE(std::string);
......
...@@ -153,6 +153,10 @@ void AutophaseTracker::execute(const std::queue<double> &dtAllTracks, ...@@ -153,6 +153,10 @@ void AutophaseTracker::execute(const std::queue<double> &dtAllTracks,
maxStepsAutoPhasing.pop(); maxStepsAutoPhasing.pop();
} }
INFOMSG(level2 << "step = " << step << ", spos = " << refR(2) << " [m], "
<< "t= " << itsBunch_m.getT() << " [s], " << "E = " << getEnergyMeV(refP) << " [MeV] "
<< endl);
printCavityPhases(); printCavityPhases();
sendCavityPhases(); sendCavityPhases();
...@@ -166,6 +170,7 @@ void AutophaseTracker::track(double uptoSPos, ...@@ -166,6 +170,7 @@ void AutophaseTracker::track(double uptoSPos,
std::queue<unsigned long long> &maxStepsAutoPhasing) { std::queue<unsigned long long> &maxStepsAutoPhasing) {
Vector_t &refR = itsBunch_m.R[0]; Vector_t &refR = itsBunch_m.R[0];
Vector_t &refP = itsBunch_m.P[0]; Vector_t &refP = itsBunch_m.P[0];
double t = itsBunch_m.getT(); double t = itsBunch_m.getT();
const int dtfraction = DTFRACTION; const int dtfraction = DTFRACTION;
......
...@@ -911,14 +911,14 @@ void TrackRun::findPhasesForMaxEnergy(bool writeToFile) const { ...@@ -911,14 +911,14 @@ void TrackRun::findPhasesForMaxEnergy(bool writeToFile) const {
void TrackRun::executeAutophaseTracker() { void TrackRun::executeAutophaseTracker() {
Beam *beam = Beam::find(Attributes::getString(itsAttr[BEAM])); Beam *beam = Beam::find(Attributes::getString(itsAttr[BEAM]));
double charge = setDistributionParallelT(beam); /*double charge =*/ setDistributionParallelT(beam);
Track::block->bunch->setdT(Track::block->dT.front()); Track::block->bunch->setdT(Track::block->dT.front());
Track::block->bunch->dtScInit_m = Track::block->dtScInit; Track::block->bunch->dtScInit_m = Track::block->dtScInit;
Track::block->bunch->deltaTau_m = Track::block->deltaTau; Track::block->bunch->deltaTau_m = Track::block->deltaTau;
Track::block->bunch->setT(Track::block->t0_m); Track::block->bunch->setT(Track::block->t0_m);
Track::block->bunch->setCharge(charge); // Track::block->bunch->setCharge(charge);
double couplingConstant = 1.0 / (4 * pi * epsilon_0); double couplingConstant = 1.0 / (4 * pi * epsilon_0);
Track::block->bunch->setCouplingConstant(couplingConstant); Track::block->bunch->setCouplingConstant(couplingConstant);
......
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