diff --git a/src/Elements/OpalElement.cpp b/src/Elements/OpalElement.cpp index 63bf8b771bf9200523104f97bbb7684f2ca46d29..684fc18f62354414ef97a6bbe5bb05471f603e96 100644 --- a/src/Elements/OpalElement.cpp +++ b/src/Elements/OpalElement.cpp @@ -568,7 +568,8 @@ void OpalElement::update() { rotation = rotTheta * (rotPhi * rotPsi); } else { if (itsAttr[ORIENTATION]) { - throw OpalException("Line::parse","Parameter orientation is array of 3 values (theta, phi, psi);\n" + + throw OpalException("OpalElement::update", + "Parameter orientation is array of 3 values (theta, phi, psi);\n" + std::to_string(dir.size()) + " values provided"); } } @@ -577,7 +578,8 @@ void OpalElement::update() { origin = Vector_t(ori[0], ori[1], ori[2]); } else { if (itsAttr[ORIGIN]) { - throw OpalException("Line::parse","Parameter origin is array of 3 values (x, y, z);\n" + + throw OpalException("OpalElement::update", + "Parameter origin is array of 3 values (x, y, z);\n" + std::to_string(ori.size()) + " values provided"); } } diff --git a/src/Elements/OpalRBend.cpp b/src/Elements/OpalRBend.cpp index dec75dc88fd2a27239cc8538a2487d68a35b513b..0f1b9e0be8c28d849f5a493ee21c4a8839024680 100644 --- a/src/Elements/OpalRBend.cpp +++ b/src/Elements/OpalRBend.cpp @@ -24,7 +24,6 @@ #include "Structure/OpalWake.h" #include "Structure/ParticleMatterInteraction.h" #include "Utilities/OpalException.h" -#include <cmath> OpalRBend::OpalRBend(): OpalBend("RBEND", @@ -47,10 +46,8 @@ OpalRBend::OpalRBend(const std::string &name, OpalRBend *parent): OpalRBend::~OpalRBend() { - if(owk_m) - delete owk_m; - if(parmatint_m) - delete parmatint_m; + delete owk_m; + delete parmatint_m; } @@ -131,7 +128,7 @@ void OpalRBend::update() { double k0s = itsAttr[K0S] ? Attributes::getReal(itsAttr[K0S]) : 0.0; //JMJ 4/10/2000: above line replaced // length ? angle / length : angle; - // to avoid closed orbit created by RBEND with defalt K0. + // to avoid closed orbit created by RBEND with default K0. field.setNormalComponent(1, factor * k0); field.setSkewComponent(1, factor * Attributes::getReal(itsAttr[K0S])); field.setNormalComponent(2, factor * Attributes::getReal(itsAttr[K1])); @@ -177,8 +174,11 @@ void OpalRBend::update() { } // Energy in eV. - if(itsAttr[DESIGNENERGY]) { + if(itsAttr[DESIGNENERGY] && Attributes::getReal(itsAttr[DESIGNENERGY]) != 0.0) { bend->setDesignEnergy(Attributes::getReal(itsAttr[DESIGNENERGY]), false); + } else if (bend->getName() != "RBEND") { + throw OpalException("OpalRBend::update", + "RBend requires non-zero DESIGNENERGY"); } bend->setFullGap(Attributes::getReal(itsAttr[GAP])); diff --git a/src/Elements/OpalRBend3D.cpp b/src/Elements/OpalRBend3D.cpp index f64500bfddc8945e4520fc85fbce6fe40bdd9ad1..e1175d63fcd64bce123bf92242e2bd0dfbb925b3 100644 --- a/src/Elements/OpalRBend3D.cpp +++ b/src/Elements/OpalRBend3D.cpp @@ -72,10 +72,8 @@ OpalRBend3D::OpalRBend3D(const std::string &name, OpalRBend3D *parent): } OpalRBend3D::~OpalRBend3D() { - if(owk_m) - delete owk_m; - if(parmatint_m) - delete parmatint_m; + delete owk_m; + delete parmatint_m; } OpalRBend3D *OpalRBend3D::clone(const std::string &name) { @@ -130,8 +128,11 @@ void OpalRBend3D::update() { bend->setEntranceAngle(e1); // Energy in eV. - if(itsAttr[DESIGNENERGY]) { + if(itsAttr[DESIGNENERGY] && Attributes::getReal(itsAttr[DESIGNENERGY]) != 0.0) { bend->setDesignEnergy(Attributes::getReal(itsAttr[DESIGNENERGY]), false); + } else if (bend->getName() != "RBEND3D") { + throw OpalException("OpalRBend3D::update", + "RBend3D requires non-zero DESIGNENERGY"); } bend->setFullGap(Attributes::getReal(itsAttr[GAP])); diff --git a/src/Elements/OpalSBend.cpp b/src/Elements/OpalSBend.cpp index 785c1bf3d17951b734bc898323be340f58d297e2..2ec776a807aa5568bbd0e2005e294229f88bbb4a 100644 --- a/src/Elements/OpalSBend.cpp +++ b/src/Elements/OpalSBend.cpp @@ -24,7 +24,6 @@ #include "Structure/OpalWake.h" #include "Structure/ParticleMatterInteraction.h" #include "Utilities/OpalException.h" -#include <cmath> OpalSBend::OpalSBend(): OpalBend("SBEND", @@ -47,10 +46,8 @@ OpalSBend::OpalSBend(const std::string &name, OpalSBend *parent): OpalSBend::~OpalSBend() { - if(owk_m) - delete owk_m; - if(parmatint_m) - delete parmatint_m; + delete owk_m; + delete parmatint_m; } @@ -131,7 +128,7 @@ void OpalSBend::update() { double k0s = itsAttr[K0S] ? Attributes::getReal(itsAttr[K0S]) : 0.0; //JMJ 4/10/2000: above line replaced // length ? angle / length : angle; - // to avoid closed orbit created by SBEND with defalt K0. + // to avoid closed orbit created by SBEND with default K0. field.setNormalComponent(1, factor * k0); field.setSkewComponent(1, factor * Attributes::getReal(itsAttr[K0S])); field.setNormalComponent(2, factor * Attributes::getReal(itsAttr[K1])); @@ -163,11 +160,11 @@ void OpalSBend::update() { if(itsAttr[GREATERTHANPI]) throw OpalException("OpalSBend::update", - "GREATERTHANPI not supportet any more"); + "GREATERTHANPI not supported anymore"); if(itsAttr[ROTATION]) throw OpalException("OpalSBend::update", - "ROTATION not supportet any more; use PSI instead"); + "ROTATION not supported anymore; use PSI instead"); if(itsAttr[FMAPFN]) bend->setFieldMapFN(Attributes::getString(itsAttr[FMAPFN])); @@ -183,15 +180,18 @@ void OpalSBend::update() { bend->setExitAngle(e2); // Units are eV. - if(itsAttr[DESIGNENERGY]) { + if(itsAttr[DESIGNENERGY] && Attributes::getReal(itsAttr[DESIGNENERGY]) != 0.0) { bend->setDesignEnergy(Attributes::getReal(itsAttr[DESIGNENERGY]), false); + } else if (bend->getName() != "SBEND") { + throw OpalException("OpalSBend::update", + "SBend requires non-zero DESIGNENERGY"); } bend->setFullGap(Attributes::getReal(itsAttr[GAP])); if(itsAttr[APERT]) - throw OpalException("OpalRBend::fillRegisteredAttributes", - "APERTURE in RBEND not supported; use GAP and HAPERT instead"); + throw OpalException("OpalSBend::update", + "APERTURE in SBEND not supported; use GAP and HAPERT instead"); if(itsAttr[HAPERT]) { double hapert = Attributes::getReal(itsAttr[HAPERT]);