Commit 26921708 authored by frey_m's avatar frey_m
Browse files

ParallelCyclotronTracker: Removal of duplicated code

parent 99d8a45c
This diff is collapsed.
......@@ -22,6 +22,7 @@
#include "Structure/DataSink.h"
#include "AbsBeamline/ElementBase.h"
#include <vector>
#include <tuple>
#include "Steppers/Steppers.h"
......@@ -55,6 +56,8 @@ public:
BUNCH = 2
};
typedef std::vector<double> dvector_t;
typedef std::vector<int> ivector_t;
typedef std::pair<double[8], Component *> element_pair;
typedef std::pair<ElementBase::ElementType, element_pair> type_pair;
typedef std::list<type_pair *> beamline_list;
......@@ -260,11 +263,9 @@ private:
double PathLength_m;
void Tracker_LF();
void Tracker_RK4();
void Tracker_MTS();
void MtsTracker();
void Tracker_Generic();
void GenericTracker();
bool getFieldsAtPoint(const double &t, const size_t &Pindex, Vector_t &Efield, Vector_t &Bfield);
/*
......@@ -355,7 +356,7 @@ private:
bool checkGapCross(Vector_t Rold, Vector_t Rnew, RFCavity * rfcavity, double &DistOld);
bool RFkick(RFCavity * rfcavity, const double t, const double dt, const int Pindex);
bool getTunes(std::vector<double> &t, std::vector<double> &r, std::vector<double> &z, int lastTurn, double &nur, double &nuz);
bool getTunes(dvector_t &t, dvector_t &r, dvector_t &z, int lastTurn, double &nur, double &nuz);
IpplTimings::TimerRef IntegrationTimer_m;
IpplTimings::TimerRef DumpTimer_m ;
......@@ -493,9 +494,18 @@ private:
stepper::INTEGRATOR stepper_m;
void update_m(double& t, const double& dt, const bool& dumpEachTurn);
std::tuple<double, double, double> initializeTracking_m();
void finalizeTracking_m(dvector_t& Ttime,
dvector_t& Tdeltr,
dvector_t& Tdeltz,
ivector_t& TturnNumber);
void seoMode_m(double& t, const double dt, bool& dumpEachTurn,
std::vector<double>& Ttime, std::vector<double>& Tdeltr,
std::vector<double>& Tdeltz, std::vector<int>& TturnNumber);
dvector_t& Ttime, dvector_t& Tdeltr,
dvector_t& Tdeltz, ivector_t& TturnNumber);
void singleMode_m(double& t, const double dt, bool& dumpEachTurn, double& oldReferenceTheta);
......@@ -519,6 +529,11 @@ private:
void computeSpaceChargeFields_m();
bool computeExternalFields_m(const size_t& i,
const double& t,
Vector_t& Efield,
Vector_t& Bfield);
void injectBunch_m(bool& flagTransition);
};
......
#include "BorisPusher.h"
template <typename FieldFunction, typename ... Arguments>
bool LF2<FieldFunction, Arguments ...>::advance(PartBunch* bunch,
const size_t& i,
......@@ -66,21 +68,12 @@ bool LF2<FieldFunction, Arguments ...>::kick_m(PartBunch* bunch, const size_t& i
double const q = bunch->Q[0] / Physics::q_e; // For now all particles have the same charge
double const M = bunch->M[0] * 1.0e9; // For now all particles have the same rest energy
double const h12Halfqc_M = 0.5 * h * q * Physics::c / M;
double const h12Halfqcc_M = h12Halfqc_M * Physics::c;
// Half step E
bunch->P[i] += h12Halfqc_M * externalE;
// Full step B
double const gamma = sqrt(1.0 + dot(bunch->P[i], bunch->P[i]));
Vector_t const r = h12Halfqcc_M * externalB / gamma;
Vector_t const w = bunch->P[i] + cross(bunch->P[i], r);
Vector_t const s = 2.0 / (1.0 + dot(r, r)) * r;
bunch->P[i] += cross(w, s);
// Half step E
bunch->P[i] += h12Halfqc_M * externalE;
BorisPusher pusher;
pusher.kick(bunch->R[i], bunch->P[i],
externalE, externalB,
h, M, q);
return true;
}
......@@ -3,8 +3,6 @@
#include "RK4.h"
#include "LF2.h"
#include "MTS.h"
namespace stepper {
......
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