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) {
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <fstream> #include <fstream>
#include <ios> #include <ios>
extern Inform *gmsg;
using namespace std; using namespace std;
using Physics::mu_0; using Physics::mu_0;
...@@ -31,17 +33,17 @@ FM3DDynamic::FM3DDynamic(std::string aFilename): ...@@ -31,17 +33,17 @@ FM3DDynamic::FM3DDynamic(std::string aFilename):
parsing_passed = parsing_passed && parsing_passed = parsing_passed &&
interpreteLine<double>(file, frequency_m); interpreteLine<double>(file, frequency_m);
parsing_passed = parsing_passed && parsing_passed = parsing_passed &&
interpreteLine<double, double, int>(file, xbegin_m, xend_m, num_gridpx_m); interpreteLine<double, double, unsigned int>(file, xbegin_m, xend_m, num_gridpx_m);
parsing_passed = parsing_passed && parsing_passed = parsing_passed &&
interpreteLine<double, double, int>(file, ybegin_m, yend_m, num_gridpy_m); interpreteLine<double, double, unsigned int>(file, ybegin_m, yend_m, num_gridpy_m);
parsing_passed = parsing_passed && parsing_passed = parsing_passed &&
interpreteLine<double, double, int>(file, zbegin_m, zend_m, num_gridpz_m); interpreteLine<double, double, unsigned int>(file, zbegin_m, zend_m, num_gridpz_m);
} else { } else {
cerr << "at the moment only the XYZ orientation is supported!\n" cerr << "at the moment only the XYZ orientation is supported!\n"
<< "unknown orientation of 3D dynamic fieldmap" << endl; << "unknown orientation of 3D dynamic fieldmap" << endl;
parsing_passed = false; parsing_passed = false;
} }
for(long i = 0; (i < (num_gridpz_m + 1) * (num_gridpx_m + 1) * (num_gridpy_m + 1)) && parsing_passed; ++ i) { for(unsigned long i = 0; (i < (num_gridpz_m + 1) * (num_gridpx_m + 1) * (num_gridpy_m + 1)) && parsing_passed; ++ i) {
parsing_passed = parsing_passed && parsing_passed = parsing_passed &&
interpreteLine<double>(file, interpreteLine<double>(file,
tmpDouble, tmpDouble,
...@@ -122,16 +124,16 @@ void FM3DDynamic::readMap() { ...@@ -122,16 +124,16 @@ void FM3DDynamic::readMap() {
// else // else
// { // {
long ii = 0; long ii = 0;
for(int k = 0; k < num_gridpz_m; ++ k) { for(unsigned int i = 0; i < num_gridpx_m; ++ i) {
for(int j = 0; j < num_gridpy_m; ++ j) { for(unsigned int j = 0; j < num_gridpy_m; ++ j) {
for(int i = 0; i < num_gridpx_m; ++ i) { for(unsigned int k = 0; k < num_gridpz_m; ++ k) {
interpreteLine<double>(in, interpreteLine<double>(in,
FieldstrengthEx_m[ii],
FieldstrengthEy_m[ii],
FieldstrengthEz_m[ii], FieldstrengthEz_m[ii],
FieldstrengthHx_m[ii], FieldstrengthEy_m[ii],
FieldstrengthEx_m[ii],
FieldstrengthHz_m[ii],
FieldstrengthHy_m[ii], FieldstrengthHy_m[ii],
FieldstrengthHz_m[ii]); FieldstrengthHx_m[ii]);
++ ii; ++ ii;
} }
} }
...@@ -150,27 +152,26 @@ void FM3DDynamic::readMap() { ...@@ -150,27 +152,26 @@ void FM3DDynamic::readMap() {
-- index_y; -- index_y;
} }
ii = index_x + index_y * num_gridpx_m; ii = (index_y + index_x * num_gridpy_m) * num_gridpz_m;
for(int i = 0; i < num_gridpz_m; i++) { for(unsigned int i = 0; i < num_gridpz_m; i++) {
if(fabs(FieldstrengthEz_m[ii]) > Ezmax) { if(std::abs(FieldstrengthEz_m[ii]) > Ezmax) {
Ezmax = fabs(FieldstrengthEz_m[ii]); Ezmax = std::abs(FieldstrengthEz_m[ii]);
} }
ii += num_gridpx_m * num_gridpy_m; ++ ii;
} }
for(long i = 0; i < num_gridpx_m * num_gridpy_m * num_gridpz_m; i++) { for(unsigned long i = 0; i < num_gridpx_m * num_gridpy_m * num_gridpz_m; i++) {
FieldstrengthEz_m[i] /= Ezmax; FieldstrengthEz_m[i] *= 1e6 / Ezmax;
FieldstrengthEx_m[i] /= Ezmax; FieldstrengthEx_m[i] *= 1e6 / Ezmax;
FieldstrengthEy_m[i] /= Ezmax; FieldstrengthEy_m[i] *= 1e6 / Ezmax;
FieldstrengthHz_m[i] /= Ezmax; FieldstrengthHz_m[i] *= Physics::mu_0 / Ezmax;
FieldstrengthHx_m[i] /= Ezmax; FieldstrengthHx_m[i] *= Physics::mu_0 / Ezmax;
FieldstrengthHy_m[i] /= Ezmax; FieldstrengthHy_m[i] *= Physics::mu_0 / Ezmax;
} }
INFOMSG(level3 << typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << "\n" INFOMSG(level3 << typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << "\n"
<< endl); << endl);
} }
} }
...@@ -196,78 +197,82 @@ void FM3DDynamic::freeMap() { ...@@ -196,78 +197,82 @@ void FM3DDynamic::freeMap() {
} }
bool FM3DDynamic::getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const { bool FM3DDynamic::getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const {
const int index_x = static_cast<int>(floor((R(0) - xbegin_m) / hx_m)); const unsigned int index_x = static_cast<int>(floor((R(0) - xbegin_m) / hx_m));
const double lever_x = (R(0) - xbegin_m) / hx_m - index_x; const double lever_x = (R(0) - xbegin_m) / hx_m - index_x;
const int index_y = static_cast<int>(floor((R(1) - ybegin_m) / hy_m)); const unsigned int index_y = static_cast<int>(floor((R(1) - ybegin_m) / hy_m));
const double lever_y = (R(1) - ybegin_m) / hy_m - index_y; const double lever_y = (R(1) - ybegin_m) / hy_m - index_y;
const int index_z = (int)floor((R(2) - zbegin_m) / hz_m); const unsigned int index_z = (int)floor((R(2) - zbegin_m) / hz_m);
const double lever_z = (R(2) - zbegin_m) / hz_m - index_z; const double lever_z = (R(2) - zbegin_m) / hz_m - index_z;
if((index_z < 0) || (index_z + 2 > num_gridpz_m)) { if(index_z >= num_gridpz_m - 2) {
return false; return false;
} }
if(index_x + 2 > num_gridpx_m || index_y + 2 > num_gridpy_m) { if(index_x >= num_gridpx_m - 2|| index_y >= num_gridpy_m - 2) {
return true; return true;
} }
const long index1 = index_x + (index_y + index_z * num_gridpy_m) * num_gridpx_m; static unsigned int deltaX = num_gridpy_m * num_gridpz_m;
static unsigned int deltaY = num_gridpz_m;
E(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1] static unsigned int deltaZ = 1;
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEx_m[index1 + num_gridpx_m] const unsigned long index1 = index_x * deltaX + index_y * deltaY + index_z * deltaZ;
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEx_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m] E(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEx_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEx_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + deltaZ]
E(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1] + lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + deltaX + deltaZ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 + 1] + (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEx_m[index1 + deltaY + deltaZ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + num_gridpx_m] + lever_x * lever_y * lever_z * FieldstrengthEx_m[index1 + deltaX + deltaY + deltaZ];
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m] E(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + deltaZ]
E(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1] + lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + deltaX + deltaZ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 + 1] + (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEy_m[index1 + deltaY + deltaZ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + num_gridpx_m] + lever_x * lever_y * lever_z * FieldstrengthEy_m[index1 + deltaX + deltaY + deltaZ];
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m] E(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + deltaZ]
B(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1] + lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + deltaX + deltaZ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 + 1] + (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEz_m[index1 + deltaY + deltaZ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + num_gridpx_m] + lever_x * lever_y * lever_z * FieldstrengthEz_m[index1 + deltaX + deltaY + deltaZ];
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m] B(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + deltaZ]
B(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1] + lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + deltaX + deltaZ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 + 1] + (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHx_m[index1 + deltaY + deltaZ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + num_gridpx_m] + lever_x * lever_y * lever_z * FieldstrengthHx_m[index1 + deltaX + deltaY + deltaZ];
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m] B(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + deltaZ]
B(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1] + lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + deltaX + deltaZ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 + 1] + (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHy_m[index1 + deltaY + deltaZ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + num_gridpx_m] + lever_x * lever_y * lever_z * FieldstrengthHy_m[index1 + deltaX + deltaY + deltaZ];
+ lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + num_gridpx_m + 1]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m] B(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + 1] + lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m] + (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + deltaY ]
+ lever_x * lever_y * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1]; + lever_x * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + deltaX + deltaY ]
+ (1.0 - lever_x) * (1.0 - lever_y) * lever_z * FieldstrengthHz_m[index1 + deltaZ]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHz_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHz_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthHz_m[index1 + deltaX + deltaY + deltaZ];
return false; return false;
} }
...@@ -300,3 +305,38 @@ double FM3DDynamic::getFrequency() const { ...@@ -300,3 +305,38 @@ double FM3DDynamic::getFrequency() const {
void FM3DDynamic::setFrequency(double freq) { void FM3DDynamic::setFrequency(double freq) {
frequency_m = freq; frequency_m = freq;
} }
void FM3DDynamic::getOnaxisEz(std::vector<std::pair<double, double> > & F) {
F.resize(num_gridpz_m);
int index_x = static_cast<int>(ceil(-xbegin_m / hx_m));
double lever_x = index_x * hx_m + xbegin_m;
if(lever_x > 0.5) {
-- index_x;
}
int index_y = static_cast<int>(ceil(-ybegin_m / hy_m));
double lever_y = index_y * hy_m + ybegin_m;
if(lever_y > 0.5) {
-- index_y;
}
std::ofstream out("data/" + Filename_m);
unsigned int ii = (index_y + index_x * num_gridpy_m) * num_gridpz_m;
for(unsigned int i = 0; i < num_gridpz_m; ++ i) {
F[i].first = hz_m * i;
F[i].second = FieldstrengthEz_m[ii ++] / 1e6;
Vector_t R(0,0,zbegin_m + F[i].first), B(0.0), E(0.0);
getFieldstrength(R, E, B);
out << std::setw(16) << std::setprecision(8) << F[i].first
<< std::setw(16) << std::setprecision(8) << E(0)
<< std::setw(16) << std::setprecision(8) << E(1)
<< std::setw(16) << std::setprecision(8) << E(2)
<< std::setw(16) << std::setprecision(8) << B(0)
<< std::setw(16) << std::setprecision(8) << B(1)
<< std::setw(16) << std::setprecision(8) << B(2) << "\n";
}
out.close();
}
\ No newline at end of file
...@@ -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