Commit b7325d0d authored by kraus's avatar kraus

throw exception if some field overlaps with dipole field; does not work yet

parent 236d53a0
......@@ -440,6 +440,17 @@ void OpalBeamline::prepareSections() {
}
}
}
if (sections_m[i].doDipoleFieldsOverlap()) {
const CompVec &elements = sections_m[i].getElements();
auto it = elements.begin();
std::string elementNames = (*it)->getName();
for (++ it; it != elements.end(); ++ it) {
elementNames += ", " + (*it)->getName();
}
throw OpalException("OpalBeamline::prepareSections",
"Fields overlap with dipole fields; not supported yet;\n*** affected elements: " + elementNames);
}
}
......
......@@ -62,8 +62,6 @@ OpalSection::OpalSection(const CompVec &elements, const double &start, const dou
boundarygeometry_m = (*clit)->getBoundaryGeometry();
has_boundarygeometry_m = true;
}
}
if(has_wake_m && !wakefunction_m) {
// we then dismissed them all or there is
......@@ -165,4 +163,25 @@ void OpalSection::updateEndCache() {
EndCache_m.u_factor = tanb * sinc / cosa - tana * cosc;
EndCache_m.v_factor = -tanb * cosc / cosa - tana * sinc;
}
}
bool OpalSection::doDipoleFieldsOverlap() const {
if (!bends_m) return false;
unsigned int numFieldContributions = 0;
for (auto it = elements_m.begin(); it != elements_m.end(); ++ it) {
switch((*it)->getType()) {
case ElementBase::CORRECTOR:
case ElementBase::MULTIPOLE:
case ElementBase::RBEND:
case ElementBase::RFCAVITY:
case ElementBase::RFQUADRUPOLE:
case ElementBase::SBEND:
case ElementBase::SOLENOID:
case ElementBase::TRAVELINGWAVE:
++ numFieldContributions;
default:
}
}
return (numFieldContributions > 1);
}
\ No newline at end of file
......@@ -69,6 +69,7 @@ public:
return EndCache_m;
}
bool doDipoleFieldsOverlap() const;
private:
CompVec elements_m;
double start_m;
......
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