86#include <boost/filesystem.hpp>
118 bool revBeam,
bool revTrack,
123 const double& mbPara,
124 const std::string& mbMode,
125 const std::string& mbBinning)
126 :
Tracker(beamline, bunch, reference, revBeam, revTrack)
128 , maxSteps_m(maxSTEPS)
129 , lastDumpedStep_m(0)
130 , myNode_m(
Ippl::myNode())
131 , initialLocalNum_m(bunch->getLocalNum())
132 , initialTotalNum_m(bunch->getTotalNum())
133 , opalRing_m(nullptr)
134 , itsStepper_mp(nullptr)
136 , stepper_m(timeintegrator)
141 if ( numBunch > 1 ) {
144 mbPara, mbMode, mbBinning)
179 Inform msg(
"bgf_main_collision_test ");
193 dtime, intecoords, triId);
203 <<
" lost on boundary geometry" <<
endl;
212 const short& bunchNr) {
213 if ( prevAzimuth < 0.0 ) {
218 azimuth = theta + plus;
220 double dtheta = theta - prevAzimuth;
224 if ( dtheta > 180 ) {
242 std::vector<double> dotP(dl.size());
249 allreduce(dotP.data(), dotP.size(), std::plus<double>());
252 double sum = std::accumulate(dotP.begin(), dotP.end() - 1, 0);
256 for (
short b = 0; b < (short)dotP.size() - 1; ++b) {
268 for (
size_t i = 0; i < dotP.size(); ++i) {
269 double const gamma =
std::sqrt(1.0 + dotP[i]);
270 double const beta =
std::sqrt(dotP[i]) / gamma;
284 for (
unsigned int i=0; i<numFiles; i++) {
285 std::string SfileName2 = SfileName;
287 SfileName2 += std::string(
"-Angle" + std::to_string(
int(i)) +
".dat");
291 SfileName2 += std::string(
"-afterEachTurn.dat");
294 outfTheta_m.emplace_back(
new std::ofstream(SfileName2.c_str()));
296 outfTheta_m.back()->setf(std::ios::scientific, std::ios::floatfield);
298 <<
"theta [deg] beta_theta*gamma "
321 *
gmsg <<
"* ----------------------------- Cyclotron -------------------------------- *" <<
endl;
330 *
gmsg <<
endl <<
"* This is a Spiral Inflector Simulation! This means the following:" <<
endl;
331 *
gmsg <<
"* 1.) It is up to the user to provide appropriate geometry, electric and magnetic fields!" <<
endl;
332 *
gmsg <<
"* (Use BANDRF type cyclotron and use RFMAPFN to load both magnetic" <<
endl;
333 *
gmsg <<
"* and electric fields, setting SUPERPOSE to an array of TRUE values.)" <<
endl;
334 *
gmsg <<
"* 2.) For high currents it is strongly recommended to use the SAAMG fieldsolver," <<
endl;
335 *
gmsg <<
"* FFT does not give the correct results (boundary conditions are missing)." <<
endl;
336 *
gmsg <<
"* 3.) The whole geometry will be meshed and used for the fieldsolver." <<
endl;
337 *
gmsg <<
"* There will be no transformations of the bunch into a local frame und consequently," <<
endl;
338 *
gmsg <<
"* the problem will be treated non-relativistically!" <<
endl;
339 *
gmsg <<
"* (This is not an issue for spiral inflectors as they are typically < 100 keV/amu.)" <<
endl;
340 *
gmsg <<
endl <<
"* Note: For now, multi-bunch mode (MBM) needs to be de-activated for spiral inflector" <<
endl;
341 *
gmsg <<
"* and space charge needs to be solved every time-step. numBunch_m and scSolveFreq are reset." <<
endl;
358 if (referenceTheta <= -180.0 || referenceTheta > 180.0) {
359 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
360 "PHIINIT is out of [-180, 180)!");
370 if (insqrt > -1.0e-10) {
373 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
392 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
393 "You are trying a local restart from a global h5 file!");
399 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
400 "You are trying a global restart from a local h5 file!");
408 if (referenceTheta <= -180.0 || referenceTheta > 180.0) {
409 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
410 "PHIINIT is out of [-180, 180)!");
418 *
gmsg <<
"* Bunch global starting position:" <<
endl;
423 *
gmsg <<
"* Bunch global starting momenta:" <<
endl;
427 *
gmsg <<
"* Reference azimuthal momentum (Pt) = " <<
referencePt <<
" [beta gamma]" <<
endl;
433 *
gmsg <<
"* " << sym <<
"-fold field symmetry " <<
endl;
440 *
gmsg <<
"* Field map file = '" << fmfn <<
"'" <<
endl;
443 *
gmsg <<
"* Type of cyclotron = " <<
type <<
" " <<
endl;
447 *
gmsg <<
"* Radial aperture = " << rmin <<
" ... " << rmax<<
" [m] "<<
endl;
451 *
gmsg <<
"* Vertical aperture = " << zmin <<
" ... " << zmax<<
" [m]"<<
endl;
455 *
gmsg <<
"* Harmonic number h = " << h <<
" " <<
endl;
463 for (
size_t i = 0; i < rfphi.size(); ++i) {
478 double BcParameter[8] = {};
492 *
gmsg <<
"* ----------------------------- Collimator ------------------------------- *" <<
endl;
500 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
502 double xend = elptr->
getXEnd();
503 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
506 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
508 double yend = elptr->
getYEnd();
509 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
512 *
gmsg <<
"* ZStart = " << zstart <<
" [m]" <<
endl;
514 double zend = elptr->
getZEnd();
515 *
gmsg <<
"* ZEnd = " << zend <<
" [m]" <<
endl;
518 *
gmsg <<
"* Width = " << width <<
" [m]" <<
endl;
522 double BcParameter[8] = {};
524 BcParameter[0] = xstart;
525 BcParameter[1] = xend;
526 BcParameter[2] = ystart;
527 BcParameter[3] = yend;
528 BcParameter[4] = width;
549 *
gmsg <<
"In Degrader; L= " <<
deg.getElementLength() <<
endl;
581 "ParallelCylcotronTracker::visitOffset",
582 "Attempt to place an offset when Ring not defined");
627 *
gmsg <<
"Adding MultipoleT" <<
endl;
631 throw OpalException(
"ParallelCyclotronTracker::visitMultipoleT",
632 "Need to define a RINGDEFINITION to use MultipoleT element");
643 *
gmsg <<
"Adding MultipoleTStraight" <<
endl;
647 throw OpalException(
"ParallelCyclotronTracker::visitMultipoleTStraight",
648 "Need to define a RINGDEFINITION to use MultipoleTStraight element");
659 *
gmsg <<
"Adding MultipoleTCurvedConstRadius" <<
endl;
663 throw OpalException(
"ParallelCyclotronTracker::visitMultipoleTCurvedConstRadius",
664 "Need to define a RINGDEFINITION to use MultipoleTCurvedConstRadius element");
675 *
gmsg <<
"Adding MultipoleTCurvedVarRadius" <<
endl;
679 throw OpalException(
"ParallelCyclotronTracker::visitMultipoleTCurvedVarRadius",
680 "Need to define a RINGDEFINITION to use MultipoleTCurvedVarRadius element");
691 *
gmsg <<
"* ----------------------------- Probe ------------------------------------ *" <<
endl;
699 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
701 double xend = elptr->
getXEnd();
702 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
705 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
707 double yend = elptr->
getYEnd();
708 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
713 double BcParameter[8] = {};
715 BcParameter[0] = xstart;
716 BcParameter[1] = xend;
717 BcParameter[2] = ystart;
718 BcParameter[3] = yend;
740 *
gmsg <<
"* ----------------------------- RFCavity --------------------------------- * " <<
endl;
746 throw OpalException(
"ParallelCyclotronTracker::visitRFCavity",
748 "The ParallelCyclotronTracker can only play with cyclotron type RF system currently...");
754 *
gmsg <<
"* RF Field map file = '" << fmfn <<
"'" <<
endl;
756 double rmin = elptr->
getRmin();
757 *
gmsg <<
"* Minimal radius of cavity = " << rmin <<
" [mm]" <<
endl;
759 double rmax = elptr->
getRmax();
760 *
gmsg <<
"* Maximal radius of cavity = " << rmax <<
" [mm]" <<
endl;
763 *
gmsg <<
"* RF frequency (2*pi*f) = " << rff <<
" [rad/s]" <<
endl;
766 *
gmsg <<
"* Cavity azimuth position = " << angle <<
" [deg] " <<
endl;
769 *
gmsg <<
"* Cavity gap width = " << gap <<
" [mm] " <<
endl;
772 *
gmsg <<
"* Cavity Shift distance = " << pdis <<
" [mm] " <<
endl;
774 double phi0 = elptr->
getPhi0();
775 *
gmsg <<
"* Initial RF phase (t=0) = " << phi0 <<
" [deg] " <<
endl;
782 std::shared_ptr<AbstractTimeDependence> freq_atd =
nullptr;
783 std::shared_ptr<AbstractTimeDependence> ampl_atd =
nullptr;
784 std::shared_ptr<AbstractTimeDependence> phase_atd =
nullptr;
787 unityVec.push_back(1.);
788 unityVec.push_back(0.);
789 unityVec.push_back(0.);
790 unityVec.push_back(0.);
796 if (!frequencyModelName.empty()) {
798 *
gmsg <<
"* Variable frequency RF Model name " << frequencyModelName <<
endl;
803 if (!amplitudeModelName.empty()) {
805 *
gmsg <<
"* Variable amplitude RF Model name " << amplitudeModelName <<
endl;
810 if (!phaseModelName.empty()) {
812 *
gmsg <<
"* Variable phase RF Model name " << phaseModelName <<
endl;
819 double BcParameter[8] = {};
824 BcParameter[3] = angle;
834 *
gmsg <<
"* ----------------------------- Ring ------------------------------------- *" <<
endl;
848 if (referenceTheta <= -180.0 || referenceTheta > 180.0) {
849 throw OpalException(
"Error in ParallelCyclotronTracker::visitRing",
850 "PHIINIT is out of [-180, 180)!");
865 double BcParameter[8] = {};
895 throw OpalException(
"ParallelCyclotronTracker::visitSBend3D",
896 "Need to define a RINGDEFINITION to use SBend3D element");
900 *
gmsg <<
"Adding ScalingFFAMagnet" <<
endl;
906 throw OpalException(
"ParallelCyclotronTracker::visitScalingFFAMagnet",
907 "Need to define a RINGDEFINITION to use ScalingFFAMagnet element");
917 *
gmsg <<
"* ----------------------------- Septum ----------------------------------- *" <<
endl;
925 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
927 double xend = elptr->
getXEnd();
928 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
931 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
933 double yend = elptr->
getYEnd();
934 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
937 *
gmsg <<
"* Width = " << width <<
" [m]" <<
endl;
942 double BcParameter[8] = {};
944 BcParameter[0] = xstart;
945 BcParameter[1] = xend;
946 BcParameter[2] = ystart;
947 BcParameter[3] = yend;
948 BcParameter[4] = width;
962 *
gmsg <<
"Solenoid: no position of the element given!" <<
endl;
973 *
gmsg <<
"* ----------------------------- Stripper --------------------------------- *" <<
endl;
981 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
983 double xend = elptr->
getXEnd();
984 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
987 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
989 double yend = elptr->
getYEnd();
990 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
993 *
gmsg <<
"* Charge of outcoming particle = +e * " << opcharge <<
endl;
996 *
gmsg <<
"* Mass of the outcoming particle = " << opmass <<
" [GeV/c^2]" <<
endl;
999 *
gmsg << std::boolalpha
1000 <<
"* Particles stripped will be deleted after interaction -> "
1005 double BcParameter[8] = {};
1007 BcParameter[0] = xstart;
1008 BcParameter[1] = xend;
1009 BcParameter[2] = ystart;
1010 BcParameter[3] = yend;
1012 BcParameter[5] = opcharge;
1013 BcParameter[6] = opmass;
1024 *
gmsg <<
"* ----------------------------- Vacuum ----------------------------------- *" <<
endl;
1029 double BcParameter[8] = {};
1032 *
gmsg <<
"* Residual gas = " << gas <<
endl;
1037 *
gmsg <<
"* Pressure field map file = '" << pmfn <<
"'" <<
endl;
1038 *
gmsg <<
"* Default pressure = " << pressure <<
" [mbar]" <<
endl;
1040 *
gmsg <<
"* Pressure = " << pressure <<
" [mbar]" <<
endl;
1045 *
gmsg <<
"* Temperature = " << temperature <<
" [K]" <<
endl;
1048 *
gmsg << std::boolalpha
1049 <<
"* Particles stripped will be deleted after interaction -> "
1054 BcParameter[0] = pressure;
1055 BcParameter[1] = pscale;
1056 BcParameter[2] = temperature;
1067 *
gmsg <<
"Adding Variable RF Cavity" <<
endl;
1071 throw OpalException(
"ParallelCyclotronTracker::visitVariableRFCavity",
1072 "Need to define a RINGDEFINITION to use VariableRFCavity element");
1082 *
gmsg <<
"Adding Variable RF Cavity with Fringe Field" <<
endl;
1086 throw OpalException(
"ParallelCyclotronTracker::visitVariableRFCavityFringeField",
1087 "Need to define a RINGDEFINITION to use VariableRFCavity element");
1096 *
gmsg <<
"Adding Vertical FFA Magnet" <<
endl;
1100 throw OpalException(
"ParallelCyclotronTracker::visitVerticalFFAMagnet",
1101 "Need to define a RINGDEFINITION to use VerticalFFAMagnet element");
1116 localpair->first = elementType;
1118 for (
int i = 0; i < 8; i++)
1119 *(((localpair->second).first) + i) = *(BcParameter + i);
1121 (localpair->second).second = elptr;
1145 int maxnlp = 111111;
1148 *
gmsg << s <<
"min local particle number: "<< minnlp <<
endl;
1149 *
gmsg <<
"* max local particle number: " << maxnlp <<
endl;
1177 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1178 *
gmsg <<
"* The selected Beam line elements are :" <<
endl;
1194 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl <<
endl;
1202 for (
int k = 0; k < 2; k++)
1212 std::placeholders::_1,
1213 std::placeholders::_2,
1214 std::placeholders::_3,
1215 std::placeholders::_4);
1219 *
gmsg <<
"* 2nd order Leap-Frog integrator" <<
endl;
1224 *
gmsg <<
"* Multiple time stepping (MTS) integrator" <<
endl;
1229 *
gmsg <<
"* 4th order Runge-Kutta integrator" <<
endl;
1241 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1242 *
gmsg <<
"* Finalizing i.e. write data and close files :" <<
endl;
1244 ((fd->second).second)->finalise();
1246 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1261 double t = 0, dt = 0, oldReferenceTheta = 0;
1265 *
gmsg <<
"* MTS: Number of substeps per step is " << numSubsteps <<
endl;
1267 double const dt_inner = dt / double(numSubsteps);
1268 *
gmsg <<
"* MTS: The inner time step is therefore " << dt_inner <<
" [ns]" <<
endl;
1272 bool flagTransition =
false;
1274 *
gmsg <<
"* ---------------------- Start tracking ---------------------------------- *" <<
endl;
1281 bool finishedTurn =
false;
1295 for (
int n = 0;
n < numSubsteps; ++
n)
1337 temp_meanTheta, finishedTurn);
1340 oldReferenceTheta, temp_meanTheta);
1342 oldReferenceTheta = temp_meanTheta;
1349 finishedTurn =
true;
1353 <<
", Total number of live particles: "
1370 *
gmsg <<
"* ---------------------- DONE TRACKING PARTICLES ------------------------- *" <<
endl;
1401 double t = 0, dt = 0, oldReferenceTheta = 0;
1420 *
gmsg <<
"* ---------------------- Start tracking ---------------------------------- *" <<
endl;
1424 bool finishedTurn =
false;
1429 seoMode_m(t, dt, finishedTurn, Ttime, Tdeltr, Tdeltz, TturnNumber);
1445 throw OpalException(
"ParallelCyclotronTracker::GenericTracker()",
1446 "No such tracking mode.");
1456 *
gmsg <<
"* ---------------------- DONE TRACKING PARTICLES ------------------------- *" <<
endl;
1500 double distNew = (Rnew[0] * sinx - Rnew[1] * cosx) - PerpenDistance;
1501 double distOld = (Rold[0] * sinx - Rold[1] * cosx) - PerpenDistance;
1502 if (distOld > 0.0 && distNew <= 0.0) flag =
true;
1512 double rmin = rfcavity->
getRmin();
1513 double rmax = rfcavity->
getRmax();
1514 double nomalRadius = (radius - rmin) / (rmax - rmin);
1516 if (nomalRadius <= 1.0 && nomalRadius >= 0.0) {
1518 for (
int j = 0; j < 3; j++)
1524 for (
int j = 0; j < 3; j++)
1551 int lastTurn,
double& ,
double& ) {
1554 int Ndat = t.size();
1561 for (
int i = 0; i < Ndat; i++)
1566 for (
int i = 0; i < Ndat; i++)
1568 double ti = *(t.begin());
1569 double tf = t[t.size()-1];
1570 double T = (tf - ti);
1573 for (
int i = 0; i < Ndat; i++) {
1580 *
gmsg <<
"* ************************************* nuR ******************************************* *" <<
endl;
1581 *
gmsg <<
endl <<
"* ===> " << Ndat <<
" data points Ti=" << ti <<
" Tf= " << tf <<
" -> T= " <<
T <<
endl;
1589 *
gmsg <<
"* TUNE: Lomb analysis failed" <<
endl;
1590 *
gmsg <<
"* ************************************************************************************* *" <<
endl;
1600 *
gmsg <<
"* ************************************* nuZ ******************************************* *" <<
endl;
1601 *
gmsg <<
endl <<
"* ===> " << Ndat <<
" data points Ti=" << ti <<
" Tf= " << tf <<
" -> T= " <<
T <<
endl;
1607 *
gmsg <<
"* TUNE: Lomb analysis failed" <<
endl;
1608 *
gmsg <<
"* ************************************************************************************* *" <<
endl;
1621 if (elcycl !=
nullptr)
1623 throw OpalException(
"ParallelCyclotronTracker::getHarmonicNumber()",
1624 std::string(
"The first item in the FieldDimensions list does not ")
1625 +std::string(
"seem to be a Ring or a Cyclotron element"));
1637 for (
int d = 0; d < 3; ++d) {
1656 for (
int d = 0; d < 3; ++d) {
1675 double phi,
Vector_t const translationToGlobal) {
1677 particleVectors -= translationToGlobal;
1685 particleVectors[i] =
dot(rotation, particleVectors[i]);
1691 double phi,
Vector_t const translationToGlobal) {
1699 particleVectors[i] =
dot(rotation, particleVectors[i]);
1702 particleVectors += translationToGlobal;
1713 particleVectors -= meanR;
1726 reverseQuaternion(0) *= -1.0;
1732 particleVectors += meanR;
1745 particleVectors -= meanR;
1795 particleVectors += meanR;
1822 Vector_t const quaternionVectorComponent =
Vector_t(quaternion(1), quaternion(2), quaternion(3));
1823 double const quaternionScalarComponent = quaternion(0);
1827 particleVectors[i] = 2.0f *
dot(quaternionVectorComponent, particleVectors[i]) * quaternionVectorComponent +
1828 (quaternionScalarComponent * quaternionScalarComponent -
1829 dot(quaternionVectorComponent, quaternionVectorComponent)) * particleVectors[i] + 2.0f *
1830 quaternionScalarComponent *
cross(quaternionVectorComponent, particleVectors[i]);
1836 double tolerance = 1.0e-10;
1837 double length2 =
dot(quaternion, quaternion);
1839 if (
std::abs(length2) > tolerance &&
std::abs(length2 - 1.0f) > tolerance) {
1842 quaternion /= length;
1848 double tolerance = 1.0e-10;
1849 double length2 =
dot(vector, vector);
1851 if (
std::abs(length2) > tolerance &&
std::abs(length2 - 1.0f) > tolerance) {
1866 particleVectors[i] =
dot(rotation, particleVectors[i]);
1877 myVector =
dot(rotation, myVector);
1889 particleVectors[i] =
dot(rotation, particleVectors[i]);
1900 myVector =
dot(rotation, myVector);
1909 double k_cos_theta =
dot(u, v);
1911 double tolerance1 = 1.0e-5;
1912 double tolerance2 = 1.0e-8;
1915 if (
std::abs(k_cos_theta / k + 1.0) < tolerance1) {
1922 if (
dot(resultVectorComponent, resultVectorComponent) < tolerance2) {
1927 double sinHalfAngle =
std::sin(halfAngle);
1929 resultVectorComponent *= sinHalfAngle;
1935 resultVectorComponent =
cross(u, v);
1938 quaternion(0) = k_cos_theta + k;
1939 quaternion(1) = resultVectorComponent(0);
1940 quaternion(2) = resultVectorComponent(1);
1941 quaternion(3) = resultVectorComponent(2);
1956 bool flagNeedUpdate =
false;
1964 double const distNew = (
itsBunch_m->
R[i][0] * ccd.sinAzimuth -
itsBunch_m->
R[i][1] * ccd.cosAzimuth) - ccd.perpenDistance;
1965 bool tagCrossing =
false;
1967 if (distNew <= 0.0) {
1968 distOld = (oldR[0] * ccd.sinAzimuth - oldR[1] * ccd.cosAzimuth) - ccd.perpenDistance;
1969 if (distOld > 0.0) tagCrossing =
true;
1973 double const dt2 = h - dt1;
1990 return flagNeedUpdate;
1997 bool flagNeedUpdate =
false;
2010 return flagNeedUpdate;
2018 bool flagNeedUpdate =
push(0.5 * h);
2033 flagNeedUpdate |=
kick(h);
2036 flagNeedUpdate |=
push(0.5 * h);
2050 Vacuum* vac =
static_cast<Vacuum*
>(((*sindex)->second).second);
2065 *
gmsg <<
"* Total number of particles after PluginElement= "
2083 allreduce(flagNeedUpdate, 1, std::logical_or<bool>());
2085 if (flagNeedUpdate) {
2087 std::vector<size_t> locLostParticleNum(bunchCount, 0);
2090 std::unique_ptr<size_t[]> localBinCount;
2093 localBinCount = std::unique_ptr<size_t[]>(
new size_t[leb]);
2094 for (
int i = 0; i < leb; ++i)
2095 localBinCount[i] = 0;
2112 for (
int i = 0; i < leb; ++i) {
2117 std::vector<size_t> localnum(bunchCount + 1);
2118 for (
size_t i = 0; i < localnum.size() - 1; ++i) {
2134 std::vector<size_t> totalnum(bunchCount + 1);
2137 allreduce(localnum.data(), totalnum.data(), localnum.size(), std::plus<size_t>());
2140 for (
short i = 0; i < bunchCount; ++i) {
2144 size_t sum = std::accumulate(totalnum.begin(),
2145 totalnum.end() - 1, 0);
2147 if (
sum != totalnum[bunchCount] ) {
2148 throw OpalException(
"ParallelCyclotronTracker::deleteParticle()",
2149 "Total number of particles " + std::to_string(totalnum[bunchCount]) +
2150 " != " + std::to_string(
sum) +
" (sum over all bunches)");
2153 size_t globLostParticleNum = 0;
2154 size_t locNumLost = std::accumulate(locLostParticleNum.begin(),
2155 locLostParticleNum.end(), 0);
2157 reduce(locNumLost, globLostParticleNum, 1, std::plus<size_t>());
2159 if ( globLostParticleNum > 0 ) {
2161 <<
", lost " << globLostParticleNum <<
" particles" <<
endl;
2164 if (totalnum[bunchCount] == 0) {
2166 return flagNeedUpdate;
2203 return flagNeedUpdate;
2292 *
gmsg <<
"* Restart in the local frame" <<
endl;
2310 *
gmsg <<
"* Restart in the global frame" <<
endl;
2330 double radius =
std::sqrt(meanR[0] * meanR[0] + meanR[1] * meanR[1]);
2350 *
gmsg <<
endl <<
"* *********************** Bunch information in local frame: ************************";
2377 *
gmsg <<
endl <<
"* *********************** Bunch information in global frame: ***********************";
2391 double pTotalMean = 0.0;
2396 allreduce(pTotalMean, 1, std::plus<double>());
2401 throw OpalException(
"ParallelCyclotronTracker::checkFileMomentum",
2402 "The total momentum of the particle distribution\n"
2403 "in the global reference frame: " +
2404 std::to_string(pTotalMean) +
",\n"
2405 "is different from the momentum given\n"
2406 "in the \"BEAM\" command: " +
2408 "In Opal-cycl the initial distribution\n"
2409 "is specified in the local reference frame.\n"
2410 "When using a \"FROMFILE\" type distribution, the momentum \n"
2411 "must be the same as the specified in the \"BEAM\" command,\n"
2412 "which is in global reference frame.");
2431 int found[2] = {-1, -1};
2447 int numberOfPart = 0;
2449 while(notReceived > 0) {
2454 if (rmsg ==
nullptr)
2455 ERRORMSG(
"Could not receive from client nodes in main." <<
endl);
2459 rmsg->
get(&numberOfPart);
2461 for (
int i = 0; i < numberOfPart; ++i) {
2464 for (
int ii = 0; ii < 6; ii++) {
2472 for (
int i = 0; i < counter; ++i) {
2476 for (
int j = 0; j < 3; ++j) {
2484 for (
auto tmpid : tmpi) {
2496 for (
int ii = 0; ii < 6; ii++) {
2508 for (
int i = 0; i < counter; i++) {
2512 for (
int j = 0; j < 3; j++) {
2519 ERRORMSG(
"Ippl::Comm->send(smsg, 0, tag) failed " <<
endl);
2552 double phi = 0.0, psi = 0.0;
2616 (((*DumpSindex)->second).second)->apply(meanR, meanP, temp_t,
extE_m,
extB_m);
2681 double const betagamma_temp =
std::sqrt(
dot(meanP, meanP));
2686 double const theta =
std::atan2(meanR(1), meanR(0));
2714 (((*DumpSindex)->second).second)->apply(meanR, meanP, temp_t,
extE_m,
extB_m);
2720 bool dumpLocalFrame =
true;
2721 std::string dumpString =
"local";
2723 dumpLocalFrame =
false;
2724 dumpString =
"global";
2727 if (dumpLocalFrame ==
true) {
2756 if (dumpLocalFrame ==
true) {
2767 <<
" (no phase space dump for <= 2 particles)" <<
endl;
2770 <<
" (" << dumpString <<
" frame) at integration step " <<
step_m + 1 <<
endl;
2775 *
gmsg <<
"* T = " << temp_t <<
" ns"
2777 *
gmsg <<
"* E = " << E <<
" MeV"
2778 <<
", beta * gamma = " << betagamma_temp <<
endl;
2793 const bool& finishedTurn)
2801 if (!(
step_m + 1 % 1000)) {
2886 *
gmsg <<
"* Beginning of this run is at t = " << t <<
" [ns]" <<
endl;
2887 *
gmsg <<
"* The time step is set to dt = " << dt <<
" [ns]" <<
endl;
2890 *
gmsg <<
"* MBM: Time interval between neighbour bunches is set to "
2892 *
gmsg <<
"* MBM: The particles energy bin reset frequency is set to "
2903 *
gmsg <<
"* ------------------------- STATIC EQUILIBRIUM ORBIT MODE ----------------------------- *" <<
endl
2904 <<
"* Instruction: When the total particle number is equal to 2, SEO mode is triggered *" <<
endl
2905 <<
"* automatically. This mode does NOT include any RF cavities. The initial distribution *" <<
endl
2906 <<
"* file must be specified. In the file the first line is for reference particle and the *" <<
endl
2907 <<
"* second line is for off-center particle. The tune is calculated by FFT routines based *" <<
endl
2908 <<
"* on these two particles. *" <<
endl
2909 <<
"* ---------------- NOTE: SEO MODE ONLY WORKS SERIALLY ON SINGLE NODE ------------------ *" <<
endl;
2912 throw OpalException(
"Error in ParallelCyclotronTracker::initializeTracking_m",
2913 "SEO MODE ONLY WORKS SERIALLY ON SINGLE NODE!");
2918 *
gmsg <<
"* ------------------------------ SINGLE PARTICLE MODE --------------------------------- *" <<
endl
2919 <<
"* Instruction: When the total particle number is equal to 1, single particle mode is *" <<
endl
2920 <<
"* triggered automatically. The initial distribution file must be specified which should *" <<
endl
2921 <<
"* contain only one line for the single particle *" <<
endl
2922 <<
"* ---------NOTE: SINGLE PARTICLE MODE ONLY WORKS SERIALLY ON A SINGLE NODE ------------ *" <<
endl;
2925 throw OpalException(
"Error in ParallelCyclotronTracker::initializeTracking_m",
2926 "SINGLE PARTICLE MODE ONLY WORKS SERIALLY ON A SINGLE NODE!");
2937 throw OpalException(
"ParallelCyclotronTracker::initializeTracking_m()",
2938 "No such tracking mode.");
2942 return std::make_tuple(t, dt, oldReferenceTheta);
2954 *
gmsg <<
"* Final energy of reference particle = " << FinalEnergy <<
" [MeV]" <<
endl;
2966 *
gmsg <<
"* **************** The result for tune calculation (NO space charge) ******************* *" <<
endl
2967 <<
"* Number of tracked turns: " << TturnNumber.back() <<
endl;
2969 getTunes(Ttime, Tdeltr, Tdeltz, TturnNumber.back(), nur, nuz);
2982 *
gmsg <<
"* Cave: Turn number is not correct for restart mode"<<
endl;
2993 *
gmsg <<
endl <<
"* *********************** Bunch information in global frame: ***********************";
3000 *
gmsg <<
endl <<
"* No Particles left in bunch!" <<
endl;
3001 *
gmsg <<
"* **********************************************************************************" <<
endl;
3023 double r_tuning[2], z_tuning[2];
3058 Tdeltz.push_back(z_tuning[1]);
3059 Tdeltr.push_back(r_tuning[1] - r_tuning[0]);
3066 bool& finishedTurn,
double& oldReferenceTheta) {
3101 temp_meanTheta, finishedTurn);
3104 oldReferenceTheta, temp_meanTheta);
3106 oldReferenceTheta = temp_meanTheta;
3132 static bool flagTransition =
false;
3212 finishedTurn =
true;
3216 <<
", Total number of live particles: "
3232 bool tag_crossing =
false;
3233 double DistOld = 0.0;
3238 rfcav =
static_cast<RFCavity *
>(((*sindex)->second).second);
3242 if ( tag_crossing ) {
3245 double oldMomentum2 =
dot(Pold, Pold);
3246 double oldBetgam =
std::sqrt(oldMomentum2);
3247 double oldGamma =
std::sqrt(1.0 + oldMomentum2);
3248 double oldBeta = oldBetgam / oldGamma;
3250 double dt2 = dt - dt1;
3257 if (dt / dt1 < 1.0e9) {
3261 RFkick(rfcav, t, dt1, i);
3266 if (dt / dt2 < 1.0e9) {
3277 const double& oldReferenceTheta,
3278 const double& temp_meanTheta) {
3280 for (
unsigned int i=0; i<=2; i++) {
3285 <<
", Time = " << t <<
" [ns]" <<
std::endl
3286 <<
" " << std::hypot(
R(0),
R(1))
3287 <<
" " << P(0) *
std::cos(temp_meanTheta) + P(1) *
std::sin(temp_meanTheta)
3289 <<
" " << - P(0) *
std::sin(temp_meanTheta) + P(1) *
std::cos(temp_meanTheta)
3299 const double& temp_meanTheta,
3300 bool& finishedTurn) {
3303 finishedTurn =
true;
3308 <<
", Time = " << t <<
" [ns]" <<
std::endl
3310 <<
" " << P(0) *
std::cos(temp_meanTheta) +
3313 <<
" " << - P(0) *
std::sin(temp_meanTheta) +
3417 bool outOfBound = (((*sindex)->second).second)->apply(i, t, Efield, Bfield);
3430 bool outOfBound = (((*sindex)->second).second)->apply(
R, P, t, Efield, Bfield);
3457 if ( flagTransition ) {
3459 *
gmsg <<
"* MBM: After one revolution, Multi-Bunch Mode will be invoked" <<
endl;
3469 throw OpalException(
"ParallelCyclotronTracker::injectBunch()",
3470 "Unknown return value " + std::to_string(result));
3504 std::vector<double> lpaths(1);
3538 for (
short b = 0; b <
mbHandler_m->getNumBunch(); ++b) {
Vector3D cross(const Vector3D &lhs, const Vector3D &rhs)
Vector cross product.
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
T euclidean_norm(const Vector< T > &)
Euclidean norm.
void allreduce(const T *input, T *output, int count, Op op)
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
bool for_each(const BareFieldIterator< T, D > &p, SameFieldID s, C)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
PETE_TUTree< FnArcCos, typename T::PETE_Expr_t > acos(const PETE_Expr< T > &l)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Inform & level4(Inform &inf)
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double q_e
The elementary charge in As.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
std::string::iterator iterator
T deg(T x)
Convert radians to degrees.
int psDumpFreq
The frequency to dump the phase space, i.e.dump data when steppsDumpFreq==0.
bool psDumpEachTurn
phase space dump flag for OPAL-cycl
int sptDumpFreq
The frequency to dump single particle trajectory of particles with ID = 0 & 1.
unsigned int delPartFreq
The frequency to delete particles (currently: OPAL-cycl only)
int scSolveFreq
The frequency to solve space charge fields.
int repartFreq
The frequency to do particles repartition for better load balance between nodes.
int rebinFreq
The frequency to reset energy bin ID for all particles.
DumpFrame psDumpFrame
flag to decide in which coordinate frame the phase space will be dumped for OPAL-cycl
int statDumpFreq
The frequency to dump statistical values, e.e. dump data when stepstatDumpFreq==0.
std::string doubleVectorToString(const std::vector< double > &v)
std::string boolVectorToUpperString(const std::vector< bool > &b)
boost::function< boost::tuple< double, bool >(arguments_t)> type
const std::string & getOpalName() const
Return object name.
ParticleAttrib< Vector_t > Ef
double get_meanKineticEnergy() const
ParticleAttrib< int > Bin
void boundp_destroyCycl()
double getQ() const
Access to reference data.
double getChargePerParticle() const
get the macro particle charge
size_t getLocalNum() const
void setLocalTrackStep(long long n)
step in a TRACK command
void setLocalBinCount(size_t num, int bin)
ParticleAttrib< double > M
size_t getTotalNum() const
ParticleAttrib< Vector_t > P
FieldSolverType getFieldSolverType() const
Return the fieldsolver type if we have a fieldsolver.
void setLocalNumPerBunch(size_t numpart, short n)
size_t getLocalNumPerBunch(short n) const
void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion)
virtual void computeSelfFields_cycl(double gamma)=0
ParticleAttrib< double > Q
void calcBeamParameters()
size_t getTotalNumPerBunch(short n) const
ParticleAttrib< short > cavityGapCrossed
void setTotalNum(size_t n)
long long getLocalTrackStep() const
void setGlobalMeanR(Vector_t globalMeanR)
short getNumBunch() const
virtual void do_binaryRepart()
ParticleAttrib< double > dt
int getStepsPerTurn() const
void countTotalNumPerBunch()
DistributionType getDistType() const
virtual void setBinCharge(int bin, double q)
Set the charge of one bin to the value of q and all other to zero.
void performDestroy(bool updateLocalNum=false)
ParticleAttrib< short > bunchNum
void setTotalNumPerBunch(size_t numpart, short n)
void destroy(size_t M, size_t I, bool doNow=false)
ParticleAttrib< Vector_t > Bf
std::string getInputBasename()
get input file name without extension
static OpalData * getInstance()
BoundaryGeometry * getGlobalGeometry()
void setOpenMode(OpenMode openMode)
bool inRestartRun()
true if we do a restart run
int lombAnalysis(double *x, double *y, int Ndat, int nhis)
void operator()(double x)
void computePathLengthUpdate(std::vector< double > &dl, const double &dt)
std::vector< PluginElement * > pluginElements_m
void dumpAzimuthAngles_m(const double &t, const Vector_t &R, const Vector_t &P, const double &oldReferenceTheta, const double &temp_meanTheta)
IpplTimings::TimerRef IntegrationTimer_m
IpplTimings::TimerRef PluginElemTimer_m
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a degrader.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
static Vector_t const xaxis
The positive axes unit vectors.
Vector_t calcMeanP() const
virtual void visitProbe(const Probe &)
Apply the algorithm to a probe.
virtual void visitVacuum(const Vacuum &)
Apply the algorithm to a vacuum space.
std::function< bool(const double &, const size_t &, Vector_t &, Vector_t &)> function_t
bool computeExternalFields_m(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &Efield, Vector_t &Bfield)
Calculate the field map at an arbitrary point.
std::vector< double > azimuth_angle_m
the different azimuthal angles for the outfTheta_m output files
std::unique_ptr< MultiBunchHandler > mbHandler_m
void injectBunch(bool &flagTransition)
void rotateAroundZ(ParticleAttrib< Vector_t > &particleVectors, double const phi)
virtual void visitStripper(const Stripper &)
Apply the algorithm to a particle stripper.
void normalizeQuaternion(Quaternion_t &quaternion)
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
void singleMode_m(double &t, const double dt, bool &finishedTurn, double &oldReferenceTheta)
void update_m(double &t, const double &dt, const bool &finishedTurn)
Update time and path length, write to output files.
ParallelCyclotronTracker()
virtual ~ParallelCyclotronTracker()
std::vector< std::unique_ptr< std::ofstream > > outfTheta_m
output coordinates at different azimuthal angles and one after every turn
void computeSpaceChargeFields_m()
bool hasMultiBunch() const
double getHarmonicNumber() const
void rotateAroundX(ParticleAttrib< Vector_t > &particleVectors, double const psi)
double calculateAngle(double x, double y)
bool isTurnDone()
Check if turn done.
virtual void visitBeamline(const Beamline &)
Apply the algorithm to a beam line.
bool checkGapCross(Vector_t Rold, Vector_t Rnew, RFCavity *rfcavity, double &DistOld)
virtual void visitOffset(const Offset &)
Apply the algorithm to a offset (placement).
IpplTimings::TimerRef DelParticleTimer_m
void normalizeVector(Vector_t &vector)
bool RFkick(RFCavity *rfcavity, const double t, const double dt, const int Pindex)
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &bend)
Apply the algorithm to a scaling FFA magnet.
double computeRadius(const Vector_t &meanR) const
void updatePathLength(const double &dt)
virtual void visitMultipoleTStraight(const MultipoleTStraight &)
Apply the algorithm to an arbitrary straight multipole.
void updateTime(const double &dt)
void openFiles(size_t numFiles, std::string fn)
@ open / close output coordinate files
virtual void visitSBend3D(const SBend3D &)
Apply the algorithm to a sector bend with 3D field map.
void borisExternalFields(double h)
double bega
The reference variables.
void dumpAngle(const double &theta, double &prevAzimuth, double &azimuth, const short &bunchNr=0)
bool applyPluginElements(const double dt)
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a closed orbit corrector.
static Vector_t const yaxis
std::tuple< double, double, double > initializeTracking_m()
std::pair< ElementType, element_pair > type_pair
virtual void visitRing(const Ring &ring)
Apply the algorithm to a ring.
IpplTimings::TimerRef BinRepartTimer_m
void globalToLocal(ParticleAttrib< Vector_t > &vectorArray, double phi, Vector_t const translationToGlobal=0)
static Vector_t const zaxis
void updateAzimuthAndRadius()
const size_t initialLocalNum_m
bool getFieldsAtPoint(const double &t, const size_t &Pindex, Vector_t &Efield, Vector_t &Bfield)
std::vector< CavityCrossData > cavCrossDatas_m
beamline_list FieldDimensions
virtual void visitDrift(const Drift &)
Apply the algorithm to a drift space.
std::unique_ptr< Stepper< function_t > > itsStepper_mp
struct ParallelCyclotronTracker::settings setup_m
std::ofstream outfTrackOrbit_m
void finalizeTracking_m(dvector_t &Ttime, dvector_t &Tdeltr, dvector_t &Tdeltz, ivector_t &TturnNumber)
virtual void visitVariableRFCavityFringeField(const VariableRFCavityFringeField &cav)
Apply the algorithm to a variable RF cavity with Fringe Field.
void gapCrossKick_m(size_t i, double t, double dt, const Vector_t &Rold, const Vector_t &Pold)
void getQuaternionTwoVectors(Vector_t u, Vector_t v, Quaternion_t &quaternion)
virtual void visitSBend(const SBend &)
Apply the algorithm to a sector bend.
virtual void visitMarker(const Marker &)
Apply the algorithm to a marker.
virtual void execute()
Apply the algorithm to the top-level beamline.
void dumpThetaEachTurn_m(const double &t, const Vector_t &R, const Vector_t &P, const double &temp_meanTheta, bool &finishedTurn)
void bunchMode_m(double &t, const double dt, bool &finishedTurn)
void initTrackOrbitFile()
std::list< Component * > myElements
std::unique_ptr< LossDataSink > lossDs_m
virtual void visitMultipoleT(const MultipoleT &)
Apply the algorithm to an arbitrary multipole.
virtual void visitVariableRFCavity(const VariableRFCavity &cav)
Apply the algorithm to a variabel RF cavity.
const size_t initialTotalNum_m
void bgf_main_collision_test()
void buildupFieldList(double BcParameter[], ElementType elementType, Component *elptr)
void rotateWithQuaternion(ParticleAttrib< Vector_t > &vectorArray, Quaternion_t const quaternion)
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a multipole.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a solenoid.
Steppers::TimeIntegrator stepper_m
std::vector< double > dvector_t
void bunchDumpPhaseSpaceData()
IpplTimings::TimerRef TransformTimer_m
Vector_t calcMeanR(short bunchNr=-1) const
double calculateAngle2(double x, double y)
virtual void visitCyclotron(const Cyclotron &cycl)
Apply the algorithm to a cyclotron.
bool deleteParticle(bool=false)
void localToGlobal(ParticleAttrib< Vector_t > &vectorArray, double phi, Vector_t const translationToGlobal=0)
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RF cavity.
bool getTunes(dvector_t &t, dvector_t &r, dvector_t &z, int lastTurn, double &nur, double &nuz)
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
void checkNumPart(std::string s)
void singleParticleDump()
virtual void visitMultipoleTCurvedVarRadius(const MultipoleTCurvedVarRadius &)
Apply the algorithm to an arbitrary curved multipole of variable radius.
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &bend)
Apply the algorithm to a vertical FFA magnet.
virtual void visitSeptum(const Septum &)
Apply the algorithm to a septum.
IpplTimings::TimerRef DumpTimer_m
virtual void visitMultipoleTCurvedConstRadius(const MultipoleTCurvedConstRadius &)
Apply the algorithm to an arbitrary curved multipole of constant radius.
bool isMultiBunch() const
void seoMode_m(double &t, const double dt, bool &finishedTurn, dvector_t &Ttime, dvector_t &Tdeltr, dvector_t &Tdeltz, ivector_t &TturnNumber)
int maxSteps_m
The maximal number of steps the system is integrated.
void initDistInGlobalFrame()
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a beam position monitor.
std::vector< int > ivector_t
static void writeFields(Component *field)
static void writeFields(Component *field)
double getZStart()
Member variable access.
Interface for a single beam element.
Interface for general corrector.
virtual std::vector< double > getEScale() const
virtual double getCyclHarm() const
virtual bool getSpiralFlag() const
virtual double getPRinit() const
virtual double getPZinit() const
virtual std::string getFieldMapFN() const
virtual double getRmin() const
virtual double getMaxR() const
virtual std::vector< double > getRfFrequ() const
virtual double getRmax() const
virtual double getMaxZ() const
virtual double getBScale() const
virtual double getZinit() const
virtual double getPHIinit() const
virtual double getSymmetry() const
virtual double getMinZ() const
virtual std::vector< double > getRfPhi() const
BFieldType getBFieldType() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)
virtual std::vector< bool > getSuperpose() const
unsigned int getNumberOfTrimcoils() const
virtual double getRinit() const
virtual double getMinR() const
const std::string & getCyclotronType() const
Interface for drift space.
virtual const std::string & getName() const
Get element name.
virtual double getElementLength() const
Get design length.
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
virtual ElementBase * clone() const =0
Return clone.
virtual bool hasAttribute(const std::string &aKey) const
Test for existence of an attribute.
std::string getTypeString() const
Interface for general multipole.
ElementBase * clone() const override
virtual ElementBase * clone() const override
virtual ElementBase * clone() const override
virtual ElementBase * clone() const override
void updateGeometry(Vector_t startPosition, Vector_t startDirection)
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Pure virtual implementation of Component.
double getXStart() const
Member variable access.
std::string getPhaseModelName()
virtual double getRmax() const
void getMomentaKick(const double normalRadius, double momentum[], const double t, const double dtCorrt, const int PID, const double restMass, const int chargenumber)
used in OPAL-cycl
virtual double getAzimuth() const
std::string getAmplitudeModelName()
virtual double getCosAzimuth() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
virtual double getSinAzimuth() const
virtual std::string getFieldMapFN() const
virtual double getCycFrequency() const
virtual double getGapWidth() const
std::string getFrequencyModelName()
virtual double getPerpenDistance() const
CavityType getCavityType() const
virtual double getPhi0() const
std::string getCavityTypeString() const
virtual double getRmin() const
Ring describes a ring type geometry for tracking.
double getBeamRInit() const
Vector_t getNextPosition() const
Vector_t getNextNormal() const
double getBeamPRInit() const
double getSymmetry() const
virtual ElementBase * clone() const override
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
double getBeamPhiInit() const
double getHarmonicNumber()
void appendElement(const Component &element)
ScalingFFAMagnet * clone() const override
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Pure virtual implementation of Component.
double getOPCharge() const
double getPressure() const
std::string getPressureMapFN() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
virtual bool checkVacuum(PartBunchBase< double, 3 > *bunch, Cyclotron *cycl)
double getTemperature() const
std::string getResidualGasName()
static std::shared_ptr< AbstractTimeDependence > getTimeDependence(std::string name)
const PartData itsReference
The reference information.
double getBeta() const
The relativistic beta per particle.
double getGamma() const
The relativistic gamma per particle.
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
An abstract sequence of beam line components.
virtual void iterate(BeamlineVisitor &, bool r2l) const
Apply visitor to all elements of the line.
void kick(const Vector_t &R, Vector_t &P, const Vector_t &Ef, const Vector_t &Bf, const double &dt) const
4-th order Runnge-Kutta stepper
int partInside(const Vector_t &r, const Vector_t &v, const double dt, Vector_t &intecoords, int &triId)
void setMultiBunchInitialPathLengh(MultiBunchHandler *mbhandler_p)
void dumpSDDS(PartBunchBase< double, 3 > *beam, Vector_t FDext[], const double &azimuth=-1) const
void dumpH5(PartBunchBase< double, 3 > *beam, Vector_t FDext[]) const
void writeMultiBunchStatistics(PartBunchBase< double, 3 > *beam, MultiBunchHandler *mbhandler)
The base class for all OPAL exceptions.
Message * receive_block(int &node, int &tag)
Message & put(const T &val)
Message & get(const T &cval)
int next_tag(int t, int s=1000)
static Communicate * Comm
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t