Commit cf7e3803 authored by adelmann's avatar adelmann 🎗
Browse files

fist part to solve the restart problem when dumping in local coordinates

parent cdbf4f7b
......@@ -152,6 +152,13 @@ public:
/// set multipacting flag
virtual void setMpacflg(bool mpacflg) {};
virtual void setPr(double x) { } ;
virtual void setR(double x) { } ;
virtual void setTheta(double x) { } ;
virtual void setBeGa(double x) { } ;
// standing wave structures
FieldList cavities_m;
......
......@@ -282,29 +282,37 @@ void ParallelCyclotronTracker::visitCyclotron(const Cyclotron &cycl) {
Cyclotron *elptr = dynamic_cast<Cyclotron *>(cycl.clone());
myElements.push_back(elptr);
double ri = elptr->getRinit();
*gmsg << "* RINIT= " << ri << " [mm]" << endl;
referenceR = ri;
double pri = elptr->getPRinit();
//msg << "PRINIT= " << pri << " [CU]" << endl;
referencePr = pri;
double phii = elptr->getPHIinit();
*gmsg << "* PHIINIT= " << phii << " [deg]" << endl;
referenceTheta = phii;
if(referenceTheta <= -180.0 || referenceTheta > 180.0) {
referencePz = 0.0;
if(!OpalData::getInstance()->inRestartRun()) {
// get values from cyclotron command
referenceR = elptr->getRinit();
referencePr = elptr->getPRinit();
referenceTheta = elptr->getPHIinit();
//msg << "PRINIT= " << pri << " [CU]" << endl;
if(referenceTheta <= -180.0 || referenceTheta > 180.0) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron", "PHIINIT is out of [-180, 180)!");
}
referencePtot = itsReference.getGamma() * itsReference.getBeta();
}
else {
// in case of a restart the values from the h5 file are already within this class
if(referenceTheta <= -180.0 || referenceTheta > 180.0) {
throw OpalException("Error in ParallelCyclotronTracker::visitCyclotron", "PHIINIT is out of [-180, 180)!");
}
referencePtot = bega;
}
referencePz = 0.0;
referencePtot = itsReference.getGamma() * itsReference.getBeta();
referencePt = sqrt(referencePtot * referencePtot - referencePr * referencePr);
if(referencePtot < 0.0) referencePt *= -1.0;
sinRefTheta_m = sin(phii / 180.0 * pi);
cosRefTheta_m = cos(phii / 180.0 * pi);
sinRefTheta_m = sin(referenceTheta / 180.0 * pi);
cosRefTheta_m = cos(referenceTheta / 180.0 * pi);
*gmsg << "* RINIT= " << referenceR << " [mm]" << endl;
*gmsg << "* PHIINIT= " << referenceTheta << " [deg]" << endl;
*gmsg << "* Initial gamma = " << itsReference.getGamma() << endl;
......
......@@ -165,6 +165,11 @@ public:
/// set the control parameter for "AUTO" sub-mode
inline void setParaAutoMode(const double para) {CoeffDBunches_m = para; }
inline void setPr(double x) {referencePr = x;}
inline void setR(double x) {referenceR = x;}
inline void setTheta(double x) {referenceTheta = x;}
inline void setBeGa(double x) {bega = x;}
private:
// Not implemented.
......@@ -188,7 +193,7 @@ private:
/// The scale factor for dimensionless variables
double scaleFactor_m;
double bega;
double referenceR;
double referenceTheta;
double referenceZ;
......
......@@ -176,6 +176,11 @@ public:
void SetDistType();
void ShiftBeam(double &maxTOrZ, double &minTOrZ);
// in case if OPAL-cycl in restart mode
double GetPr() {return referencePr_m;}
double GetR() {return referenceR_m;}
double GetTheta() {return referenceTheta_m;}
double GetBeGa() {return bega_m;}
private:
......@@ -383,6 +388,12 @@ private:
double sigmaFall_m;
double cutoff_m;
double referencePr_m;
double referenceR_m;
double referenceTheta_m;
double bega_m;
};
inline Inform &operator<<(Inform &os, const Distribution &d) {
......
......@@ -446,13 +446,20 @@ void TrackRun::execute() {
itsTracker->setNumBunch(specifiedNumBunch);
if(OPAL->inRestartRun()) {
itsTracker->setPr(dist->GetPr());
itsTracker->setR(dist->GetR());
itsTracker->setTheta(dist->GetTheta());
itsTracker->setBeGa(dist->GetBeGa());
}
if(specifiedNumBunch > 1) {
// only for regular run of multi bunches, instantiate the PartBins class
// note that for restart run of multi bunches, PartBins class is instantiated in function doRestart_cycl()
if(!OPAL->inRestartRun()) {
// already exist bins number initially
const int BinCount = 1;
//allowed maximal bin
......
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