Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 26921708 authored by frey_m's avatar frey_m
Browse files

ParallelCyclotronTracker: Removal of duplicated code

parent 99d8a45c
No related branches found
No related tags found
1 merge request!15Add Stepper classes to ParallelCyclotronTracker
This diff is collapsed.
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "Structure/DataSink.h" #include "Structure/DataSink.h"
#include "AbsBeamline/ElementBase.h" #include "AbsBeamline/ElementBase.h"
#include <vector> #include <vector>
#include <tuple>
#include "Steppers/Steppers.h" #include "Steppers/Steppers.h"
...@@ -55,6 +56,8 @@ public: ...@@ -55,6 +56,8 @@ public:
BUNCH = 2 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<double[8], Component *> element_pair;
typedef std::pair<ElementBase::ElementType, element_pair> type_pair; typedef std::pair<ElementBase::ElementType, element_pair> type_pair;
typedef std::list<type_pair *> beamline_list; typedef std::list<type_pair *> beamline_list;
...@@ -260,11 +263,9 @@ private: ...@@ -260,11 +263,9 @@ private:
double PathLength_m; double PathLength_m;
void Tracker_LF(); void MtsTracker();
void Tracker_RK4();
void Tracker_MTS();
void Tracker_Generic(); void GenericTracker();
bool getFieldsAtPoint(const double &t, const size_t &Pindex, Vector_t &Efield, Vector_t &Bfield); bool getFieldsAtPoint(const double &t, const size_t &Pindex, Vector_t &Efield, Vector_t &Bfield);
/* /*
...@@ -355,7 +356,7 @@ private: ...@@ -355,7 +356,7 @@ private:
bool checkGapCross(Vector_t Rold, Vector_t Rnew, RFCavity * rfcavity, double &DistOld); 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 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 IntegrationTimer_m;
IpplTimings::TimerRef DumpTimer_m ; IpplTimings::TimerRef DumpTimer_m ;
...@@ -493,9 +494,18 @@ private: ...@@ -493,9 +494,18 @@ private:
stepper::INTEGRATOR stepper_m; 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, void seoMode_m(double& t, const double dt, bool& dumpEachTurn,
std::vector<double>& Ttime, std::vector<double>& Tdeltr, dvector_t& Ttime, dvector_t& Tdeltr,
std::vector<double>& Tdeltz, std::vector<int>& TturnNumber); dvector_t& Tdeltz, ivector_t& TturnNumber);
void singleMode_m(double& t, const double dt, bool& dumpEachTurn, double& oldReferenceTheta); void singleMode_m(double& t, const double dt, bool& dumpEachTurn, double& oldReferenceTheta);
...@@ -519,6 +529,11 @@ private: ...@@ -519,6 +529,11 @@ private:
void computeSpaceChargeFields_m(); void computeSpaceChargeFields_m();
bool computeExternalFields_m(const size_t& i,
const double& t,
Vector_t& Efield,
Vector_t& Bfield);
void injectBunch_m(bool& flagTransition); void injectBunch_m(bool& flagTransition);
}; };
......
#include "BorisPusher.h"
template <typename FieldFunction, typename ... Arguments> template <typename FieldFunction, typename ... Arguments>
bool LF2<FieldFunction, Arguments ...>::advance(PartBunch* bunch, bool LF2<FieldFunction, Arguments ...>::advance(PartBunch* bunch,
const size_t& i, const size_t& i,
...@@ -66,21 +68,12 @@ bool LF2<FieldFunction, Arguments ...>::kick_m(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 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 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 BorisPusher pusher;
bunch->P[i] += h12Halfqc_M * externalE;
pusher.kick(bunch->R[i], bunch->P[i],
// Full step B externalE, externalB,
double const gamma = sqrt(1.0 + dot(bunch->P[i], bunch->P[i])); h, M, q);
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;
return true; return true;
} }
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include "RK4.h" #include "RK4.h"
#include "LF2.h" #include "LF2.h"
#include "MTS.h"
namespace stepper { namespace stepper {
......
  • frey_m @frey_m

    mentioned in issue #1

    ·

    mentioned in issue #1

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment