Commit bc9cf059 authored by kraus's avatar kraus
Browse files

complete autophasetracker but untested

parent 67769cc8
This diff is collapsed.
......@@ -47,7 +47,11 @@ class ClassicField;
class AutophaseTracker: public DefaultVisitor {
public:
AutophaseTracker(const Beamline &beamline, const PartData &ref, const double &T0);
AutophaseTracker(const Beamline &beamline,
const PartData &ref,
const double &T0,
double initialR,
double initialP);
virtual ~AutophaseTracker();
FieldList executeAutoPhaseForSliceTracker();
......@@ -84,13 +88,27 @@ private:
ClassicField* checkCavity(double s);
void updateRFElement(std::string elName, double maxPhi);
void updateAllRFElements(double phiShift);
void adjustCavityPhase(Component *);
double APtrack(Component *cavity, double cavity_start, const double &phi) const;
void track(double uptoSPos,
size_t &step,
std::queue<double> &dtAllTracks,
std::queue<double> &maxZ,
std::queue<unsigned long long> &maxTrackSteps);
double getGlobalPhaseShift();
void handleOverlappingMonitors();
void prepareSections();
double getEnergyMeV(const Vector_t &p);
void evaluateField();
Component* getNextCavity(const Component *current);
void advanceTime(size_t & step, const size_t maxSteps, const double beginNextCavity);
double guessCavityPhase(Component *);
double optimizeCavityPhase(Component *,
double initialPhase,
size_t currentStep,
double dt);
double getBeginCavity(Component *);
double getEndCavity(Component *);
OpalBeamline itsOpalBeamline_m;
FieldList cavities_m;
......@@ -103,12 +121,24 @@ private:
};
inline void AutophaseTracker::visitBeamline(const Beamline &bl) {
inline
void AutophaseTracker::visitBeamline(const Beamline &bl) {
bl.iterate(*dynamic_cast<BeamlineVisitor *>(this), false);
}
inline double AutophaseTracker::getEnergyMeV(const Vector_t &p) {
inline
double AutophaseTracker::getEnergyMeV(const Vector_t &p) {
return (sqrt(dot(p, p) + 1.0) - 1.0) * itsBunch_m.getM() * 1e-6;
}
inline
double AutophaseTracker::getBeginCavity(Component* comp) {
if (comp == NULL) return -1e6;
double startComp = 0.0, endComp = 0.0;
comp->getDimensions(startComp, endComp);
return startComp;
}
#endif
\ No newline at end of file
......@@ -891,9 +891,19 @@ void ParallelTTracker::doAutoPhasing() {
<< " phi= " << (*it).second << " (rad)" << endl);
}
} else {
AutophaseTracker ap(itsBeamline_m, itsReference, itsBunch->getT());
ap.execute(dtAllTracks_m, zStop_m, localTrackSteps_m);
#ifdef NEWTRACKER
Vector_t meanP = itsBunch->get_pmean();
Vector_t meanR = itsBunch->get_rmean();
AutophaseTracker apTracker(itsBeamline_m,
itsReference,
itsBunch->getT(),
meanR(2),
meanP(2));
apTracker.execute(dtAllTracks_m,
zStop_m,
localTrackSteps_m);
#else
int tag = 101;
int Parent = 0;
......@@ -963,6 +973,7 @@ void ParallelTTracker::doAutoPhasing() {
itsBunch->pop();
itsDataSink_m->storeCavityInformation();
}
#endif
}
updateAllRFElements(OpalData::getInstance()->getGlobalPhaseShift());
INFOMSG("finished autophasing" << endl);
......@@ -3260,4 +3271,4 @@ Vector_t ParallelTTracker::calcMeanP() const {
}
reduce(meanP, meanP, OpAddAssign());
return meanP / Vector_t(itsBunch->getTotalNum());
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ OpalBeamline::~OpalBeamline() {
CompVec OpalBeamline::dummy_list_m = CompVec();
OpalSection OpalBeamline::dummy_section_m = OpalSection(dummy_list_m, 0., 0.);
CompVec &OpalBeamline::getPredecessors(const std::shared_ptr<Component> element) {
CompVec &OpalBeamline::getPredecessors(std::shared_ptr<const Component> element) {
size_t index;
bool found = false;
for(index = 0; index < sections_m.size(); ++ index) {
......@@ -50,10 +50,13 @@ CompVec &OpalBeamline::getPredecessors(const std::shared_ptr<Component> element)
}
CompVec &OpalBeamline::getSuccessors(const std::shared_ptr<Component> element) {
CompVec &OpalBeamline::getSuccessors(std::shared_ptr<const Component> element) {
size_t index;
bool found = false;
if (element == NULL)
return sections_m[0].getElements();
for(index = 0; index < sections_m.size(); ++ index) {
if(sections_m[index].find(element)) {
found = true;
......
......@@ -43,8 +43,8 @@ public:
OpalBeamline();
~OpalBeamline();
CompVec &getPredecessors(const std::shared_ptr<Component>);
CompVec &getSuccessors(const std::shared_ptr<Component>);
CompVec &getPredecessors(std::shared_ptr<const Component>);
CompVec &getSuccessors(std::shared_ptr<const Component>);
OpalSection &getSectionAt(const Vector_t &, long &);
OpalSection &getSection(const unsigned int &);
void getSectionIndexAt(const Vector_t &, long &) const;
......
......@@ -94,7 +94,7 @@ void OpalSection::setOrientation(const Vector_t &angle) {
updateEndCache();
}
bool OpalSection::find(const std::shared_ptr<Component> check) const {
bool OpalSection::find(std::shared_ptr<const Component> check) const {
bool found = false;
for(size_t index = 0; index < elements_m.size(); ++ index) {
if(elements_m[index] == check) {
......
......@@ -43,7 +43,7 @@ public:
const bool &hasSurfacePhysics() const;
void push_back(std::shared_ptr<Component>);
bool find(const std::shared_ptr<Component>) const;
bool find(std::shared_ptr<const Component>) const;
CompVec &getElements();
void print(Inform &) const;
......
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