18#ifndef PART_BUNCH_BASE_HPP
19#define PART_BUNCH_BASE_HPP
27#include "Structure/FieldSolver.h"
38template <
class T,
unsigned Dim>
87template <
class T,
unsigned Dim>
90 bool hasToReset =
false;
91 if (!R.isDirty()) hasToReset =
true;
93 for (
size_t i = 0; i < getLocalNum(); i++) {
95 if (use_dt_per_particle)
103 if (hasToReset) R.resetDirtyFlag();
107template <
class T,
unsigned Dim>
110 bool hasToReset =
false;
111 if (!R.isDirty()) hasToReset =
true;
113 for (
size_t i = 0; i < getLocalNum(); i++) {
115 if (use_dt_per_particle)
123 if (hasToReset) R.resetDirtyFlag();
127template <
class T,
unsigned Dim>
132template <
class T,
unsigned Dim>
134 std::vector<Distribution*> addedDistributions,
136 Inform m(
"setDistribution " );
138 dist_m->createOpalT(
this, addedDistributions, np);
141template <
class T,
unsigned Dim>
147template <
class T,
unsigned Dim>
149 return (pbin_m !=
nullptr);
153template <
class T,
unsigned Dim>
155 size_t numParticles = getLocalNum();
156 reduce(numParticles, numParticles, OpAddAssign());
157 setTotalNum(numParticles);
161template <
class T,
unsigned Dim>
170template <
class T,
unsigned Dim>
172 if (pbin_m !=
nullptr)
173 return pbin_m->getLastemittedBin();
178template <
class T,
unsigned Dim>
183template <
class T,
unsigned Dim>
188template <
class T,
unsigned Dim>
194template <
class T,
unsigned Dim>
199template <
class T,
unsigned Dim>
204template <
class T,
unsigned Dim>
209template <
class T,
unsigned Dim>
214template <
class T,
unsigned Dim>
216 if (pbin_m !=
nullptr) {
217 pbin_m->setPartNum(bin, num);
222template <
class T,
unsigned Dim>
224 this->Q = where(
eq(this->Bin, bin), q, 0.0);
228template <
class T,
unsigned Dim>
230 this->Q = where(
eq(this->Bin, bin), this->qi_m, 0.0);
234template <
class T,
unsigned Dim>
237 std::size_t localnum = 0;
240 for (
unsigned long k = 0; k < getLocalNum(); ++ k)
241 if (std::abs(R[k](0) - meanR(0)) > x(0) ||
242 std::abs(R[k](1) - meanR(1)) > x(1) ||
243 std::abs(R[k](2) - meanR(2)) > x(2)) {
248 gather(&localnum, &globalPartPerNode_m[0], 1);
250 size_t npOutside = std::accumulate(globalPartPerNode_m.get(),
251 globalPartPerNode_m.get() + Ippl::getNodes(), 0,
252 std::plus<size_t>());
267template <
class T,
unsigned Dim>
269 std::vector<double>& lineDensity,
270 std::pair<double, double>& meshInfo) {
272 get_bounds(rmin, rmax);
276 this->updateDomainLength(grid);
280 double length = rmax(2) - rmin(2);
281 double zmin = rmin(2) - dh_m * length, zmax = rmax(2) + dh_m * length;
282 double hz = (zmax - zmin) / (nBins - 2);
283 double perMeter = 1.0 / hz;
286 lineDensity.resize(nBins, 0.0);
287 std::fill(lineDensity.begin(), lineDensity.end(), 0.0);
289 const unsigned int lN = getLocalNum();
290 for (
unsigned int i = 0; i < lN; ++ i) {
291 const double z = R[i](2) - 0.5 * hz;
292 unsigned int idx = (z - zmin) / hz;
293 double tau = (z - zmin) / hz - idx;
295 lineDensity[idx] += Q[i] * (1.0 - tau) * perMeter;
296 lineDensity[idx + 1] += Q[i] * tau * perMeter;
299 reduce(&(lineDensity[0]), &(lineDensity[0]) + nBins, &(lineDensity[0]), OpAddAssign());
301 meshInfo.first = zmin;
302 meshInfo.second = hz;
306template <
class T,
unsigned Dim>
312 IpplTimings::startTimer(boundpTimer_m);
314 if ( !(R.isDirty() || ID.isDirty() ) && stateOfLastBoundP_ == unit_state_)
return;
316 stateOfLastBoundP_ = unit_state_;
318 if (!isGridFixed()) {
319 const int dimIdx = (dcBeam_m? 2: 3);
327 this->updateDomainLength(nr_m);
328 IpplTimings::startTimer(boundpBoundsTimer_m);
329 get_bounds(rmin_m, rmax_m);
330 IpplTimings::stopTimer(boundpBoundsTimer_m);
334 for (
int i = 0; i < dimIdx; i++) {
335 double length = std::abs(rmax_m[i] - rmin_m[i]);
336 if (length < 1e-10) {
340 rmax_m[i] += dh_m * length;
341 rmin_m[i] -= dh_m * length;
343 hr_m[i] = (rmax_m[i] - rmin_m[i]) / (nr_m[i] - 1);
346 rmax_m[2] = rmin_m[2] + periodLength_m;
347 hr_m[2] = periodLength_m / (nr_m[2] - 1);
349 for (
int i = 0; i < dimIdx; ++ i) {
350 volume *= std::abs(rmax_m[i] - rmin_m[i]);
353 if (volume < 1e-21 && getTotalNum() > 1 && std::abs(sum(Q)) > 0.0) {
354 WARNMSG(level1 <<
"!!! Extremely high particle density detected !!!" << endl);
358 if (hr_m[0] * hr_m[1] * hr_m[2] <= 0) {
363 this->updateFields(hr_m, origin);
365 IpplTimings::startTimer(boundpUpdateTimer_m);
367 IpplTimings::stopTimer(boundpUpdateTimer_m);
370 IpplTimings::stopTimer(boundpTimer_m);
374template <
class T,
unsigned Dim>
377 this->updateDomainLength(nr_m);
379 std::vector<size_t> tmpbinemitted;
384 const size_t localNum = getLocalNum();
388 const bool haveEnergyBins = weHaveEnergyBins();
389 if (haveEnergyBins) {
390 tmpbinemitted.resize(getNumberOfEnergyBins(), 0.0);
392 for (
unsigned int i = 0; i < localNum; i++) {
396 }
else if (haveEnergyBins) {
397 tmpbinemitted[Bin[i]]++;
403 calcBeamParameters();
404 gatherLoadBalanceStatistics();
406 reduce(ne, ne, OpAddAssign());
411template <
class T,
unsigned Dim>
414 std::unique_ptr<size_t[]> tmpbinemitted;
416 const size_t localNum = getLocalNum();
417 const size_t totalNum = getTotalNum();
420 if (weHaveEnergyBins()) {
421 tmpbinemitted = std::unique_ptr<size_t[]>(
new size_t[getNumberOfEnergyBins()]);
422 for (
int i = 0; i < getNumberOfEnergyBins(); i++) {
423 tmpbinemitted[i] = 0;
425 for (
unsigned int i = 0; i < localNum; i++) {
430 tmpbinemitted[Bin[i]]++;
433 Inform dmsg(
"destroy: ", INFORM_ALL_NODES);
434 for (
size_t i = 0; i < localNum; i++) {
443 performDestroy(
true);
446 calcBeamParameters();
447 gatherLoadBalanceStatistics();
449 size_t newTotalNum = getLocalNum();
450 reduce(newTotalNum, newTotalNum, OpAddAssign());
452 setTotalNum(newTotalNum);
454 return totalNum - newTotalNum;
458template <
class T,
unsigned Dim>
463template <
class T,
unsigned Dim>
468template <
class T,
unsigned Dim>
473template <
class T,
unsigned Dim>
478template <
class T,
unsigned Dim>
484template <
class T,
unsigned Dim>
486 return this->R[i](0);
490template <
class T,
unsigned Dim>
492 return this->R[i](1);
496template <
class T,
unsigned Dim>
498 return this->R[i](2);
502template <
class T,
unsigned Dim>
508template <
class T,
unsigned Dim>
514template <
class T,
unsigned Dim>
519template <
class T,
unsigned Dim>
522 this->getLocalBounds(rmin, rmax);
526 for (
unsigned int i = 0; i <
Dim; ++i) {
528 min[2*i + 1] = -rmax[i];
531 allreduce(min, 2*
Dim, std::less<double>());
533 for (
unsigned int i = 0; i <
Dim; ++i) {
535 rmax[i] = -min[2*i + 1];
540template <
class T,
unsigned Dim>
542 const size_t localNum = getLocalNum();
544 double maxValue = 1e8;
552 for (
size_t i = 1; i < localNum; ++ i) {
553 for (
unsigned short d = 0; d < 3u; ++ d) {
554 if (rmin(d) > R[i](d)) rmin(d) = R[i](d);
555 else if (rmax(d) < R[i](d)) rmax(d) = R[i](d);
561template <
class T,
unsigned Dim>
564 get_bounds(rmin, rmax);
566 std::pair<Vector_t<double, 3>,
double> sphere;
567 sphere.first = 0.5 * (rmin + rmax);
568 sphere.second = std::sqrt(
dot(rmax - sphere.first, rmax - sphere.first));
574template <
class T,
unsigned Dim>
577 getLocalBounds(rmin, rmax);
579 std::pair<Vector_t<double, 3>,
double> sphere;
580 sphere.first = 0.5 * (rmin + rmax);
581 sphere.second = std::sqrt(
dot(rmax - sphere.first, rmax - sphere.first));
587template <
class T,
unsigned Dim>
589 Inform msg(
"PartBunch ");
591 size_t i = getLocalNum();
594 R[i] = particle.
getR();
595 P[i] = particle.
getP();
598 msg <<
"Created one particle i= " << i << endl;
603template <
class T,
unsigned Dim>
609template <
class T,
unsigned Dim>
615template <
class T,
unsigned Dim>
621template <
class T,
unsigned Dim>
627template <
class T,
unsigned Dim>
633template <
class T,
unsigned Dim>
639template <
class T,
unsigned Dim>
645template <
class T,
unsigned Dim>
651template <
class T,
unsigned Dim>
657template <
class T,
unsigned Dim>
663template <
class T,
unsigned Dim>
669template <
class T,
unsigned Dim>
675template <
class T,
unsigned Dim>
681template <
class T,
unsigned Dim>
687template <
class T,
unsigned Dim>
693template <
class T,
unsigned Dim>
699template <
class T,
unsigned Dim>
705template <
class T,
unsigned Dim>
708 return dist_m->get_pmean();
710 double gamma = 0.1 / getM() + 1;
715template <
class T,
unsigned Dim>
721template <
class T,
unsigned Dim>
727template <
class T,
unsigned Dim>
732template <
class T,
unsigned Dim>
737template <
class T,
unsigned Dim>
742template <
class T,
unsigned Dim>
747template <
class T,
unsigned Dim>
752template <
class T,
unsigned Dim>
757template <
class T,
unsigned Dim>
762template <
class T,
unsigned Dim>
767template <
class T,
unsigned Dim>
772template <
class T,
unsigned Dim>
778template <
class T,
unsigned Dim>
784template <
class T,
unsigned Dim>
790template <
class T,
unsigned Dim>
796template <
class T,
unsigned Dim>
802template <
class T,
unsigned Dim>
808template <
class T,
unsigned Dim>
811 for (
int i = 0; i < Ippl::getNodes(); i++)
812 globalPartPerNode_m[i] = 0;
814 std::size_t localnum = getLocalNum();
815 gather(&localnum, &globalPartPerNode_m[0], 1);
819template <
class T,
unsigned Dim>
821 return globalPartPerNode_m[p];
825template <
class T,
unsigned Dim>
827 bounds(this->
P, min, max);
831template <
class T,
unsigned Dim>
834 IpplTimings::startTimer(statParamTimer_m);
835 get_bounds(rmin_m, rmax_m);
837 IpplTimings::stopTimer(statParamTimer_m);
840template <
class T,
unsigned Dim>
842 return couplingConstant_m;
846template <
class T,
unsigned Dim>
848 couplingConstant_m =
c;
852template <
class T,
unsigned Dim>
855 if (getTotalNum() != 0)
858 WARNMSG(
"Could not set total charge in PartBunch::setCharge based on getTotalNum" << endl);
862template <
class T,
unsigned Dim>
868template <
class T,
unsigned Dim>
870 massPerParticle_m = mass;
871 if (getTotalNum() != 0)
875template <
class T,
unsigned Dim>
877 massPerParticle_m = mass;
881template <
class T,
unsigned Dim>
887template <
class T,
unsigned Dim>
892template <
class T,
unsigned Dim>
894 return massPerParticle_m;
897template <
class T,
unsigned Dim>
914template <
class T,
unsigned Dim>
917 return fs_m->hasValidSolver();
924template <
class T,
unsigned Dim>
927 return fs_m->getFieldSolverType();
929 return FieldSolverType::NONE;
934template <
class T,
unsigned Dim>
940template <
class T,
unsigned Dim>
942 return stepsPerTurn_m;
946template <
class T,
unsigned Dim>
948 globalTrackStep_m = n;
952template <
class T,
unsigned Dim>
954 return globalTrackStep_m;
958template <
class T,
unsigned Dim>
960 localTrackStep_m = n;
964template <
class T,
unsigned Dim>
966 globalTrackStep_m++; localTrackStep_m++;
970template <
class T,
unsigned Dim>
972 return localTrackStep_m;
976template <
class T,
unsigned Dim>
979 bunchTotalNum_m.resize(n);
980 bunchLocalNum_m.resize(n);
984template <
class T,
unsigned Dim>
990template <
class T,
unsigned Dim>
992 globalMeanR_m = globalMeanR;
996template <
class T,
unsigned Dim>
998 return globalMeanR_m;
1002template <
class T,
unsigned Dim>
1005 globalToLocalQuaternion_m = globalToLocalQuaternion;
1009template <
class T,
unsigned Dim>
1011 return globalToLocalQuaternion_m;
1015template <
class T,
unsigned Dim>
1017 SteptoLastInj_m = n;
1021template <
class T,
unsigned Dim>
1023 return SteptoLastInj_m;
1026template <
class T,
unsigned Dim>
1028 return reference->getQ();
1032template <
class T,
unsigned Dim>
1034 return reference->getM();
1038template <
class T,
unsigned Dim>
1040 return reference->getP();
1044template <
class T,
unsigned Dim>
1046 return reference->getE();
1050template <
class T,
unsigned Dim>
1052 return refPOrigin_m;
1055template <
class T,
unsigned Dim>
1057 refPOrigin_m = origin;
1061template <
class T,
unsigned Dim>
1066template <
class T,
unsigned Dim>
1072template <
class T,
unsigned Dim>
1074 return dist_m->getType();
1078template <
class T,
unsigned Dim>
1080 const_cast<PartData *
>(reference)->setQ(q);
1084template <
class T,
unsigned Dim>
1086 const_cast<PartData *
>(reference)->setM(m);
1090template <
class T,
unsigned Dim>
1096template <
class T,
unsigned Dim>
1102template <
class T,
unsigned Dim>
1104 return reference->getGamma();
1108template <
class T,
unsigned Dim>
1114template <
class T,
unsigned Dim>
1120template <
class T,
unsigned Dim>
1126template <
class T,
unsigned Dim>
1133template <
class T,
unsigned Dim>
1138template <
class T,
unsigned Dim>
1141 if (getTotalNum() != 0) {
1142 Inform::FmtFlags_t ff = os.flags();
1144 double pathLength = get_sPos();
1146 os << std::scientific;
1147 os << level1 <<
"\n";
1148 os <<
"* ************** B U N C H ********************************************************* \n";
1149 os <<
"* NP = " << getTotalNum() <<
"\n";
1156 if (getTotalNum() >= 2) {
1158 os <<
"* rms momenta = " << std::setw(12) << std::setprecision(5) << get_prms() <<
" [beta gamma]\n";
1160 os <<
"* mean momenta = " << std::setw(12) << std::setprecision(5) << get_pmean() <<
" [beta gamma]\n";
1161 os <<
"* rms emittance = " << std::setw(12) << std::setprecision(5) << get_emit() <<
" (not normalized)\n";
1162 os <<
"* rms correlation = " << std::setw(12) << std::setprecision(5) << get_rprms() <<
"\n";
1165 os <<
"* dh = " << std::setw(13) << std::setprecision(5) << dh_m * 100 <<
" [%]\n";
1169 os <<
"* ********************************************************************************** " << endl;
1176template <
class T,
unsigned Dim>
1178 double thetaXY = atan2(y, x);
1184template <
class T,
unsigned Dim>
1194template <
class T,
unsigned Dim>
1196 throw OpalException(
"PartBunch<T, Dim>::runTests() ",
"No test supported.");
1200template <
class T,
unsigned Dim>
1205template <
class T,
unsigned Dim>
1207 if (i >= getLocalNum() || j >= getLocalNum() || i == j)
return;
1209 std::swap(R[i], R[j]);
1210 std::swap(P[i], P[j]);
1211 std::swap(Q[i], Q[j]);
1212 std::swap(M[i], M[j]);
1213 std::swap(Phi[i], Phi[j]);
1214 std::swap(Ef[i], Ef[j]);
1215 std::swap(Eftmp[i], Eftmp[j]);
1216 std::swap(Bf[i], Bf[j]);
1217 std::swap(Bin[i], Bin[j]);
1218 std::swap(dt[i], dt[j]);
1219 std::swap(PType[i], PType[j]);
1220 std::swap(POrigin[i], POrigin[j]);
1221 std::swap(TriID[i], TriID[j]);
1222 std::swap(cavityGapCrossed[i], cavityGapCrossed[j]);
1223 std::swap(bunchNum[i], bunchNum[j]);
1227template <
class T,
unsigned Dim>
1229 throw OpalException(
"PartBunch<T, Dim>::setBCAllPeriodic() ",
"Not supported BC.");
1233template <
class T,
unsigned Dim>
1235 throw OpalException(
"PartBunch<T, Dim>::setBCAllOpen() ",
"Not supported BC.");
1239template <
class T,
unsigned Dim>
1241 throw OpalException(
"PartBunch<T, Dim>::setBCForDCBeam() ",
"Not supported BC.");
1245template <
class T,
unsigned Dim>
1250template <
class T,
unsigned Dim>
1253 pb->addAttribute(
P);
1254 pb->addAttribute(
Q);
1255 pb->addAttribute(
M);
1256 pb->addAttribute(
Phi);
1257 pb->addAttribute(
Ef);
1258 pb->addAttribute(
Eftmp);
1259 pb->addAttribute(
Bf);
1260 pb->addAttribute(
Bin);
1261 pb->addAttribute(
dt);
1262 pb->addAttribute(PType);
1263 pb->addAttribute(POrigin);
1264 pb->addAttribute(TriID);
1265 pb->addAttribute(cavityGapCrossed);
1268 boundpTimer_m = IpplTimings::getTimer(
"Boundingbox");
1269 boundpBoundsTimer_m = IpplTimings::getTimer(
"Boundingbox-bounds");
1270 boundpUpdateTimer_m = IpplTimings::getTimer(
"Boundingbox-update");
1271 statParamTimer_m = IpplTimings::getTimer(
"Compute Statistics");
1272 selfFieldTimer_m = IpplTimings::getTimer(
"SelfField total");
1274 histoTimer_m = IpplTimings::getTimer(
"Histogram");
1276 distrCreate_m = IpplTimings::getTimer(
"Create Distr");
1277 distrReload_m = IpplTimings::getTimer(
"Load Distr");
1285template <
class T,
unsigned Dim>
1287 return pbase_m->getTotalNum();
1290template <
class T,
unsigned Dim>
1292 return pbase_m->getLocalNum();
1296template <
class T,
unsigned Dim>
1298 return pbase_m->getDestroyNum();
1301template <
class T,
unsigned Dim>
1303 return pbase_m->getGhostNum();
1306template <
class T,
unsigned Dim>
1308 pbase_m->setTotalNum(n);
1311template <
class T,
unsigned Dim>
1313 pbase_m->setLocalNum(n);
1316template <
class T,
unsigned Dim>
1318 return pbase_m->getLayout();
1321template <
class T,
unsigned Dim>
1323 return pbase_m->getLayout();
1326template <
class T,
unsigned Dim>
1328 return pbase_m->getUpdateFlag(f);
1331template <
class T,
unsigned Dim>
1333 pbase_m->setUpdateFlag(f, val);
1336template <
class T,
unsigned Dim>
1338 return pbase_m->singleInitNode();
1341template <
class T,
unsigned Dim>
1346template <
class T,
unsigned Dim>
1350 }
catch (
const IpplException& ex) {
1355template <
class T,
unsigned Dim>
1358 pbase_m->update(canSwap);
1359 }
catch (
const IpplException& ex) {
1364template <
class T,
unsigned Dim>
1366 pbase_m->createWithID(
id);
1369template <
class T,
unsigned Dim>
1374template <
class T,
unsigned Dim>
1376 pbase_m->globalCreate(np);
1379template <
class T,
unsigned Dim>
1381 pbase_m->destroy(
M, I, doNow);
1384template <
class T,
unsigned Dim>
1386 pbase_m->performDestroy(updateLocalNum);
1389template <
class T,
unsigned Dim>
1391 pbase_m->ghostDestroy(
M, I);
1394template <
class T,
unsigned Dim>
1399template <
class T,
unsigned Dim>
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
boost::numeric::ublas::matrix< double > matrix_t
ippl::Vector< T, Dim > Vector_t
Inform & operator<<(Inform &os, PartBunch< T, Dim > &p)
ippl::ParticleAttrib< T > ParticleAttrib
constexpr double two_pi
The value of.
constexpr double e
The value of.
constexpr double c
The velocity of light in m/s.
bool eq(double x, double y)
std::string getChargeString(double charge, unsigned int precision=3)
std::string getEnergyString(double energyInMeV, unsigned int precision=3)
std::string getTimeString(double time, unsigned int precision=3)
std::string getLengthString(double spos, unsigned int precision=3)
static OpalData * getInstance()
const Vector_t< double, 3 > & getP() const
Get momentum.
const Vector_t< double, 3 > & getR() const
Get position in m.
int getSteptoLastInj() const
long long localTrackStep_m
step in a TRACK command
ParticleAttrib< int > bunchNum
void gatherLoadBalanceStatistics()
Vector_t< T, Dim > get_hr() const
ParticleAttrib< double > Phi
double getMassPerParticle() const
void setBeamFrequency(double v)
Vector_t< T, Dim > get_prms() const
void getLocalBounds(Vector_t< T, Dim > &rmin, Vector_t< T, Dim > &rmax) const
void updateFields(const Vector_t< T, Dim > &, const Vector_t< T, Dim > &origin)
Vector_t< double, Dim > rmin_m
ParticleLayout< double, 3 > & getLayout()
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)
std::unique_ptr< Inform > pmsg_m
void destroy(size_t M, size_t I, bool doNow=false)
Vector_t< T, Dim > globalMeanR_m
double t_m
holds the actual time of the integration
const PartData * reference
relative enlargement of the mesh
void setChargeZeroPart(double q)
Vector_t< T, Dim > get_99_99Percentile() const
ParticleAttrib< Vector_t< T, Dim > > Ef
size_t calcNumPartsOutside(Vector_t< T, Dim > x)
returns the number of particles outside of a box defined by x
Vector_t< T, Dim > get_normalizedEps_99Percentile() const
void setLocalTrackStep(long long n)
step in a TRACK command
size_t getLoadBalance(int p) const
void setPType(const std::string &type)
void calcBeamParameters()
Vector_t< T, Dim > get_maxExtent() const
Vector_t< T, Dim > get_pmean() const
int stepsPerTurn_m
steps per turn for OPAL-cycl
ParticleAttrib< int > Bin
double spos_m
the position along design trajectory
double getQ() const
Access to reference data.
void swap(unsigned int i, unsigned int j)
std::pair< Vector_t< T, Dim >, double > getLocalBoundingSphere()
ParticleAttrib< double > M
Quaternion_t globalToLocalQuaternion_m
void resetInterpolationCache(bool clearCache=false)
void resetQ(double q)
Set reference data.
Vector_t< double, Dim > rmax_m
void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion)
std::pair< Vector_t< T, Dim >, double > getBoundingSphere()
void switchToUnitlessPositions(bool use_dt_per_particle=false)
double getCharge() const
get the total charge per simulation particle
double getInitialBeta() const
void get_PBounds(Vector_t< T, Dim > &min, Vector_t< T, Dim > &max) const
Vector_t< T, Dim > get_rrms() const
size_t getDestroyNum() const
std::unique_ptr< size_t[]> binemitted_m
Vector_t< T, Dim > get_halo() const
Vector_t< T, Dim > get_origin() const
short numBunch_m
current bunch number
short getNumBunch() const
double getGamma(int i) const
Vector_t< T, Dim > get_68Percentile() const
void setLocalBinCount(size_t num, int bin)
ParticleAttrib< double > dt
double get_meanKineticEnergy()
int getNumberOfEnergyBins()
double dt_m
6x6 matrix of the moments of the beam
long long getLocalTrackStep() const
void get_bounds(Vector_t< T, Dim > &rmin, Vector_t< T, Dim > &rmax) const
void ghostDestroy(size_t M, size_t I)
double calculateAngle(double x, double y)
long long globalTrackStep_m
if multiple TRACK commands
size_t getLocalNum() const
double dh_m
Mesh enlargement.
std::vector< size_t > bunchTotalNum_m
number of particles per bunch
void setZ(int i, double zcoo)
void setSolver(std::string solver)
void setLocalNum(size_t n)
Vector_t< double, Dim > R(size_t i)
Vector_t< T, Dim > get_99Percentile() const
Vector_t< T, Dim > get_normalizedEps_99_99Percentile() const
void calcLineDensity(unsigned int nBins, std::vector< double > &lineDensity, std::pair< double, double > &meshInfo)
calculates the 1d line density (not normalized) and append it to a file.
Vector_t< T, Dim > get_rmean() const
double getChargePerParticle() const
get the macro particle charge
ParticleAttrib< Vector_t< T, Dim > > P
Vector_t< T, Dim > getGlobalMeanR()
void setup(AbstractParticle< T, Dim > *pb)
void setSteptoLastInj(int n)
ParticleAttrib< Vector_t< T, Dim > > Eftmp
void setStepsPerTurn(int n)
Vector_t< T, Dim > get_pmean_Distribution() const
Vector_t< T, Dim > get_emit() const
const PartData * getReference() const
Vector_t< T, Dim > get_95Percentile() const
std::unique_ptr< std::ofstream > f_stream
Vector_t< T, Dim > get_centroid() const
void setUpdateFlag(UpdateFlags_t f, bool val)
void setGlobalTrackStep(long long n)
step in multiple TRACK commands
Vector_t< double, Dim > hr_m
mesh size [m]
long long getGlobalTrackStep() const
void initialize(FieldLayout_t< Dim > &fl, Mesh_t< Dim > &mesh)
double getInitialGamma() const
void globalCreate(size_t np)
std::vector< size_t > bunchLocalNum_m
Inform & print(Inform &os)
Quaternion_t getGlobalToLocalQuaternion()
double getBeta(int i) const
bool getUpdateFlag(UpdateFlags_t f) const
Vector_t< T, Dim > get_normalizedEps_95Percentile() const
void switchOffUnitlessPositions(bool use_dt_per_particle=false)
void createWithID(unsigned id)
double couplingConstant_m
void setMassZeroPart(double mass)
Vector_t< T, Dim > get_normalizedEps_68Percentile() const
double getCouplingConstant() const
size_t getTotalNum() const
void calcGammas()
Compute the gammas of all bins.
void set_meshEnlargement(double dh)
double getEmissionDeltaT()
Vector_t< T, Dim > get_rprms() const
void setCouplingConstant(double c)
void setGlobalMeanR(Vector_t< T, Dim > globalMeanR)
bool getFieldSolverType() const
Return the fieldsolver type if we have a fieldsolver.
void setTotalNum(size_t n)
void setNumBunch(short n)
int getStepsPerTurn() const
ParticleAttrib< double > Q
double getBinGamma(int bin)
Get gamma of one bin.
Vector_t< T, Dim > get_norm_emit() const
std::unique_ptr< size_t[]> globalPartPerNode_m
ParticleAttrib< Vector_t< T, Dim > > Bf
size_t getGhostNum() const
size_t emitParticles(double eZ)
Emit particles in the given bin i.e. copy the particles from the bin structure into the particle cont...
std::unique_ptr< double[]> bingamma_m
holds the gamma of the bin
double getBeta() const
The relativistic beta per particle.
void initSolver() override
static ParticleType getParticleType(const std::string &str)
The base class for all OPAL exceptions.