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() {
......
......@@ -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) {
......
......@@ -6,6 +6,8 @@
#include <fstream>
#include <ios>
extern Inform *gmsg;
using namespace std;
using Physics::mu_0;
......@@ -31,17 +33,17 @@ FM3DDynamic::FM3DDynamic(std::string aFilename):
parsing_passed = parsing_passed &&
interpreteLine<double>(file, frequency_m);
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 &&
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 &&
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 {
cerr << "at the moment only the XYZ orientation is supported!\n"
<< "unknown orientation of 3D dynamic fieldmap" << endl;
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 &&
interpreteLine<double>(file,
tmpDouble,
......@@ -122,16 +124,16 @@ void FM3DDynamic::readMap() {
// else
// {
long ii = 0;
for(int k = 0; k < num_gridpz_m; ++ k) {
for(int j = 0; j < num_gridpy_m; ++ j) {
for(int i = 0; i < num_gridpx_m; ++ i) {
for(unsigned int i = 0; i < num_gridpx_m; ++ i) {
for(unsigned int j = 0; j < num_gridpy_m; ++ j) {
for(unsigned int k = 0; k < num_gridpz_m; ++ k) {
interpreteLine<double>(in,
FieldstrengthEx_m[ii],
FieldstrengthEy_m[ii],
FieldstrengthEz_m[ii],
FieldstrengthHx_m[ii],
FieldstrengthEy_m[ii],
FieldstrengthEx_m[ii],
FieldstrengthHz_m[ii],
FieldstrengthHy_m[ii],
FieldstrengthHz_m[ii]);
FieldstrengthHx_m[ii]);
++ ii;
}
}
......@@ -150,27 +152,26 @@ void FM3DDynamic::readMap() {
-- index_y;
}
ii = index_x + index_y * num_gridpx_m;
for(int i = 0; i < num_gridpz_m; i++) {
if(fabs(FieldstrengthEz_m[ii]) > Ezmax) {
Ezmax = fabs(FieldstrengthEz_m[ii]);
ii = (index_y + index_x * num_gridpy_m) * num_gridpz_m;
for(unsigned int i = 0; i < num_gridpz_m; i++) {
if(std::abs(FieldstrengthEz_m[ii]) > Ezmax) {
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;
FieldstrengthEx_m[i] /= Ezmax;
FieldstrengthEy_m[i] /= Ezmax;
FieldstrengthHz_m[i] /= Ezmax;
FieldstrengthHx_m[i] /= Ezmax;
FieldstrengthHy_m[i] /= Ezmax;
FieldstrengthEz_m[i] *= 1e6 / Ezmax;
FieldstrengthEx_m[i] *= 1e6 / Ezmax;
FieldstrengthEy_m[i] *= 1e6 / Ezmax;
FieldstrengthHz_m[i] *= Physics::mu_0 / Ezmax;
FieldstrengthHx_m[i] *= Physics::mu_0 / Ezmax;
FieldstrengthHy_m[i] *= Physics::mu_0 / Ezmax;
}
INFOMSG(level3 << typeset_msg("read in fieldmap '" + Filename_m + "'", "info") << "\n"
<< endl);
}
}
......@@ -196,78 +197,82 @@ void FM3DDynamic::freeMap() {
}
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 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 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;
if((index_z < 0) || (index_z + 2 > num_gridpz_m)) {
if(index_z >= num_gridpz_m - 2) {
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;
}
const long index1 = index_x + (index_y + index_z * num_gridpy_m) * num_gridpx_m;
E(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1]
+ 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]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthEx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
E(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + num_gridpx_m]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthEy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
E(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + num_gridpx_m]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthEz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
B(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + num_gridpx_m]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthHx_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
B(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + num_gridpx_m]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthHy_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
B(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 + 1]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + num_gridpx_m]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + 1]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m]
+ lever_x * lever_y * lever_z * FieldstrengthHz_m[index1 + num_gridpx_m * num_gridpy_m + num_gridpx_m + 1];
static unsigned int deltaX = num_gridpy_m * num_gridpz_m;
static unsigned int deltaY = num_gridpz_m;
static unsigned int deltaZ = 1;
const unsigned long index1 = index_x * deltaX + index_y * deltaY + index_z * deltaZ;
E(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEx_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEx_m[index1 + deltaY ]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEx_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEx_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthEx_m[index1 + deltaX + deltaY + deltaZ];
E(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEy_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEy_m[index1 + deltaY ]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEy_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEy_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthEy_m[index1 + deltaX + deltaY + deltaZ];
E(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthEz_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthEz_m[index1 + deltaY ]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthEz_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthEz_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthEz_m[index1 + deltaX + deltaY + deltaZ];
B(0) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHx_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHx_m[index1 + deltaY ]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHx_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHx_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthHx_m[index1 + deltaX + deltaY + deltaZ];
B(1) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHy_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHy_m[index1 + deltaY ]
+ 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]
+ lever_x * (1.0 - lever_y) * lever_z * FieldstrengthHy_m[index1 + deltaX + deltaZ]
+ (1.0 - lever_x) * lever_y * lever_z * FieldstrengthHy_m[index1 + deltaY + deltaZ]
+ lever_x * lever_y * lever_z * FieldstrengthHy_m[index1 + deltaX + deltaY + deltaZ];
B(2) += (1.0 - lever_x) * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 ]
+ lever_x * (1.0 - lever_y) * (1.0 - lever_z) * FieldstrengthHz_m[index1 + deltaX ]
+ (1.0 - lever_x) * lever_y * (1.0 - lever_z) * FieldstrengthHz_m[index1 + deltaY ]
+ 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;
}
......@@ -300,3 +305,38 @@ double FM3DDynamic::getFrequency() const {
void FM3DDynamic::setFrequency(double 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:
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,9 +44,9 @@ 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;
......
......@@ -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;
......
......@@ -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);
......
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