Commit 03d273a9 authored by kraus's avatar kraus
Browse files

fixing calculation of external fields for output

parent ce0f138f
......@@ -2866,12 +2866,14 @@ void ParallelTTracker::writePhaseSpace(const long long step, const double &sposR
<< "\t " << externalB(0) << "\t " << externalB(1) << "\t " << externalB(2) << endl;
#endif
for(int k = 0; k < 3; ++k) {
externalB = Vector_t(0.0);
externalE = Vector_t(0.0);
itsOpalBeamline_m.getFieldAt(pos[k], itsBunch->get_rmean(), itsBunch->getT() - 0.5 * itsBunch->getdT(), externalE, externalB);
FDext[2 * k] = externalB;
FDext[2 * k + 1] = externalE * 1e-6;
if (psDump || statDump) {
for(int k = 0; k < 3; ++k) {
externalB = Vector_t(0.0);
externalE = Vector_t(0.0);
itsOpalBeamline_m.getFieldAt(pos[k], itsBunch->get_rmean(), itsBunch->getT() - 0.5 * itsBunch->getdT(), externalE, externalB);
FDext[2 * k] = externalB;
FDext[2 * k + 1] = externalE * 1e-6;
}
}
if(psDump && (itsBunch->getTotalNum() > 0)) {
......
......@@ -79,22 +79,22 @@ CompVec &OpalBeamline::getSuccessors(std::shared_ptr<const Component> element) {
}
}
OpalSection &OpalBeamline::getSectionAt(const Vector_t &pos, long &initial_guess) {
if(initial_guess >= (long) sections_m.size()) initial_guess = static_cast<long>(sections_m.size()) - 1;
OpalSection &OpalBeamline::getSectionAt(const Vector_t &pos, long &sectionIndex) {
if(sectionIndex >= (long) sections_m.size()) sectionIndex = static_cast<long>(sections_m.size()) - 1;
if(prepared_m) {
if(pos(2) < sections_m[0].getStart(pos(0), pos(1))) return dummy_section_m;
if(pos(2) > sections_m.back().getEnd(pos(0), pos(1))) {
initial_guess = BEAMLINE_EOL;
sectionIndex = BEAMLINE_EOL;
return dummy_section_m;
}
if(initial_guess == -1) initial_guess = 0;
if(sectionIndex == -1) sectionIndex = sections_m.size() - 1;
while(pos(2) > sections_m[initial_guess].getEnd(pos(0), pos(1))) ++initial_guess;
while(pos(2) < sections_m[initial_guess].getStart(pos(0), pos(1))) --initial_guess;
while(pos(2) < sections_m[sectionIndex].getStart(pos(0), pos(1))) --sectionIndex;
while(pos(2) > sections_m[sectionIndex].getEnd(pos(0), pos(1))) ++sectionIndex;
if(pos(2) >= sections_m[initial_guess].getStart(pos(0), pos(1)) &&
pos(2) <= sections_m[initial_guess].getEnd(pos(0), pos(1))) return sections_m[initial_guess];
if(pos(2) >= sections_m[sectionIndex].getStart(pos(0), pos(1)) &&
pos(2) <= sections_m[sectionIndex].getEnd(pos(0), pos(1))) return sections_m[sectionIndex];
return dummy_section_m;
}
......@@ -241,10 +241,9 @@ unsigned long OpalBeamline::getFieldAt(const unsigned int &index, const Vector_t
}
unsigned long OpalBeamline::getFieldAt(const Vector_t &pos, const Vector_t &centroid, const double &t, Vector_t &E, Vector_t &B) {
unsigned long rtv = 0x00;
long initial_guess = 0;
long initial_guess = -1;
B = Vector_t(0.0);
E = Vector_t(0.0);
......@@ -530,4 +529,4 @@ FieldList OpalBeamline::getElementByType(ElementBase::ElementType type) {
}
}
return elements_of_requested_type;
}
\ 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