Commit 534d1bfe authored by snuverink_j's avatar snuverink_j
Browse files

Merge branch '546-bend-without-designenergy-gives-infinite-loop' into 'master'

Resolve "Bend without DESIGNENERGY gives infinite loop"

Closes #546

See merge request !394
parents 50bf3359 84f32ef3
......@@ -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");
}
}
......
......@@ -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]));
......
......@@ -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]));
......
......@@ -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]);
......
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