Commit 2e67875d authored by frey_m's avatar frey_m

modified: ClosedOrbitFinder.h

modified:   Harmonics.h
modified:   SigmaGenerator.h
deleted:    math.h

Matthias: Remove math.h that just defined the sign function. It is replaced in SigmaGenerator.h and Harmonics.h. Update of exception-handling in ClosedOrbitFinder.h
parent af82a7a8
......@@ -284,18 +284,17 @@ ClosedOrbitFinder<Value_type, Size_type, Stepper>::ClosedOrbitFinder(value_type
rmin_m(rmin), ntheta_m(ntheta), nradial_m(nradial), dr_m(dr), lastOrbitVal_m(0.0), lastMomentumVal_m(0.0),
vertOscDone_m(false), fieldmap_m(fieldmap), domain_m(domain), stepper_m(), rguess_m(rguess)
{
if ( Emin_m > Emax_m )
throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()",
"Incorrect cyclotron energy (MeV) bounds: Maximum cyclotron energy smaller than minimum cyclotron energy.");
// if ( E_m < Emin_m )
// throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()",
// "Kinetic energy (" + std::to_string(E_m) + " MeV) smaller than minimum cyclotron energy (" + std::to_string(Emin_m) + " MeV)");
if ( Emin_m > Emax_m )
throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()",
"Incorrect cyclotron energy (MeV) bounds: Maximum cyclotron energy smaller than minimum cyclotron energy.");
// // Even if the numbers are equal --> if statement is true.
// if ( E_m < Emin_m )
// throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()", "Kinetic energy smaller than minimum cyclotron energy");
if ( E_m > Emax_m )
throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()",
"Kinetic energy (" + std::to_string(E_m) + " MeV) bigger than maximum cyclotron energy (" + std::to_string(Emax_m) + " MeV)");
if ( E_m > Emax_m )
throw OpalException("ClosedOrbitFinder::ClosedOrbitFinder()", "Kinetic energy exceeds cyclotron energy");
// velocity: beta = v/c = sqrt(1-1/(gamma*gamma))
if (gamma_m == 0)
......
......@@ -21,8 +21,6 @@
#include <boost/numeric/ublas/matrix.hpp>
#include "matrix_vector_operation.h"
#include "math.h"
// #include "physics.h"
template<typename Value_type, typename Size_type>
class Harmonics
......@@ -531,7 +529,10 @@ typename Harmonics<Value_type, Size_type>::matrix_type Harmonics<Value_type, Siz
M(1,0) = - s * fx / r;
M(2,2) = M(3,3) = C;
M(2,3) = S * r / fy;
M(3,2) = matt::sign(k) * S * fy / r;
value_type sign = (std::signbit(k)) ? value_type(-1) : value_type(1);
M(3,2) = sign * S * fy / r;
M(4,5) = l / gam2 - r / (1.0 + k) * (phi - s / fx);
M(4,0)= - (M(1,5) = s / fx);
M(4,1)= - (M(0,5) = r * (1.0 - c) / (1.0 + k));
......
......@@ -40,7 +40,6 @@
#include <boost/numeric/odeint/stepper/runge_kutta4.hpp>
#include "math.h"
#include "rdm.h"
#include "matrix_vector_operation.h"
......@@ -960,8 +959,10 @@ typename SigmaGenerator<Value_type, Size_type>::matrix_type SigmaGenerator<Value
*/
value_type cosy = 0.5 * (M(2,2) + M(3,3));
value_type invsiny = matt::sign(M(2,3)) / std::sqrt(std::fabs( 1.0 - cosy * cosy));
value_type sign = (std::signbit(M(2,3))) ? value_type(-1) : value_type(1);
value_type invsiny = sign / std::sqrt(std::fabs( 1.0 - cosy * cosy));
value_type alphay = 0.5 * (M(2,2) - M(3,3)) * invsiny;
value_type betay = M(2,3) * invsiny;
......
/**
* @file math.h
* Mathematical functions that aren't part of the standard of C++
*
* @author Matthias Frey
* @version 1.0
*/
#ifndef MATH_H
#define MATH_H
#include <cmath>
/*!
* \addtogroup matt
* @{
*/
/// @brief Defines additional mathematical functions
namespace matt {
/// Computes the sign of the input argument
template<typename T>
T sign(const T val) {
return (std::signbit(val)) ? T(-1) : T(1);
}
}
/*! @} End of Doxygen Groups*/
#endif
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