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) {
}
}
return !alive;
} else if(isASlit_m) {
return (R(0) <= -getXsize() || R(1) <= -getYsize() || R(0) >= getXsize() || R(1) >= getYsize());
} else if (isARColl_m) {
return (R(0) <= -getXsize() || R(1) <= -getYsize() || R(0) >= getXsize() || R(1) >= getYsize());
} else if(isASlit_m || isARColl_m) {
return (std::abs(R(0)) >= getXsize() || std::abs(R(1)) >= getYsize());
} else if(isAWire_m) {
ERRORMSG("Not yet implemented");
} else {
// case of an elliptic collimator
const double trm1 = ((R(0)*R(0))/(getXsize()*getXsize()));
const double trm2 = ((R(1)*R(1))/(getYsize()*getYsize()));
return (trm1 + trm2) > 1.0;
return (std::pow(R(0) / getXsize(), 2.0) + std::pow(R(1) / getYsize(), 2.0)) >= 1.0;
}
}
return false;
......@@ -342,39 +338,7 @@ void Collimator::finalise()
}
void Collimator::goOnline(const double &) {
if(RefPartBunch_m == NULL) {
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;
print();
PosX_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum()));
PosY_m.reserve((int)(1.1 * RefPartBunch_m->getLocalNum()));
......@@ -391,8 +355,7 @@ void Collimator::print() {
if(RefPartBunch_m == NULL) {
if(!informed_m) {
std::string errormsg = Fieldmap::typeset_msg("BUNCH SIZE NOT SET", "warning");
*gmsg << errormsg << "\n"
<< endl;
ERRORMSG(errormsg << endl);
if(Ippl::myNode() == 0) {
ofstream omsg("errormsg.txt", ios_base::app);
omsg << errormsg << endl;
......@@ -403,19 +366,25 @@ void Collimator::print() {
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;
*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;
*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;
*gmsg << "* RCollimator a= " << getXsize() << " b= " << getYsize()
<< " start= " << position_m << " fn= " << filename_m
<< " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
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)
*gmsg << "Wire x= " << x0_m << " y= " << y0_m << endl;
*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;
*gmsg << "* ECollimator a= " << getXsize() << " b= " << b_m << " start= " << position_m
<< " fn= " << filename_m << " ny= " << nHolesY_m << " pitch= " << pitch_m << endl;
}
void Collimator::goOffline() {
......@@ -641,4 +610,4 @@ int Collimator::checkPoint(const double &x, const double &y) {
}
}
return (cn & 1); // 0 if even (out), and 1 if odd (in)
}
}
\ No newline at end of file
......@@ -242,7 +242,6 @@ void FM2DDynamic::setFrequency(double freq) {
void FM2DDynamic::getOnaxisEz(std::vector<std::pair<double, double> > & F) {
double dz = (zend_m - zbegin_m) / (num_gridpz_m - 1);
std::string tmpString;
F.resize(num_gridpz_m);
for(int i = 0; i < num_gridpz_m; ++ i) {
......
This diff is collapsed.
......@@ -14,6 +14,7 @@ public:
virtual void getInfo(Inform *msg);
virtual double getFrequency() const;
virtual void setFrequency(double freq);
virtual void getOnaxisEz(std::vector<std::pair<double, double> > & F);
private:
FM3DDynamic(std::string aFilename);
......@@ -43,12 +44,12 @@ private:
double hx_m; /**< length between points in grid, x-direction */
double hy_m; /**< length between points in grid, y-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*/
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_gridpx_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*/
unsigned int num_gridpz_m; /**< Read in number of points after 0(not counted here) in grid, z-direction*/
bool swap_m;
friend class Fieldmap;
};
#endif
#endif
\ No newline at end of file
......@@ -675,6 +675,7 @@ void Fieldmap::SetFieldGap(double gap) {
}
REGISTER_PARSE_TYPE(int);
REGISTER_PARSE_TYPE(unsigned int);
REGISTER_PARSE_TYPE(double);
REGISTER_PARSE_TYPE(std::string);
......
......@@ -153,6 +153,10 @@ void AutophaseTracker::execute(const std::queue<double> &dtAllTracks,
maxStepsAutoPhasing.pop();
}
INFOMSG(level2 << "step = " << step << ", spos = " << refR(2) << " [m], "
<< "t= " << itsBunch_m.getT() << " [s], " << "E = " << getEnergyMeV(refP) << " [MeV] "
<< endl);
printCavityPhases();
sendCavityPhases();
......@@ -166,6 +170,7 @@ void AutophaseTracker::track(double uptoSPos,
std::queue<unsigned long long> &maxStepsAutoPhasing) {
Vector_t &refR = itsBunch_m.R[0];
Vector_t &refP = itsBunch_m.P[0];
double t = itsBunch_m.getT();
const int dtfraction = DTFRACTION;
......@@ -571,4 +576,4 @@ void AutophaseTracker::save(const std::string &fname) {
}
out.close();
}
}
\ No newline at end of file
......@@ -911,14 +911,14 @@ void TrackRun::findPhasesForMaxEnergy(bool writeToFile) const {
void TrackRun::executeAutophaseTracker() {
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->dtScInit_m = Track::block->dtScInit;
Track::block->bunch->deltaTau_m = Track::block->deltaTau;
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);
Track::block->bunch->setCouplingConstant(couplingConstant);
......@@ -1138,4 +1138,4 @@ Amr* TrackRun::setupAMRSolver() {
return amrptr;
}
#endif
#endif
\ No newline at end of file
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