111 bool revBeam,
bool revTrack,
116 const double& mbPara,
117 const std::string& mbMode,
118 const std::string& mbBinning)
119 :
Tracker(beamline, bunch, reference, revBeam, revTrack)
122 , maxSteps_m(maxSTEPS)
123 , lastDumpedStep_m(0)
125 , myNode_m(
Ippl::myNode())
126 , initialLocalNum_m(bunch->getLocalNum())
127 , initialTotalNum_m(bunch->getTotalNum())
128 , opalRing_m(nullptr)
129 , itsStepper_mp(nullptr)
131 , stepper_m(timeintegrator)
137 if ( numBunch > 1 ) {
142 throw OpalException(
"ParallelCyclotronTracker::ParallelCyclotronTracker()",
143 "FIELDSOLVER, MESHFIT=\"CORE\" is not available in "
144 "multi-bunch mode (TURNS > 1 in RUN).");
148 mbPara, mbMode, mbBinning)
181 Inform msg(
"bgf_main_collision_test ");
198 dtime, intecoords, triId);
212 <<
" lost on boundary geometry" <<
endl;
221 const short& bunchNr) {
222 if ( prevAzimuth < 0.0 ) {
227 azimuth = theta + plus;
229 double dtheta = theta - prevAzimuth;
233 if ( dtheta > 180 ) {
243 return Units::m2mm * std::sqrt(meanR(0) * meanR(0) + meanR(1) * meanR(1));
251 std::vector<double> dotP(dl.size());
258 allreduce(dotP.data(), dotP.size(), std::plus<double>());
262 const size_t numBunchEntries = std::max(dotP.size() - 1,
size_t(1));
263 double sum = std::accumulate(dotP.begin(), dotP.begin() + numBunchEntries, 0.0);
267 for (
short b = 0; b < (short)dotP.size() - 1; ++b) {
277 double buf[2] = {0.0, 0.0};
299 dotP[0] = (totalNum > 0) ?
sum /
double(totalNum) : 0.0;
303 for (
size_t i = 0; i < dotP.size(); ++i) {
304 double const gamma = std::sqrt(1.0 + dotP[i]);
305 double const beta = std::sqrt(dotP[i]) / gamma;
318 for (
unsigned int i=0; i<numFiles; i++) {
319 std::string SfileName2 = SfileName;
321 SfileName2 += std::string(
"-Angle" + std::to_string(
int(i)) +
".dat");
325 SfileName2 += std::string(
"-afterEachTurn.dat");
328 outfTheta_m.emplace_back(
new std::ofstream(SfileName2.c_str()));
330 outfTheta_m.back()->setf(std::ios::scientific, std::ios::floatfield);
333 <<
"theta [deg] beta_theta*gamma "
334 <<
"z [m] beta_z*gamma" << std::endl;
356 *
gmsg <<
"* ----------------------------- Cyclotron -------------------------------- *" <<
endl;
365 *
gmsg <<
endl <<
"* This is a Spiral Inflector Simulation! This means the following:" <<
endl;
366 *
gmsg <<
"* 1.) It is up to the user to provide appropriate geometry, electric and magnetic fields!" <<
endl;
367 *
gmsg <<
"* (Use BANDRF type cyclotron and use RFMAPFN to load both magnetic" <<
endl;
368 *
gmsg <<
"* and electric fields, setting SUPERPOSE to an array of TRUE values.)" <<
endl;
369 *
gmsg <<
"* 2.) For high currents it is strongly recommended to use the SAAMG fieldsolver," <<
endl;
370 *
gmsg <<
"* FFT does not give the correct results (boundary conditions are missing)." <<
endl;
371 *
gmsg <<
"* 3.) The whole geometry will be meshed and used for the fieldsolver." <<
endl;
372 *
gmsg <<
"* There will be no transformations of the bunch into a local frame und consequently," <<
endl;
373 *
gmsg <<
"* the problem will be treated non-relativistically!" <<
endl;
374 *
gmsg <<
"* (This is not an issue for spiral inflectors as they are typically < 100 keV/amu.)" <<
endl;
375 *
gmsg <<
endl <<
"* Note: For now, multi-bunch mode (MBM) needs to be de-activated for spiral inflector" <<
endl;
376 *
gmsg <<
"* and space charge needs to be solved every time-step. numBunch_m and scSolveFreq are reset." <<
endl;
398 if (insqrt > -1.0e-10) {
401 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
420 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
421 "You are trying a local restart from a global h5 file");
427 throw OpalException(
"Error in ParallelCyclotronTracker::visitCyclotron",
428 "You are trying a global restart from a local h5 file");
447 *
gmsg <<
"* Bunch global starting position:" <<
endl;
452 *
gmsg <<
"* Bunch global starting momenta:" <<
endl;
456 *
gmsg <<
"* Reference azimuthal momentum (Pt) = " <<
referencePt <<
" [beta gamma]" <<
endl;
462 *
gmsg <<
"* " << sym <<
"-fold field symmetry " <<
endl;
469 *
gmsg <<
"* Field map file = '" << fmfn <<
"'" <<
endl;
472 *
gmsg <<
"* Type of cyclotron = " << type <<
" " <<
endl;
476 *
gmsg <<
"* Radial aperture = " << rmin <<
" ... " << rmax <<
" [m]" <<
endl;
480 *
gmsg <<
"* Vertical aperture = " << zmin <<
" ... " << zmax <<
" [m]" <<
endl;
484 *
gmsg <<
"* Harmonic number h = " << h <<
endl;
491 for (
size_t i = 0; i < rfphi.size(); ++i) {
506 double BcParameter[8] = {};
520 *
gmsg <<
"* ----------------------------- Collimator ------------------------------- *" <<
endl;
528 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
530 double xend = elptr->
getXEnd();
531 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
534 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
536 double yend = elptr->
getYEnd();
537 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
540 *
gmsg <<
"* ZStart = " << zstart <<
" [m]" <<
endl;
542 double zend = elptr->
getZEnd();
543 *
gmsg <<
"* ZEnd = " << zend <<
" [m]" <<
endl;
546 *
gmsg <<
"* Width = " << width <<
" [m]" <<
endl;
550 double BcParameter[8] = {};
552 BcParameter[0] = xstart;
553 BcParameter[1] = xend;
554 BcParameter[2] = ystart;
555 BcParameter[3] = yend;
556 BcParameter[4] = width;
577 *
gmsg <<
"In Degrader; L= " << deg.getElementLength() <<
endl;
609 "ParallelCylcotronTracker::visitOffset",
610 "Attempt to place an offset when Ring not defined");
652 *
gmsg <<
"Adding MultipoleT" <<
endl;
656 throw OpalException(
"ParallelCyclotronTracker::visitMultipoleT",
657 "Need to define a RINGDEFINITION to use MultipoleT element");
669 throw OpalException(
"ParallelCylcotronTracker::visitOutputPlane",
670 "Attempt to place an OutputPlane when Ring not defined");
678 double BcParameter[8] = {};
683 BcParameter[0] = centre[0]-width*norm[1];
684 BcParameter[1] = centre[0]+width*norm[1];
685 BcParameter[2] = centre[1]-width*norm[0];
686 BcParameter[3] = centre[1]+width*norm[0];
698 *
gmsg <<
"* ----------------------------- Probe ------------------------------------ *" <<
endl;
706 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
708 double xend = elptr->
getXEnd();
709 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
712 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
714 double yend = elptr->
getYEnd();
715 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
720 double BcParameter[8] = {};
722 BcParameter[0] = xstart;
723 BcParameter[1] = xend;
724 BcParameter[2] = ystart;
725 BcParameter[3] = yend;
747 *
gmsg <<
"* ----------------------------- RFCavity --------------------------------- * " <<
endl;
753 throw OpalException(
"ParallelCyclotronTracker::visitRFCavity",
755 "The ParallelCyclotronTracker can only play with cyclotron type RF system currently...");
761 *
gmsg <<
"* RF Field map file = '" << fmfn <<
"'" <<
endl;
763 double rmin = elptr->
getRmin();
764 *
gmsg <<
"* Minimal radius of cavity = " << rmin <<
" [m]" <<
endl;
766 double rmax = elptr->
getRmax();
767 *
gmsg <<
"* Maximal radius of cavity = " << rmax <<
" [m]" <<
endl;
770 *
gmsg <<
"* RF frequency (2*pi*f) = " << rff <<
" [rad/s]" <<
endl;
776 *
gmsg <<
"* Cavity gap width = " << gap <<
" [m] " <<
endl;
779 *
gmsg <<
"* Cavity Shift distance = " << pdis <<
" [m] " <<
endl;
781 double phi0 = elptr->
getPhi0();
789 std::shared_ptr<AbstractTimeDependence> freq_atd =
nullptr;
790 std::shared_ptr<AbstractTimeDependence> ampl_atd =
nullptr;
791 std::shared_ptr<AbstractTimeDependence> phase_atd =
nullptr;
794 unityVec.push_back(1.);
795 unityVec.push_back(0.);
796 unityVec.push_back(0.);
797 unityVec.push_back(0.);
803 if (!frequencyModelName.empty()) {
805 *
gmsg <<
"* Variable frequency RF Model name " << frequencyModelName <<
endl;
810 if (!amplitudeModelName.empty()) {
812 *
gmsg <<
"* Variable amplitude RF Model name " << amplitudeModelName <<
endl;
817 if (!phaseModelName.empty()) {
819 *
gmsg <<
"* Variable phase RF Model name " << phaseModelName <<
endl;
826 double BcParameter[8] = {};
828 BcParameter[0] = rmin;
829 BcParameter[1] = rmax;
830 BcParameter[2] = pdis;
831 BcParameter[3] = angle;
841 *
gmsg <<
"* ----------------------------- Ring ------------------------------------- *" <<
endl;
857 throw OpalException(
"Error in ParallelCyclotronTracker::visitRing",
858 "BEAM_PHIINIT is out of [-180, 180)");
873 double BcParameter[8] = {};
903 throw OpalException(
"ParallelCyclotronTracker::visitSBend3D",
904 "Need to define a RINGDEFINITION to use SBend3D element");
908 *
gmsg <<
"Adding ScalingFFAMagnet" <<
endl;
914 throw OpalException(
"ParallelCyclotronTracker::visitScalingFFAMagnet",
915 "Need to define a RINGDEFINITION to use ScalingFFAMagnet element");
925 *
gmsg <<
"* ----------------------------- Septum ----------------------------------- *" <<
endl;
933 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
935 double xend = elptr->
getXEnd();
936 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
939 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
941 double yend = elptr->
getYEnd();
942 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
945 *
gmsg <<
"* Width = " << width <<
" [m]" <<
endl;
950 double BcParameter[8] = {};
952 BcParameter[0] = xstart;
953 BcParameter[1] = xend;
954 BcParameter[2] = ystart;
955 BcParameter[3] = yend;
956 BcParameter[4] = width;
970 *
gmsg <<
"Solenoid: no position of the element given" <<
endl;
981 *
gmsg <<
"* ----------------------------- Stripper --------------------------------- *" <<
endl;
989 *
gmsg <<
"* XStart = " << xstart <<
" [m]" <<
endl;
991 double xend = elptr->
getXEnd();
992 *
gmsg <<
"* XEnd = " << xend <<
" [m]" <<
endl;
995 *
gmsg <<
"* YStart = " << ystart <<
" [m]" <<
endl;
997 double yend = elptr->
getYEnd();
998 *
gmsg <<
"* YEnd = " << yend <<
" [m]" <<
endl;
1001 *
gmsg <<
"* Charge of outcoming particle = +e * " << opcharge <<
endl;
1004 *
gmsg <<
"* Mass of the outcoming particle = " << opmass <<
" [GeV/c^2]" <<
endl;
1007 *
gmsg << std::boolalpha
1008 <<
"* Particles stripped will be deleted after interaction -> "
1013 double BcParameter[8] = {};
1015 BcParameter[0] = xstart;
1016 BcParameter[1] = xend;
1017 BcParameter[2] = ystart;
1018 BcParameter[3] = yend;
1020 BcParameter[5] = opcharge;
1021 BcParameter[6] = opmass;
1032 *
gmsg <<
"* ----------------------------- Vacuum ----------------------------------- *" <<
endl;
1037 double BcParameter[8] = {};
1040 *
gmsg <<
"* Residual gas = " << gas <<
endl;
1045 *
gmsg <<
"* Pressure field map file = '" << pmfn <<
"'" <<
endl;
1046 *
gmsg <<
"* Default pressure = " << pressure <<
" [mbar]" <<
endl;
1048 *
gmsg <<
"* Pressure = " << pressure <<
" [mbar]" <<
endl;
1053 *
gmsg <<
"* Temperature = " << temperature <<
" [K]" <<
endl;
1056 *
gmsg << std::boolalpha
1057 <<
"* Particles stripped will be deleted after interaction -> "
1062 BcParameter[0] = pressure;
1063 BcParameter[1] = pscale;
1064 BcParameter[2] = temperature;
1075 *
gmsg <<
"Adding Variable RF Cavity" <<
endl;
1079 throw OpalException(
"ParallelCyclotronTracker::visitVariableRFCavity",
1080 "Need to define a RINGDEFINITION to use VariableRFCavity element");
1090 *
gmsg <<
"Adding Variable RF Cavity with Fringe Field" <<
endl;
1094 throw OpalException(
"ParallelCyclotronTracker::visitVariableRFCavityFringeField",
1095 "Need to define a RINGDEFINITION to use VariableRFCavity element");
1104 *
gmsg <<
"Adding Vertical FFA Magnet" <<
endl;
1108 throw OpalException(
"ParallelCyclotronTracker::visitVerticalFFAMagnet",
1109 "Need to define a RINGDEFINITION to use VerticalFFAMagnet element");
1121 beamline_list::iterator sindex;
1124 localpair->first = elementType;
1126 for (
int i = 0; i < 8; i++)
1127 *(((localpair->second).first) + i) = *(BcParameter + i);
1129 (localpair->second).second = elptr;
1157 int maxnlp = 111111;
1160 *
gmsg << s <<
"min local particle number: "<< minnlp <<
endl;
1161 *
gmsg <<
"* max local particle number: " << maxnlp <<
endl;
1190 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1191 *
gmsg <<
"* The selected Beam line elements are :" <<
endl;
1208 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl <<
endl;
1216 for (
int k = 0; k < 6; k++) {
1226 std::placeholders::_1,
1227 std::placeholders::_2,
1228 std::placeholders::_3,
1229 std::placeholders::_4);
1233 *
gmsg <<
"* 2nd order Leap-Frog integrator" <<
endl;
1238 *
gmsg <<
"* Multiple time stepping (MTS) integrator" <<
endl;
1243 *
gmsg <<
"* 4th order Runge-Kutta integrator" <<
endl;
1255 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1256 *
gmsg <<
"* Finalizing i.e. write data and close files :" <<
endl;
1258 ((fd->second).second)->finalise();
1263 *
gmsg <<
"* ------------------------------------------------------------------------ *" <<
endl;
1278 double t = 0, dt = 0, oldReferenceTheta = 0;
1282 *
gmsg <<
"* MTS: Number of substeps per step is " << numSubsteps <<
endl;
1284 double const dt_inner = dt / double(numSubsteps);
1285 *
gmsg <<
"* MTS: The inner time step is therefore " << dt_inner *
Units::s2ns <<
" [ns]" <<
endl;
1289 bool flagTransition =
false;
1291 *
gmsg <<
"* ---------------------- Start tracking ---------------------------------- *" <<
endl;
1299 bool finishedTurn =
false;
1316 for (
int n = 0; n < numSubsteps; ++n) {
1357 temp_meanTheta, finishedTurn);
1360 oldReferenceTheta, temp_meanTheta);
1362 oldReferenceTheta = temp_meanTheta;
1369 finishedTurn =
true;
1373 <<
", Total number of live particles: "
1390 *
gmsg <<
"* ---------------------- DONE TRACKING PARTICLES ------------------------- *" <<
endl;
1420 double t = 0, dt = 0, oldReferenceTheta = 0;
1439 *
gmsg <<
"* ---------------------- Start tracking ---------------------------------- *" <<
endl;
1443 bool finishedTurn =
false;
1451 seoMode_m(t, dt, finishedTurn, Ttime, Tdeltr, Tdeltz, TturnNumber);
1467 throw OpalException(
"ParallelCyclotronTracker::GenericTracker()",
1468 "No such tracking mode.");
1478 *
gmsg <<
"* ---------------------- DONE TRACKING PARTICLES ------------------------- *" <<
endl;
1514 RFCavity* rfcavity,
double& Dold) {
1520 double distNew = (Rnew[0] * sinx - Rnew[1] * cosx) - PerpenDistance;
1521 double distOld = (Rold[0] * sinx - Rold[1] * cosx) - PerpenDistance;
1522 if (distOld > 0.0 && distNew <= 0.0) flag =
true;
1530 double radius = std::sqrt(std::pow(
itsBunch_m->
R[Pindex](0), 2.0) + std::pow(
itsBunch_m->
R[Pindex](1), 2.0)
1532 double rmin = rfcavity->
getRmin();
1533 double rmax = rfcavity->
getRmax();
1534 double nomalRadius = (radius - rmin) / (rmax - rmin);
1536 if (nomalRadius <= 1.0 && nomalRadius >= 0.0) {
1538 for (
int j = 0; j < 3; j++)
1544 for (
int j = 0; j < 3; j++)
1571 int lastTurn,
double& ,
double& ) {
1574 int Ndat = t.size();
1581 for (
int i = 0; i < Ndat; i++)
1586 for (
int i = 0; i < Ndat; i++)
1588 double ti = *(t.begin());
1589 double tf = t[t.size()-1];
1590 double T = (tf - ti);
1593 for (
int i = 0; i < Ndat; i++) {
1600 *
gmsg <<
"* ************************************* nuR ******************************************* *" <<
endl;
1601 *
gmsg <<
endl <<
"* ===> " << Ndat <<
" data points Ti=" << ti <<
" Tf= " << tf <<
" -> T= " <<
T <<
endl;
1609 *
gmsg <<
"* TUNE: Lomb analysis failed" <<
endl;
1610 *
gmsg <<
"* ************************************************************************************* *" <<
endl;
1620 *
gmsg <<
"* ************************************* nuZ ******************************************* *" <<
endl;
1621 *
gmsg <<
endl <<
"* ===> " << Ndat <<
" data points Ti=" << ti <<
" Tf= " << tf <<
" -> T= " <<
T <<
endl;
1627 *
gmsg <<
"* TUNE: Lomb analysis failed" <<
endl;
1628 *
gmsg <<
"* ************************************************************************************* *" <<
endl;
1641 if (elcycl !=
nullptr)
1643 throw OpalException(
"ParallelCyclotronTracker::getHarmonicNumber()",
1644 std::string(
"The first item in the FieldDimensions list does not ")
1645 +std::string(
"seem to be a Ring or a Cyclotron element"));
1657 for (
int d = 0; d < 3; ++d) {
1676 for (
int d = 0; d < 3; ++d) {
1695 double phi,
Vector_t const translationToGlobal) {
1697 particleVectors -= translationToGlobal;
1716 double phi,
Vector_t const translationToGlobal) {
1733 particleVectors += translationToGlobal;
1744 particleVectors -= meanR;
1757 reverseQuaternion(0) *= -1.0;
1763 particleVectors += meanR;
1776 particleVectors -= meanR;
1826 particleVectors += meanR;
1853 Vector_t const quaternionVectorComponent =
Vector_t({quaternion(1), quaternion(2), quaternion(3)});
1854 double const quaternionScalarComponent = quaternion(0);
1858 particleVectors[i] = 2.0f *
dot(quaternionVectorComponent, particleVectors[i]) * quaternionVectorComponent +
1859 (quaternionScalarComponent * quaternionScalarComponent -
1860 dot(quaternionVectorComponent, quaternionVectorComponent)) * particleVectors[i] + 2.0f *
1861 quaternionScalarComponent *
cross(quaternionVectorComponent, particleVectors[i]);
1867 double tolerance = 1.0e-10;
1868 double length2 =
dot(quaternion, quaternion);
1870 if (std::abs(length2) > tolerance && std::abs(length2 - 1.0f) > tolerance) {
1872 double length = std::sqrt(length2);
1873 quaternion /= length;
1879 double tolerance = 1.0e-10;
1880 double length2 =
dot(vector, vector);
1882 if (std::abs(length2) > tolerance && std::abs(length2 - 1.0f) > tolerance) {
1884 double length = std::sqrt(length2);
1963 double k_cos_theta =
dot(u, v);
1964 double k = std::sqrt(
dot(u, u) *
dot(v, v));
1965 double tolerance1 = 1.0e-5;
1966 double tolerance2 = 1.0e-8;
1969 if (std::abs(k_cos_theta / k + 1.0) < tolerance1) {
1976 if (
dot(resultVectorComponent, resultVectorComponent) < tolerance2) {
1981 double sinHalfAngle = std::sin(halfAngle);
1983 resultVectorComponent *= sinHalfAngle;
1986 k_cos_theta = std::cos(halfAngle);
1989 resultVectorComponent =
cross(u, v);
1992 quaternion(0) = k_cos_theta + k;
1993 quaternion(1) = resultVectorComponent(0);
1994 quaternion(2) = resultVectorComponent(1);
1995 quaternion(3) = resultVectorComponent(2);
2005 bool flagNeedUpdate =
false;
2016 double const distNew = (
itsBunch_m->
R[i][0] * ccd.sinAzimuth -
itsBunch_m->
R[i][1] * ccd.cosAzimuth) - ccd.perpenDistance;
2017 bool tagCrossing =
false;
2019 if (distNew <= 0.0) {
2020 distOld = (oldR[0] * ccd.sinAzimuth - oldR[1] * ccd.cosAzimuth) - ccd.perpenDistance;
2021 if (distOld > 0.0) tagCrossing =
true;
2025 double const dt2 = h - dt1;
2040 return flagNeedUpdate;
2047 bool flagNeedUpdate =
false;
2060 return flagNeedUpdate;
2067 bool flagNeedUpdate =
push(0.5 * h);
2082 flagNeedUpdate |=
kick(h);
2085 flagNeedUpdate |=
push(0.5 * h);
2099 Vacuum* vac =
static_cast<Vacuum*
>(((*sindex)->second).second);
2114 *
gmsg <<
"* Total number of particles after PluginElement= "
2132 allreduce(flagNeedUpdate, 1, std::logical_or<bool>());
2134 if (flagNeedUpdate) {
2136 std::vector<size_t> locLostParticleNum(bunchCount, 0);
2139 std::unique_ptr<size_t[]> localBinCount;
2142 localBinCount = std::unique_ptr<size_t[]>(
new size_t[leb]);
2143 for (
int i = 0; i < leb; ++i)
2144 localBinCount[i] = 0;
2161 for (
int i = 0; i < leb; ++i) {
2166 std::vector<size_t> localnum(bunchCount + 1);
2167 for (
size_t i = 0; i < localnum.size() - 1; ++i) {
2183 std::vector<size_t> totalnum(bunchCount + 1);
2186 allreduce(localnum.data(), totalnum.data(), localnum.size(), std::plus<size_t>());
2189 for (
short i = 0; i < bunchCount; ++i) {
2193 size_t sum = std::accumulate(totalnum.begin(),
2194 totalnum.end() - 1, 0);
2196 if (
sum != totalnum[bunchCount] ) {
2197 throw OpalException(
"ParallelCyclotronTracker::deleteParticle()",
2198 "Total number of particles " + std::to_string(totalnum[bunchCount]) +
2199 " != " + std::to_string(
sum) +
" (sum over all bunches)");
2202 size_t globLostParticleNum = 0;
2203 size_t locNumLost = std::accumulate(locLostParticleNum.begin(),
2204 locLostParticleNum.end(), 0);
2206 reduce(locNumLost, globLostParticleNum, 1, std::plus<size_t>());
2208 if ( globLostParticleNum > 0 ) {
2210 <<
", lost " << globLostParticleNum <<
" particles" <<
endl;
2213 if (totalnum[bunchCount] == 0) {
2215 return flagNeedUpdate;
2248 return flagNeedUpdate;
2264 outfTrackOrbit_m <<
"# The six-dimensional phase space data in the global Cartesian coordinates" << std::endl;
2265 outfTrackOrbit_m <<
"# Part. ID x [m] beta_x*gamma y [m] beta_y*gamma z [m] beta_z*gamma" << std::endl;
2335 *
gmsg <<
"* Restart in the local frame" <<
endl;
2352 *
gmsg <<
"* Restart in the global frame" <<
endl;
2372 double radius = std::sqrt(meanR[0] * meanR[0] + meanR[1] * meanR[1]);
2390 *
gmsg <<
endl <<
"* *********************** Bunch information in local frame: ************************";
2412 *
gmsg <<
endl <<
"* *********************** Bunch information in global frame: ***********************";
2424 double pTotalMean = 0.0;
2429 allreduce(pTotalMean, 1, std::plus<double>());
2434 if (tolerance > 0 &&
2435 std::abs(pTotalMean -
referencePtot) / pTotalMean > tolerance) {
2436 throw OpalException(
"ParallelCyclotronTracker::checkFileMomentum",
2437 "The total momentum of the particle distribution\n"
2438 "in the global reference frame: " +
2439 std::to_string(pTotalMean) +
",\n"
2440 "is different from the momentum given\n"
2441 "in the \"BEAM\" command: " +
2443 "In Opal-cycl the initial distribution\n"
2444 "is specified in the local reference frame.\n"
2445 "When using a \"FROMFILE\" type distribution, the momentum \n"
2446 "must be the same as the specified in the \"BEAM\" command,\n"
2447 "which is in global reference frame.");
2466 int found[2] = {-1, -1};
2482 int numberOfPart = 0;
2484 while(notReceived > 0) {
2489 if (rmsg ==
nullptr)
2490 ERRORMSG(
"Could not receive from client nodes in main." <<
endl);
2494 rmsg->
get(&numberOfPart);
2496 for (
int i = 0; i < numberOfPart; ++i) {
2499 for (
int ii = 0; ii < 6; ii++) {
2507 for (
int i = 0; i < counter; ++i) {
2511 for (
int j = 0; j < 3; ++j) {
2517 dvector_t::iterator itParameter = tmpr.begin();
2519 for (
auto tmpid : tmpi) {
2523 for (
int ii = 0; ii < 6; ii++) {
2535 for (
int i = 0; i < counter; i++) {
2539 for (
int j = 0; j < 3; j++) {
2546 ERRORMSG(
"Ippl::Comm->send(smsg, 0, tag) failed " <<
endl);
2574 double phi = 0.0, psi = 0.0;
2639 (((*DumpSindex)->second).second)->apply(meanR, meanP, temp_t,
extE_m,
extB_m);
2687 double buf[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
2704 if (buf[6] != 1.0) {
2710 refR =
Vector_t({buf[0], buf[1], buf[2]});
2711 refP =
Vector_t({buf[3], buf[4], buf[5]});
2728 *
gmsg <<
"* Warning: at integration step " <<
step_m + 1
2729 <<
" the reference particle (ID 0) is no longer in the bunch; falling back to "
2730 <<
"the bunch mean for the reference values and the dump frame of this and "
2731 <<
"all later dumps (H5 step attribute REFSOURCE = 2 in the GLOBAL and "
2732 <<
"REFERENCE dump frames)." <<
endl;
2763 int refSource = haveRef ? 0 : 2;
2777 double const theta = std::atan2(meanR(1), meanR(0));
2783 double const psi = 0.5 *
Physics::pi - std::acos(meanP(2) / betagamma_temp);
2795 referencePr = meanP(0) * std::cos(theta) + meanP(1) * std::sin(theta);
2805 (((*DumpSindex)->second).second)->apply(meanR, meanP, temp_t,
extE_m,
extB_m);
2811 bool dumpLocalFrame =
true;
2812 std::string dumpString =
"local";
2814 dumpLocalFrame =
false;
2815 dumpString =
"global";
2818 if (dumpLocalFrame ==
true) {
2831 for (
int k = 0; k < 6; k += 2) {
2851 if (dumpLocalFrame ==
true) {
2861 <<
" (no phase space dump for <= 2 particles)" <<
endl;
2864 <<
" (" << dumpString <<
" frame) at integration step " <<
step_m + 1 <<
endl;
2869 *
gmsg <<
"* T = " << temp_t <<
" s"
2871 *
gmsg <<
"* E = " << E <<
" MeV"
2872 <<
", beta * gamma = " << betagamma_temp <<
endl;
2898 const bool& finishedTurn)
2906 if ((
step_m + 1) % 1000 == 0) {
2995 *
gmsg <<
"* MBM: Time interval between neighbour bunches is set to "
2997 *
gmsg <<
"* MBM: The particles energy bin reset frequency is set to "
3008 *
gmsg <<
"* ------------------------- STATIC EQUILIBRIUM ORBIT MODE ----------------------------- *" <<
endl
3009 <<
"* Instruction: When the total particle number is equal to 2, SEO mode is triggered *" <<
endl
3010 <<
"* automatically. This mode does NOT include any RF cavities. The initial distribution *" <<
endl
3011 <<
"* file must be specified. In the file the first line is for reference particle and the *" <<
endl
3012 <<
"* second line is for off-center particle. The tune is calculated by FFT routines based *" <<
endl
3013 <<
"* on these two particles. *" <<
endl
3014 <<
"* ---------------- NOTE: SEO MODE ONLY WORKS SERIALLY ON SINGLE NODE ------------------ *" <<
endl;
3017 throw OpalException(
"Error in ParallelCyclotronTracker::initializeTracking_m",
3018 "SEO MODE ONLY WORKS SERIALLY ON SINGLE NODE");
3023 *
gmsg <<
"* ------------------------------ SINGLE PARTICLE MODE --------------------------------- *" <<
endl
3024 <<
"* Instruction: When the total particle number is equal to 1, single particle mode is *" <<
endl
3025 <<
"* triggered automatically. The initial distribution file must be specified which should *" <<
endl
3026 <<
"* contain only one line for the single particle *" <<
endl
3027 <<
"* ---------NOTE: SINGLE PARTICLE MODE ONLY WORKS SERIALLY ON A SINGLE NODE ------------ *" <<
endl;
3030 throw OpalException(
"Error in ParallelCyclotronTracker::initializeTracking_m",
3031 "SINGLE PARTICLE MODE ONLY WORKS SERIALLY ON A SINGLE NODE");
3042 throw OpalException(
"ParallelCyclotronTracker::initializeTracking_m()",
3043 "No such tracking mode.");
3047 return std::make_tuple(t, dt, oldReferenceTheta);
3059 double FinalMomentum2 = std::pow(refP(0), 2.0) + std::pow(refP(1), 2.0) + std::pow(refP(2), 2.0);
3061 *
gmsg <<
"* Final energy of reference particle = " << FinalEnergy <<
" [MeV]" <<
endl;
3063 *
gmsg <<
"* Final energy of reference particle: not available, "
3064 <<
"the reference particle (ID 0) is no longer in the bunch" <<
endl;
3075 *
gmsg <<
"* **************** The result for tune calculation (NO space charge) ******************* *" <<
endl
3076 <<
"* Number of tracked turns: " << TturnNumber.back() <<
endl;
3078 getTunes(Ttime, Tdeltr, Tdeltz, TturnNumber.back(), nur, nuz);
3091 *
gmsg <<
"* Cave: Turn number is not correct for restart mode"<<
endl;
3102 *
gmsg <<
endl <<
"* *********************** Bunch information in global frame: ***********************";
3109 *
gmsg <<
endl <<
"* No Particles left in bunch" <<
endl;
3110 *
gmsg <<
"* **********************************************************************************" <<
endl;
3132 double r_tuning[2], z_tuning[2];
3149 r_tuning[i] =
itsBunch_m->
R[i](0) * std::cos(OldTheta) +
3167 Tdeltz.push_back(z_tuning[1]);
3168 Tdeltr.push_back(r_tuning[1] - r_tuning[0]);
3175 bool& finishedTurn,
double& oldReferenceTheta) {
3209 temp_meanTheta, finishedTurn);
3212 oldReferenceTheta, temp_meanTheta);
3214 oldReferenceTheta = temp_meanTheta;
3241 static bool flagTransition =
false;
3322 finishedTurn =
true;
3326 <<
", Total number of live particles: "
3348 bool tag_crossing =
false;
3349 double DistOld = 0.0;
3354 rfcav =
static_cast<RFCavity*
>(((*sindex)->second).second);
3358 if ( tag_crossing ) {
3362 double dt1 = DistOld / (oldBeta *
Physics::c);
3363 double dt2 = dt - dt1;
3370 if (dt / dt1 < 1.0e9) {
3374 RFkick(rfcav, t, dt1, i);
3379 if (dt / dt2 < 1.0e9) {
3390 const double& oldReferenceTheta,
3391 const double& temp_meanTheta) {
3393 for (
unsigned int i=0; i<=2; i++) {
3398 <<
", Time = " << t *
Units::s2ns <<
" [ns]" << std::endl
3399 <<
" " << std::hypot(R(0), R(1))
3400 <<
" " << P(0) * std::cos(temp_meanTheta) + P(1) * std::sin(temp_meanTheta)
3402 <<
" " << - P(0) * std::sin(temp_meanTheta) + P(1) * std::cos(temp_meanTheta)
3404 <<
" " << P(2) << std::endl;
3412 const double& temp_meanTheta,
3413 bool& finishedTurn) {
3416 finishedTurn =
true;
3421 <<
", Time = " << t *
Units::s2ns <<
" [ns]" << std::endl
3422 <<
" " << std::sqrt(R(0) * R(0) + R(1) * R(1))
3423 <<
" " << P(0) * std::cos(temp_meanTheta) +
3424 P(1) * std::sin(temp_meanTheta)
3426 <<
" " << - P(0) * std::sin(temp_meanTheta) +
3427 P(1) * std::cos(temp_meanTheta)
3429 <<
" " << P(2) << std::endl;
3531 *
gmsg <<
"* SC mesh fit: mode " << (full ?
"FULL" :
"CORE") <<
", "
3533 <<
" % of the live charge, max " << core.
farMaxDistance <<
" sigma), "
3535 << core.
passes <<
" clipped passes, " << statistics.
numFlagged <<
" flagged, "
3536 << statistics.
numOutside <<
" outside the mesh, ";
3539 *
gmsg <<
"cells per sigma " << core.
sigma[0] / hr[0] <<
"/"
3540 << core.
sigma[1] / hr[1] <<
"/" << core.
sigma[2] / hr[2]
3541 <<
" (mesh of all particles ";
3543 *
gmsg <<
"no core particle (cells per sigma on the mesh of all particles ";
3545 *
gmsg << core.
sigma[0] / hrFull[0] <<
"/" << core.
sigma[1] / hrFull[1] <<
"/"
3547 << statistics.
turnSolves <<
" solves of this turn in FULL mode, "
3560 bool outOfBound = (((*sindex)->second).second)->apply(i, t, Efield, Bfield);
3573 bool outOfBound = (((*sindex)->second).second)->apply(R, P, t, Efield, Bfield);
3600 if ( flagTransition ) {
3602 *
gmsg <<
"* MBM: After one revolution, Multi-Bunch Mode will be invoked" <<
endl;
3612 throw OpalException(
"ParallelCyclotronTracker::injectBunch()",
3613 "Unknown return value " + std::to_string(result));
3647 std::vector<double> lpaths(1);
3680 for (
short b = 0; b <
mbHandler_m->getNumBunch(); ++b) {
T euclidean_norm(const Vector< T > &)
Euclidean norm.
Vector3D cross(const Vector3D &lhs, const Vector3D &rhs)
Vector cross product.
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
T prod_boost_vector(const boost::numeric::ublas::matrix< double > &rotation, const T &vector)
bool for_each(const BareFieldIterator< T, D > &p, SameFieldID s, C)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
void allreduce(const T *input, T *output, int count, Op op)
bool reduce(Communicate &, InputIterator, InputIterator, OutputIterator, const ReduceOp &, bool *IncludeVal=0)
Inform & level4(Inform &inf)
Inform & endl(Inform &inf)
Inform & level3(Inform &inf)
constexpr double haloSigma
The halo proper: live particles beyond haloSigma clipped rms widths in any axis.
constexpr double q_e
The elementary charge in As.
constexpr double c
The velocity of light in m/s.
constexpr double pi
The value of.
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.
bool angleBetweenAngles(const double angle, const double min, const double max)
check if angle (in rad and in range [0,2pi]) is within [min, max]
std::string doubleVectorToString(const std::vector< double > &v)
std::string boolVectorToUpperString(const std::vector< bool > &b)
Vector_t getBeta(Vector_t p)
double getGamma(Vector_t p)
const std::string & getOpalName() const
Return object name.
ParticleAttrib< Vector_t > Ef
double get_meanKineticEnergy() const
void getMeshFitFullBounds(Vector_t &rmin, Vector_t &rmax) const
MESHFIT=CORE: the bounds of all particles of the same fit.
ParticleAttrib< int > Bin
void boundp_destroyCycl()
const MeshFitParameters & getMeshFit() const
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 setComputeSCDiagnostics(bool compute)
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)
ParticleAttrib< ParticleOrigin > POrigin
virtual void computeSelfFields_cycl(double gamma)=0
ParticleAttrib< double > Q
void calcBeamParameters()
const CoreFitSC::CoreSelection & getMeshFitCore() const
size_t getTotalNumPerBunch(short n) const
ParticleAttrib< short > cavityGapCrossed
void setTotalNum(size_t n)
Vector_t getMeshSpacing(const Vector_t &rmin, const Vector_t &rmax) const
Mesh spacing that boundp() gives to particles within [rmin, rmax].
long long getLocalTrackStep() const
void setGlobalMeanR(Vector_t globalMeanR)
short getNumBunch() const
virtual void do_binaryRepart()
ParticleAttrib< double > dt
int getStepsPerTurn() const
bool isMeshFitRepartitionDue() 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)
void setMeshFitSolveStep(bool solveStep)
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
double getMomentumTolerance() const
const CoreFitSC::ModeState & getMeshFitMode() const
const MeshFitStatistics & getMeshFitStatistics() const
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)
unsigned int numRFCavities_m
RFCAVITY entries in FieldDimensions; gapCrossKick_m() has nothing to do without them.
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
bool setRefPartForDump_m(Vector_t &refR, Vector_t &refP)
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
bool statDumpBeforeNextSolve_m() const
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)
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
void repartition(bool force=false)
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
bool refLostWarned_m
setRefPartForDump_m() has reported the loss of ID 0 in this run
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()
double beamInitialRotation
bool getReferenceParticle(Vector_t &refR, Vector_t &refP) const
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 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
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.
virtual void visitOutputPlane(const OutputPlane &)
Apply the algorithm to a outputplane.
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
void checkInitialReferenceParticle(double refR, double refTheta, double refZ)
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
void setTurnNumber(int turn)
Turn number written into the loss records of apply(); the tracker sets it every step.
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
Vector_t getCentre() const
ElementBase * clone() const override
double getHorizontalExtent() const
void setGlobalFieldMap(Component *field)
Vector_t getNormal() const
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()
CavityType getCavityType() const noexcept
virtual double getCosAzimuth() const
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
std::string getCavityTypeString() const noexcept
virtual double getSinAzimuth() const
virtual std::string getFieldMapFN() const
virtual double getCycFrequency() const
virtual double getGapWidth() const
std::string getFrequencyModelName()
virtual double getPerpenDistance() const
virtual double getPhi0() const
virtual double getRmin() const
Ring describes a ring type geometry for tracking.
double getBeamRInit() 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 getBeamThetaInit() 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
std::string getResidualGasName() const
virtual bool checkVacuum(PartBunchBase< double, 3 > *bunch, Cyclotron *cycl)
double getTemperature() const
static std::shared_ptr< AbstractTimeDependence > getTimeDependence(std::string name)
const PartData itsReference
The reference information.
Result of selectCore(), the same on every rank.
unsigned int passes
clipped passes done, 0 to maxClipPasses
double getFarChargeFraction() const
Far charge over live charge, 0 without live charge.
std::size_t numLive
particles with Bin >= 0
std::size_t numFar
the other live particles
Vector_t sigma
clipped rms [m]
std::size_t numHalo
live particles beyond haloSigma * sigma in any axis
std::size_t numCore
live particles within nSigma * sigma in every axis
MESHFIT=CORE: statistics of the solves of this TRACK/RUN, for the stat file and the log.
size_t numOutside
particles outside the mesh domain at the last update()
size_t turnFullSolves
solves in FULL mode in this turn
size_t modeSwitches
switches between CORE and FULL
size_t turnSolves
solves in this turn
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, const double &timeStep) const
Write the stat file (OPAL-cycl)
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