Commit 73a43dc1 authored by snuverink_j's avatar snuverink_j
Browse files

general code improvements, cleaning and typos

parent 61691d0f
......@@ -7,7 +7,7 @@
// ------------------------------------------------------------------------
//
// Class: ParallelCyclotronTracker
// The class for tracking particles with 3D space charge in Cyclotrons and FFAG's
// The class for tracking particles with 3D space charge in Cyclotrons and FFAGs
//
// ------------------------------------------------------------------------
//
......@@ -17,18 +17,19 @@
// ------------------------------------------------------------------------
#include "Algorithms/ParallelCyclotronTracker.h"
#include "Algorithms/PolynomialTimeDependence.h"
#include "Elements/OpalPolynomialTimeDependence.h"
#include <cfloat>
#include <iostream>
#include <fstream>
#include <iostream>
#include <limits>
#include <vector>
#include "AbstractObjects/Element.h"
#include "AbstractObjects/OpalData.h"
#include "AbsBeamline/CCollimator.h"
#include "AbsBeamline/Corrector.h"
#include "AbsBeamline/Cyclotron.h"
#include "AbsBeamline/CyclotronValley.h"
#include "AbsBeamline/Degrader.h"
#include "AbsBeamline/Diagnostic.h"
#include "AbsBeamline/Drift.h"
......@@ -46,6 +47,7 @@
#include "AbsBeamline/PluginElement.h"
#include "AbsBeamline/Probe.h"
#include "AbsBeamline/RBend.h"
#include "AbsBeamline/Ring.h"
#include "AbsBeamline/RFCavity.h"
#include "AbsBeamline/RFQuadrupole.h"
#include "AbsBeamline/SBend.h"
......@@ -54,27 +56,17 @@
#include "AbsBeamline/Separator.h"
#include "AbsBeamline/Septum.h"
#include "AbsBeamline/Solenoid.h"
#include "AbsBeamline/CyclotronValley.h"
#include "AbsBeamline/Stripper.h"
#include "AbsBeamline/VariableRFCavity.h"
#include "AbsBeamline/VariableRFCavityFringeField.h"
#include "AbstractObjects/Element.h"
#include "Beamlines/FlaggedBeamline.h"
#include "Elements/OpalBeamline.h"
#include "AbsBeamline/Ring.h"
#include "Algorithms/Ctunes.h"
#include "Algorithms/PolynomialTimeDependence.h"
#include "BeamlineGeometry/Euclid3D.h"
#include "BeamlineGeometry/PlanarArcGeometry.h"
#include "BeamlineGeometry/RBendGeometry.h"
#include "BeamlineGeometry/StraightGeometry.h"
#include "Beamlines/Beamline.h"
#include "Beamlines/FlaggedBeamline.h"
#include "Fields/BMultipoleField.h"
#include "FixedAlgebra/FTps.h"
#include "FixedAlgebra/FTpsMath.h"
#include "FixedAlgebra/FVps.h"
#include "Elements/OpalBeamline.h"
#include "Physics/Physics.h"
......@@ -87,21 +79,12 @@
#include "Structure/H5PartWrapperForPC.h"
#include "Structure/BoundaryGeometry.h"
#include "Algorithms/Ctunes.h"
#include <cassert>
#include <hdf5.h>
#include "H5hut.h"
//FIXME Remove headers and dynamic_cast in readOneBunchFromFile
#include "Algorithms/PartBunch.h"
#ifdef ENABLE_AMR
#include "Algorithms/AmrPartBunch.h"
#endif
class Beamline;
class PartData;
using Physics::pi;
using Physics::q_e;
......@@ -112,12 +95,8 @@ Vector_t const ParallelCyclotronTracker::xaxis = Vector_t(1.0, 0.0, 0.0);
Vector_t const ParallelCyclotronTracker::yaxis = Vector_t(0.0, 1.0, 0.0);
Vector_t const ParallelCyclotronTracker::zaxis = Vector_t(0.0, 0.0, 1.0);
//#define PSdim 6
extern Inform *gmsg;
// typedef FVector<double, PSdim> Vector;
/**
* Constructor ParallelCyclotronTracker
*
......@@ -228,7 +207,6 @@ ParallelCyclotronTracker::~ParallelCyclotronTracker() {
}
/// set the working sub-mode for multi-bunch mode: "FORCE" or "AUTO"
inline
void ParallelCyclotronTracker::setMultiBunchMode(const std::string& mbmode)
{
if ( mbmode.compare("FORCE") == 0 ) {
......@@ -431,8 +409,8 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
*gmsg << "* (Use BANDRF type cyclotron and use RFMAPFN to load both magnetic" << endl;
*gmsg << "* and electric fields, setting SUPERPOSE to an array of TRUE values.)" << endl;
*gmsg << "* 2.) For high currents it is strongly recommended to use the SAAMG fieldsolver," << endl;
*gmsg << "* FFT does not give the correct results (boundaty conditions are missing)." << endl;
*gmsg << "* 3.) The whole geometry will be meshed and used for the fieldsolve." << endl;
*gmsg << "* FFT does not give the correct results (boundary conditions are missing)." << endl;
*gmsg << "* 3.) The whole geometry will be meshed and used for the fieldsolver." << endl;
*gmsg << "* There will be no transformations of the bunch into a local frame und consequently," << endl;
*gmsg << "* the problem will be treated non-relativistically!" << endl;
*gmsg << "* (This is not an issue for spiral inflectors as they are typically < 100 keV/amu.)" << endl;
......@@ -3049,7 +3027,7 @@ std::tuple<double, double, double> ParallelCyclotronTracker::initializeTracking_
break;
case MODE::UNDEFINED:
default:
throw OpalException("ParallelCyclotronTracker::GenericTracker()",
throw OpalException("ParallelCyclotronTracker::initializeTracking_m()",
"No such tracking mode.");
}
......@@ -3086,10 +3064,8 @@ void ParallelCyclotronTracker::finalizeTracking_m(dvector_t& Ttime,
break;
}
case MODE::SINGLE:
{
closeFiles();
// no break, continue here!
}
// fall through
case MODE::BUNCH: // we do nothing
case MODE::UNDEFINED:
default:
......@@ -3242,7 +3218,7 @@ void ParallelCyclotronTracker::singleMode_m(double& t, const double dt,
void ParallelCyclotronTracker::bunchMode_m(double& t, const double dt, bool& dumpEachTurn) {
// Flag for transition from single-bunch to multi-bunches mode
// Flag for transition from single-bunch to multi-bunches mode
static bool flagTransition = false;
// single particle dumping
......@@ -3463,7 +3439,7 @@ void ParallelCyclotronTracker::computeSpaceChargeFields_m() {
itsBunch_m->Bf = Vector_t(0.0);
itsBunch_m->Ef = Vector_t(0.0);
if (spiral_flag and itsBunch_m->getFieldSolverType() == "SAAMG") {
if (spiral_flag && itsBunch_m->getFieldSolverType() == "SAAMG") {
// --- Single bunch mode with spiral inflector --- //
// If we are doing a spiral inflector simulation and are using the SAAMG solver
......@@ -3618,11 +3594,11 @@ void ParallelCyclotronTracker::injectBunch_m(bool& flagTransition) {
Vector_t Rmean = itsBunch_m->get_centroid(); // m
RThisTurn_m = sqrt(pow(Rmean[0], 2.0) + pow(Rmean[1], 2.0));
RThisTurn_m = std::hypot(Rmean[0],Rmean[1]);
Vector_t Rrms = itsBunch_m->get_rrms(); // m
double XYrms = sqrt(pow(Rrms[0], 2.0) + pow(Rrms[1], 2.0));
double XYrms = std::hypot(Rrms[0], Rrms[1]);
// If the distance between two neighboring bunches is less than 5 times of its 2D rms size
// start multi-bunch simulation, fill current phase space to initialR and initialP arrays
......
......@@ -28,7 +28,6 @@
#include "Structure/MultiBunchDump.h"
class BMultipoleField;
template <class T, unsigned Dim>
class PartBunchBase;
......@@ -59,7 +58,7 @@ public:
FORCE = 1,
AUTO = 2
};
// multi-bunch binning type
enum class MB_BINNING {
GAMMA = 0,
......@@ -77,8 +76,8 @@ public:
// The particle bunch tracked is initially empty.
// If [b]revBeam[/b] is true, the beam runs from s = C to s = 0.
// If [b]revTrack[/b] is true, we track against the beam.
explicit ParallelCyclotronTracker(const Beamline &bl, const PartData &data,
bool revBeam, bool revTrack);
ParallelCyclotronTracker(const Beamline &bl, const PartData &data,
bool revBeam, bool revTrack);
/// Constructor.
// The beam line to be tracked is "bl".
......@@ -86,10 +85,10 @@ public:
// The particle bunch tracked is taken from [b]bunch[/b].
// If [b]revBeam[/b] is true, the beam runs from s = C to s = 0.
// If [b]revTrack[/b] is true, we track against the beam.
explicit ParallelCyclotronTracker(const Beamline &bl, PartBunchBase<double, 3> *bunch, DataSink &ds,
const PartData &data, bool revBeam,
bool revTrack, int maxSTEPS,
int timeIntegrator, int numBunch);
ParallelCyclotronTracker(const Beamline &bl, PartBunchBase<double, 3> *bunch, DataSink &ds,
const PartData &data, bool revBeam,
bool revTrack, int maxSTEPS,
int timeIntegrator, int numBunch);
virtual ~ParallelCyclotronTracker();
......@@ -220,8 +219,9 @@ public:
inline void setLastDumpedStep(const int para) {lastDumpedStep_m = para ; }
/// set the control parameter for "AUTO" sub-mode
inline void setParaAutoMode(const double para) {CoeffDBunches_m = para; }
inline void setParaAutoMode(const double para) {CoeffDBunches_m = para; }
///@{ Method for restart
inline void setPr(double x) {referencePr = x;}
inline void setPt(double x) {referencePt = x;}
inline void setPz(double x) {referencePz = x;}
......@@ -232,7 +232,7 @@ public:
inline void setPhi(double x) {referencePhi = x;}
inline void setPsi(double x) {referencePsi = x;}
inline void setPreviousH5Local(bool x) {previousH5Local = x;}
///@}
void bgf_main_collision_test();
void initializeBoundaryGeometry();
......
......@@ -391,7 +391,7 @@ bool Cyclotron::apply(const Vector_t &R, const Vector_t &P, const double &t, Vec
double tet_rad = tet;
// the actual angle of particle
// the actual angle of particle in degree
tet = tet / pi * 180.0;
// Necessary for gap phase output -DW
......@@ -713,15 +713,13 @@ bool Cyclotron::interpolate(const double& rad,
r2t2 = idx(ir + 1, it + 1);
}
double bzf = 0.0 /*, bzcub = 0.0*/;
if((it >= 0) && (ir >= 0) && (it < Bfield.ntetS) && (ir < Bfield.nrad)) {
// B_{z}
bzf = Bfield.bfld[r1t1] * wr2 * wt2 +
Bfield.bfld[r2t1] * wr1 * wt2 +
Bfield.bfld[r1t2] * wr2 * wt1 +
Bfield.bfld[r2t2] * wr1 * wt1;
double bzf = Bfield.bfld[r1t1] * wr2 * wt2 +
Bfield.bfld[r2t1] * wr1 * wt2 +
Bfield.bfld[r1t2] * wr2 * wt1 +
Bfield.bfld[r2t2] * wr1 * wt1;
bzint = /*- */bzf ;
......
......@@ -22,7 +22,6 @@
// ------------------------------------------------------------------------
#include "AbsBeamline/Component.h"
#include "BeamlineGeometry/PlanarArcGeometry.h"
#include <string>
#include <vector>
......
......@@ -53,7 +53,7 @@ namespace polynomial {
class DifferentialOperatorTwo {
public:
/** Default constructor, initalises identity operator */
/** Default constructor, initialises identity operator */
DifferentialOperatorTwo();
/** Constructor, initialises operator with zero polynomials and
* derivatives up to xDerivatives in x and sDerivatives in s
......
......@@ -53,7 +53,7 @@ class PolynomialSum {
public:
/** Default constructor, initialises empty sum */
PolynomialSum();
/** Constructor, initalises sum with a single polynomial from input
/** Constructor, initialises sum with a single polynomial from input
* \param polynomial -> The polynomial sum is initialised with this \n
* polynomial as the first and only term
*/
......
......@@ -595,7 +595,7 @@ void PartBunchBase<T, Dim>::boundp() {
}
if (volume < 1e-21 && getTotalNum() > 1 && std::abs(sum(Q)) > 0.0) {
WARNMSG(level1 << "!!! Extremly high particle density detected !!!" << endl);
WARNMSG(level1 << "!!! Extremely high particle density detected !!!" << endl);
}
//INFOMSG("It is a full boundp hz= " << hr_m << " rmax= " << rmax_m << " rmin= " << rmin_m << endl);
......
......@@ -21,16 +21,16 @@
// ------------------------------------------------------------------------
#include "AbsBeamline/Cyclotron.h"
#include "BeamlineGeometry/PlanarArcGeometry.h"
#include "Fields/BMultipoleField.h"
#include "MemoryManagement/Pointer.h"
class BMultipoleField;
// Class CyclotronWrapper
// ------------------------------------------------------------------------
/// Representation of a perturbed sectorr bend.
// A CyclotronWrapper represents a unique instance of a bend magnet
/// Representation of a perturbed cyclotron.
// A CyclotronWrapper represents a unique instance of a cyclotron
// in the accelerator model. It defines imperfections of the field,
// related to an ``ideal'' magnet contained in the wrapper.
......
......@@ -29,7 +29,7 @@ class BMultipoleField;
// Class SBendWrapper
// ------------------------------------------------------------------------
/// Representation of a perturbed sectorr bend.
/// Representation of a perturbed sector bend.
// A SBendWrapper represents a unique instance of a bend magnet
// in the accelerator model. It defines imperfections of the field,
// related to an ``ideal'' magnet contained in the wrapper.
......
......@@ -22,10 +22,6 @@
#include "Fields/StaticMagneticField.h"
class Channel;
class ElementImage;
// Class BMultipoleField
// ------------------------------------------------------------------------
/// The magnetic field of a multipole.
......
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