PartBunchBase.h 17.6 KB
Newer Older
1 2 3
#ifndef PART_BUNCH_BASE_H
#define PART_BUNCH_BASE_H

4 5
#include "Ippl.h"
#include "Particle/AbstractParticle.h" //TODO should be in Ippl.h
6
#include "Algorithms/PBunchDefs.h"
7 8 9 10 11 12 13 14 15
#include "Algorithms/OpalParticle.h"
#include "Algorithms/CoordinateSystemTrafo.h"
#include "FixedAlgebra/FMatrix.h"
#include "FixedAlgebra/FVector.h"
#include "Algorithms/PartBins.h"
#include "Algorithms/PartBinsCyc.h"
#include "Algorithms/PartData.h"
#include "Algorithms/Quaternion.h"

16 17
#include <memory>
#include <utility>
18 19 20 21
#include <vector>

#include "Structure/FieldSolver.h"
#include "Algorithms/ListElem.h"
snuverink_j's avatar
snuverink_j committed
22

frey_m's avatar
frey_m committed
23
class Distribution;
24 25 26

template <class T, int, int> class FMatrix;
template <class T, int> class FVector;
27 28 29 30

template <class T, unsigned Dim>
class PartBunchBase
{
31
public:
32
    typedef typename AbstractParticle<T, Dim>::ParticlePos_t   ParticlePos_t;
33
    typedef typename AbstractParticle<T, Dim>::ParticleIndex_t ParticleIndex_t;
34 35
    typedef typename AbstractParticle<T, Dim>::UpdateFlags     UpdateFlags_t;
    typedef typename AbstractParticle<T, Dim>::Position_t      Position_t;
kraus's avatar
kraus committed
36

37
    typedef std::pair<Vector_t, Vector_t> VectorPair_t;
kraus's avatar
kraus committed
38

39
    static const unsigned Dimension = Dim;
kraus's avatar
kraus committed
40

41
    enum UnitState_t { units = 0, unitless = 1 };
kraus's avatar
kraus committed
42

43
public:
kraus's avatar
kraus committed
44

45
    explicit PartBunchBase(AbstractParticle<T, Dim>* pb);
kraus's avatar
kraus committed
46

frey_m's avatar
frey_m committed
47
    virtual ~PartBunchBase() { }
kraus's avatar
kraus committed
48

frey_m's avatar
frey_m committed
49
    PartBunchBase(AbstractParticle<T, Dim>* pb, const PartData *ref);
kraus's avatar
kraus committed
50

51
    PartBunchBase(const PartBunchBase &rhs) = delete; // implement if needed
kraus's avatar
kraus committed
52

53 54 55
    /*
     * Bunch common member functions
     */
kraus's avatar
kraus committed
56

57 58
    // This is required since we initialize the Layout and the RegionLayout with default constructor
    virtual void initialize(FieldLayout_t *fLayout) = 0;
kraus's avatar
kraus committed
59

60
    bool getIfBeamEmitting();
kraus's avatar
kraus committed
61

62
    int getLastEmittedEnergyBin();
kraus's avatar
kraus committed
63

64
    size_t getNumberOfEmissionSteps();
kraus's avatar
kraus committed
65

66
    int getNumberOfEnergyBins();
kraus's avatar
kraus committed
67

68
    void Rebin();
kraus's avatar
kraus committed
69

70
    void setEnergyBins(int numberOfEnergyBins);
kraus's avatar
kraus committed
71

72
    bool weHaveEnergyBins();
kraus's avatar
kraus committed
73

74
    //FIXME: unify methods, use convention that all particles have own dt
75
    void switchToUnitlessPositions(bool use_dt_per_particle = false);
kraus's avatar
kraus committed
76

77
    //FIXME: unify methods, use convention that all particles have own dt
78
    void switchOffUnitlessPositions(bool use_dt_per_particle = false);
kraus's avatar
kraus committed
79

80 81
    void setDistribution(Distribution *d,
                         std::vector<Distribution *> addedDistributions,
82
                         size_t &np);
kraus's avatar
kraus committed
83

84
    bool isGridFixed() const;
85

86
    bool hasBinning() const;
kraus's avatar
kraus committed
87 88


89 90 91
    /*
       Energy bins related functions
     */
kraus's avatar
kraus committed
92

93
    void setTEmission(double t);
kraus's avatar
kraus committed
94

95
    double getTEmission();
kraus's avatar
kraus committed
96

97
    bool doEmission();
kraus's avatar
kraus committed
98

99
    bool weHaveBins() const;
kraus's avatar
kraus committed
100

101
    void setPBins(PartBins *pbin);
kraus's avatar
kraus committed
102

103
    void setPBins(PartBinsCyc *pbin);
kraus's avatar
kraus committed
104

105 106 107 108
    /** \brief Emit particles in the given bin
        i.e. copy the particles from the bin structure into the
        particle container
    */
109
    size_t emitParticles(double eZ);
kraus's avatar
kraus committed
110

111
    void updateNumTotal();
kraus's avatar
kraus committed
112

113
    void rebin();
kraus's avatar
kraus committed
114

115
    int getLastemittedBin();
kraus's avatar
kraus committed
116

117 118
    void setLocalBinCount(size_t num, int bin);

119
    /** \brief Compute the gammas of all bins */
120
    void calcGammas();
kraus's avatar
kraus committed
121

122
    void calcGammas_cycl();
kraus's avatar
kraus committed
123

124 125
    /** \brief Get gamma of one bin */
    double getBinGamma(int bin);
kraus's avatar
kraus committed
126

127
    /** \brief Set the charge of one bin to the value of q and all other to zero */
128
    virtual void setBinCharge(int bin, double q);
kraus's avatar
kraus committed
129

130
    /** \brief Set the charge of all other the ones in bin to zero */
131
    virtual void setBinCharge(int bin);
kraus's avatar
kraus committed
132

133
    /** \brief returns the number of particles outside of a box defined by x */
134
    size_t calcNumPartsOutside(Vector_t x);
kraus's avatar
kraus committed
135

136 137
    void calcLineDensity(unsigned int nBins, std::vector<double> &lineDensity,
                         std::pair<double, double> &meshInfo);
kraus's avatar
kraus committed
138

139 140
    void setBeamFrequency(double v);

141 142 143
    /*
       Mesh and Field Layout related functions
     */
kraus's avatar
kraus committed
144

145
    virtual void boundp();
kraus's avatar
kraus committed
146

frey_m's avatar
frey_m committed
147 148
    /** delete particles which are too far away from the center of beam*/
    void boundp_destroy();
kraus's avatar
kraus committed
149

150
    /** This is only temporary in order to get the collimator and pepperpot working */
frey_m's avatar
frey_m committed
151
    size_t boundp_destroyT();
kraus's avatar
kraus committed
152

frey_m's avatar
frey_m committed
153
    size_t destroyT();
kraus's avatar
kraus committed
154

155 156 157
    /*
       Read out coordinates
     */
kraus's avatar
kraus committed
158

159 160
    virtual double getPx(int i);
    virtual double getPy(int i);
161 162 163
    virtual double getPz(int i);

    virtual double getPx0(int i);
164
    virtual double getPy0(int i);
165 166 167 168 169 170 171 172 173

    virtual double getX(int i);
    virtual double getY(int i);
    virtual double getZ(int i);

    virtual double getX0(int i);
    virtual double getY0(int i);

    virtual void setZ(int i, double zcoo);
kraus's avatar
kraus committed
174

175
    void get_bounds(Vector_t &rmin, Vector_t &rmax);
kraus's avatar
kraus committed
176

177
    void getLocalBounds(Vector_t &rmin, Vector_t &rmax);
kraus's avatar
kraus committed
178

179
    std::pair<Vector_t, double> getBoundingSphere();
kraus's avatar
kraus committed
180

181
    std::pair<Vector_t, double> getLocalBoundingSphere();
kraus's avatar
kraus committed
182 183


184 185 186
    /*
       Compatibility function push_back
     */
kraus's avatar
kraus committed
187

188
    void push_back(OpalParticle p);
kraus's avatar
kraus committed
189

190 191
    void set_part(FVector<double, 6> z, int ii);

192
    void set_part(OpalParticle p, int ii);
kraus's avatar
kraus committed
193

194
    OpalParticle get_part(int ii);
kraus's avatar
kraus committed
195

196 197 198 199 200 201
    /// Return maximum amplitudes.
    //  The matrix [b]D[/b] is used to normalise the first two modes.
    //  The maximum normalised amplitudes for these modes are stored
    //  in [b]axmax[/b] and [b]aymax[/b].
    void maximumAmplitudes(const FMatrix<double, 6, 6> &D,
                           double &axmax, double &aymax);
kraus's avatar
kraus committed
202

203
    void   setdT(double dt);
204 205 206
    double getdT() const;

    void   setT(double t);
207
    void   incrementT();
208
    double getT() const;
kraus's avatar
kraus committed
209

210 211 212 213 214 215
    /**
     * get the spos of the primary beam
     *
     * @param none
     *
     */
216
    double get_sPos() const;
kraus's avatar
kraus committed
217

218 219 220
    void set_sPos(double s);

    double get_gamma() const;
kraus's avatar
kraus committed
221

222 223 224 225 226 227 228 229 230 231 232 233
    double get_meanKineticEnergy() const;
    Vector_t get_origin() const;
    Vector_t get_maxExtent() const;
    Vector_t get_centroid() const;
    Vector_t get_rrms() const;
    Vector_t get_rprms() const;
    Vector_t get_rmean() const;
    Vector_t get_prms() const;
    Vector_t get_pmean() const;
    Vector_t get_pmean_Distribution() const;
    Vector_t get_emit() const;
    Vector_t get_norm_emit() const;
234
    Vector_t get_halo() const;
frey_m's avatar
frey_m committed
235
    virtual Vector_t get_hr() const;
236 237 238 239 240 241

    double get_Dx() const;
    double get_Dy() const;

    double get_DDx() const;
    double get_DDy() const;
kraus's avatar
kraus committed
242

frey_m's avatar
frey_m committed
243
    virtual void set_meshEnlargement(double dh);
244 245 246

    void gatherLoadBalanceStatistics();
    size_t getLoadBalance(int p) const;
kraus's avatar
kraus committed
247

248
    void get_PBounds(Vector_t &min, Vector_t &max) const;
kraus's avatar
kraus committed
249

250
    void calcBeamParameters();
kraus's avatar
kraus committed
251

252
    void calcBeamParametersInitial(); // Calculate initial beam parameters before emission.
kraus's avatar
kraus committed
253

254 255
    double getCouplingConstant() const;
    void setCouplingConstant(double c);
kraus's avatar
kraus committed
256

257 258 259 260 261 262 263
    // set the charge per simulation particle
    void setCharge(double q);
    // set the charge per simulation particle when total particle number equals 0
    void setChargeZeroPart(double q);

    // set the mass per simulation particle
    void setMass(double mass);
kraus's avatar
kraus committed
264

265 266 267 268 269
    /// get the total charge per simulation particle
    double getCharge() const;

    /// get the macro particle charge
    double getChargePerParticle() const;
kraus's avatar
kraus committed
270

271
    virtual void setSolver(FieldSolver *fs);
kraus's avatar
kraus committed
272

273
    bool hasFieldSolver();
kraus's avatar
kraus committed
274

275
    std::string getFieldSolverType() const;
kraus's avatar
kraus committed
276

277 278 279 280 281 282 283 284 285 286 287 288
    void setStepsPerTurn(int n);
    int getStepsPerTurn() const;

    /// step in multiple TRACK commands
    void setGlobalTrackStep(long long n);
    long long getGlobalTrackStep() const;

    /// step in a TRACK command
    void setLocalTrackStep(long long n);
    void incTrackSteps();
    long long getLocalTrackStep() const;

frey_m's avatar
frey_m committed
289 290 291 292 293 294 295 296 297 298 299 300 301 302
    void setNumBunch(short n);
    short getNumBunch() const;

    // used in ParallelCyclotronTracker for multi-bunch mode
    void setTotalNumPerBunch(size_t numpart, short n);
    size_t getTotalNumPerBunch(short n) const;

    void setLocalNumPerBunch(size_t numpart, short n);
    size_t getLocalNumPerBunch(short n) const;

    /* used in initializeTracking_m of ParallelCyclotronTracker
     * for multi-bunch mode
     */
    void countTotalNumPerBunch();
303 304 305 306 307

    void setGlobalMeanR(Vector_t globalMeanR);
    Vector_t getGlobalMeanR();
    void setGlobalToLocalQuaternion(Quaternion_t globalToLocalQuaternion);
    Quaternion_t getGlobalToLocalQuaternion();
kraus's avatar
kraus committed
308

309
    void setSteptoLastInj(int n);
310
    int getSteptoLastInj() const;
kraus's avatar
kraus committed
311

312 313
    /// calculate average angle of longitudinal direction of bins
    double calcMeanPhi();
kraus's avatar
kraus committed
314

315 316
    /// reset Bin[] for each particle according to the method given in paper PAST-AB(064402) by  G. Fubiani et al.
    bool resetPartBinID2(const double eta);
kraus's avatar
kraus committed
317

frey_m's avatar
frey_m committed
318 319
    bool resetPartBinBunch();

320
    ///@{ Access to reference data
321 322 323 324
    double getQ() const;
    double getM() const;
    double getP() const;
    double getE() const;
325 326 327 328 329
    ParticleType::type getPType() const;
    double getInitialBeta() const;
    double getInitialGamma() const;
    ///@}
    ///@{ Set reference data
330 331
    void resetQ(double q);
    void resetM(double m);
332 333
    void setPType(ParticleType::type);
    ///@}
334
    double getdE() const;
335 336 337
    virtual double getGamma(int i);
    virtual double getBeta(int i);
    virtual void actT();
kraus's avatar
kraus committed
338

339
    const PartData *getReference() const;
kraus's avatar
kraus committed
340

341
    double getEmissionDeltaT();
kraus's avatar
kraus committed
342

343 344 345 346 347 348
    Quaternion_t getQKs3D();
    void         setQKs3D(Quaternion_t q);
    Vector_t     getKs3DRefr();
    void         setKs3DRefr(Vector_t r);
    Vector_t     getKs3DRefp();
    void         setKs3DRefp(Vector_t p);
kraus's avatar
kraus committed
349

350
    void iterateEmittedBin(int binNumber);
kraus's avatar
kraus committed
351

352
    void calcEMean();
kraus's avatar
kraus committed
353

354
    Inform &print(Inform &os);
kraus's avatar
kraus committed
355

356
    /*
kraus's avatar
kraus committed
357
     * (Pure) virtual member functions
358
     */
kraus's avatar
kraus committed
359

360
    virtual void runTests();
kraus's avatar
kraus committed
361

frey_m's avatar
frey_m committed
362
    virtual void do_binaryRepart();
kraus's avatar
kraus committed
363

364
    virtual void resetInterpolationCache(bool clearCache = false);
kraus's avatar
kraus committed
365

366 367
    /** \brief calculates back the max/min of the efield on the grid */
    virtual VectorPair_t getEExtrema() = 0;
kraus's avatar
kraus committed
368

369
    virtual double getRho(int x, int y, int z) = 0;
kraus's avatar
kraus committed
370

371
    virtual void computeSelfFields() = 0;
372 373

    /** /brief used for self fields with binned distribution */
374
    virtual void computeSelfFields(int bin) = 0;
375

376
    virtual void computeSelfFields_cycl(double gamma) = 0;
377
    virtual void computeSelfFields_cycl(int bin) = 0;
kraus's avatar
kraus committed
378

frey_m's avatar
frey_m committed
379
    virtual void swap(unsigned int i, unsigned int j);
kraus's avatar
kraus committed
380

frey_m's avatar
frey_m committed
381 382 383
    /*
       Mesh and Field Layout related functions
     */
kraus's avatar
kraus committed
384

frey_m's avatar
frey_m committed
385 386 387 388
    virtual void setBCAllPeriodic();
    virtual void setBCAllOpen();

    virtual void setBCForDCBeam();
kraus's avatar
kraus committed
389 390


391
//     virtual void setMesh(Mesh_t* mesh) = 0;
392
//     virtual Mesh_t &getMesh() = 0;
kraus's avatar
kraus committed
393

394 395
//     virtual void setFieldLayout(FieldLayout_t* fLayout) = 0;
    virtual FieldLayout_t &getFieldLayout() = 0;
kraus's avatar
kraus committed
396

397 398
    virtual void resizeMesh() { };

399 400 401
    /*
     * Wrapped member functions of IpplParticleBase
     */
kraus's avatar
kraus committed
402

403 404 405 406
    size_t getTotalNum() const;
    void setTotalNum(size_t n);
    void setLocalNum(size_t n);
    size_t getLocalNum() const;
kraus's avatar
kraus committed
407

408 409
    size_t getDestroyNum() const;
    size_t getGhostNum() const;
kraus's avatar
kraus committed
410

411 412
    unsigned int getMinimumNumberOfParticlesPerCore() const;
    void setMinimumNumberOfParticlesPerCore(unsigned int n);
kraus's avatar
kraus committed
413

414 415
    ParticleLayout<T, Dim> & getLayout();
    const ParticleLayout<T, Dim>& getLayout() const;
kraus's avatar
kraus committed
416

417 418
    bool getUpdateFlag(UpdateFlags_t f) const;
    void setUpdateFlag(UpdateFlags_t f, bool val);
kraus's avatar
kraus committed
419 420


421 422 423
    ParticleBConds<Position_t, Dimension>& getBConds() {
        return pbase->getBConds();
    }
kraus's avatar
kraus committed
424

425 426 427
    void setBConds(const ParticleBConds<Position_t, Dimension>& bc) {
        pbase->setBConds(bc);
    }
kraus's avatar
kraus committed
428

429
    bool singleInitNode() const;
kraus's avatar
kraus committed
430

431
    void resetID();
kraus's avatar
kraus committed
432

433 434
    void update();
    void update(const ParticleAttrib<char>& canSwap);
kraus's avatar
kraus committed
435

436 437 438
    void createWithID(unsigned id);
    void create(size_t M);
    void globalCreate(size_t np);
kraus's avatar
kraus committed
439

440 441 442
    void destroy(size_t M, size_t I, bool doNow = false);
    void performDestroy(bool updateLocalNum = false);
    void ghostDestroy(size_t M, size_t I);
kraus's avatar
kraus committed
443

444
protected:
445
    size_t calcMoments();    // Calculates bunch moments using only emitted particles.
kraus's avatar
kraus committed
446

snuverink_j's avatar
snuverink_j committed
447
    /* Calculates bunch moments by summing over bins
448 449 450
     * (not accurate when any particles have been emitted).
     */
    void calcMomentsInitial();
snuverink_j's avatar
snuverink_j committed
451
    /// angle range [0~2PI) degree
452
    double calculateAngle(double x, double y);
kraus's avatar
kraus committed
453 454


frey_m's avatar
frey_m committed
455
private:
frey_m's avatar
frey_m committed
456
    virtual void updateDomainLength(Vektor<int, 3>& grid) = 0;
kraus's avatar
kraus committed
457

frey_m's avatar
frey_m committed
458
    virtual void updateFields(const Vector_t& hr, const Vector_t& origin);
kraus's avatar
kraus committed
459

frey_m's avatar
frey_m committed
460
    void setup(AbstractParticle<T, Dim>* pb);
kraus's avatar
kraus committed
461

462 463 464 465
public:
    /*
     * Bunch attributes
     */
kraus's avatar
kraus committed
466 467


468 469
    ParticlePos_t& R;
    ParticleIndex_t& ID;
kraus's avatar
kraus committed
470 471


472 473 474 475 476 477 478 479
    // Particle container attributes
    ParticleAttrib< Vector_t > P;      // particle momentum //  ParticleSpatialLayout<double, 3>::ParticlePos_t P;
    ParticleAttrib< double >   Q;      // charge per simulation particle, unit: C.
    ParticleAttrib< double >   M;      // mass per simulation particle, for multi-species particle tracking, unit:GeV/c^2.
    ParticleAttrib< double >   Phi;    // the electric potential
    ParticleAttrib< Vector_t > Ef;     // e field vector
    ParticleAttrib< Vector_t > Eftmp;  // e field vector for gun simulations

480
    ParticleAttrib< Vector_t > Bf;    // b field vector
481 482 483 484 485
    ParticleAttrib< int >      Bin;   // holds the bin in which the particle is in, if zero particle is marked for deletion
    ParticleAttrib< double >   dt;   // holds the dt timestep for particle

    ParticleAttrib< short >    PType; // we can distinguish dark current particles from primary particle
    ParticleAttrib< int >      TriID; // holds the ID of triangle that the particle hit. Only for BoundaryGeometry case.
486
    ParticleAttrib< short >    cavityGapCrossed; ///< particle just crossed cavity gap (for ParallelCyclotronTracker)
kraus's avatar
kraus committed
487

488 489
    ParticleAttrib< short >    bunchNum; // bunch number to which particle belongs (multi-bunch mode)

kraus's avatar
kraus committed
490

491 492
    Vector_t RefPartR_m;
    Vector_t RefPartP_m;
493
    ParticleType::type refPType_m;
494
    CoordinateSystemTrafo toLabTrafo_m;
kraus's avatar
kraus committed
495

496 497 498 499 500 501
    // The structure for particle binning
    PartBins *pbin_m;

    /// timer for IC, can not be in Distribution.h
    IpplTimings::TimerRef distrReload_m;
    IpplTimings::TimerRef distrCreate_m;
502

503 504 505 506 507
    // For AMTS integrator in OPAL-T
    double dtScInit_m, deltaTau_m;

    /// if a local node has less than 2 particles  lowParticleCount_m == true
    bool lowParticleCount_m;
kraus's avatar
kraus committed
508

509 510 511
    // get 2nd order momentum matrix
    FMatrix<double, 2 * Dim, 2 * Dim> getSigmaMatrix();

512 513 514 515 516 517 518
private:
    // save particles in case of one core
    std::unique_ptr<Inform> pmsg_m;
    std::unique_ptr<std::ofstream> f_stream;
    /// if the grid does not have to adapt
    bool fixed_grid;

frey_m's avatar
frey_m committed
519
protected:
520
    IpplTimings::TimerRef boundpTimer_m;
521 522
    IpplTimings::TimerRef boundpBoundsTimer_m;
    IpplTimings::TimerRef boundpUpdateTimer_m;
523 524 525
    IpplTimings::TimerRef statParamTimer_m;

    IpplTimings::TimerRef histoTimer_m;
526 527
    /// timer for selfField calculation
    IpplTimings::TimerRef selfFieldTimer_m;
kraus's avatar
kraus committed
528 529


530
    const PartData *reference;
kraus's avatar
kraus committed
531 532


533 534 535 536 537 538 539 540 541 542
//     /*
//       Member variables starts here
//     */

    // unit state of PartBunch
    UnitState_t unit_state_;
    UnitState_t stateOfLastBoundP_;

    /// holds the centroid of the beam
    double centroid_m[2 * Dim];
kraus's avatar
kraus committed
543

544 545 546 547 548 549 550 551 552
    /// 6x6 matrix of the moments of the beam
    FMatrix<double, 2 * Dim, 2 * Dim> moments_m;

    /// holds the timestep in seconds
    double dt_m;
    /// holds the actual time of the integration
    double t_m;
    /// mean energy of the bunch (MeV)
    double eKin_m;
553
    /// energy spread of the beam in MeV
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
    double dE_m;
    /// the position along design trajectory
    double spos_m;

    /// Initialize the translation vector and rotation quaternion
    /// here. Cyclotron tracker will reset these values each timestep
    /// TTracker can just use 0 translation and 0 rotation (quat[1 0 0 0]).
    //Vector_t globalMeanR_m = Vector_t(0.0, 0.0, 0.0);
    //Quaternion_t globalToLocalQuaternion_m = Quaternion_t(1.0, 0.0, 0.0, 0.0);
    Vector_t globalMeanR_m;
    Quaternion_t globalToLocalQuaternion_m;

    /// maximal extend of particles
    Vector_t rmax_m;
    /// minimal extend of particles
    Vector_t rmin_m;

    /// rms beam size (m)
    Vector_t rrms_m;
    /// rms momenta
    Vector_t prms_m;
    /// mean position (m)
    Vector_t rmean_m;
    /// mean momenta
    Vector_t pmean_m;

    /// rms emittance (not normalized)
    Vector_t eps_m;

    /// rms normalized emittance
    Vector_t eps_norm_m;
frey_m's avatar
frey_m committed
585

586
    Vector_t halo_m;
frey_m's avatar
frey_m committed
587

588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
    /// rms correlation
    Vector_t rprms_m;

    /// dispersion x & y
    double Dx_m;
    double Dy_m;

    /// derivative of the dispersion
    double DDx_m;
    double DDy_m;

    /// meshspacing of cartesian mesh
    Vector_t hr_m;
    /// meshsize of cartesian mesh
    Vektor<int, 3> nr_m;

    /// stores the used field solver
    FieldSolver *fs_m;

    double couplingConstant_m;

    double qi_m;
kraus's avatar
kraus committed
610

611
    /// counter to store the distribution dump
612
    int distDump_m;
kraus's avatar
kraus committed
613

614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
    ///
    int fieldDBGStep_m;

    /// Mesh enlargement
    double dh_m; /// in % how much the mesh is enlarged

    /// if larger than 0, emitt particles for tEmission_m [s]
    double tEmission_m;

    /// holds the gamma of the bin
    std::unique_ptr<double[]> bingamma_m;

    //FIXME: this should go into the Bin class!
    // holds number of emitted particles of the bin
    // jjyang: opal-cycl use *nBin_m of pbin_m
    std::unique_ptr<size_t[]> binemitted_m;

    /// steps per turn for OPAL-cycl
    int stepsPerTurn_m;

    /// step in a TRACK command
635
    long long localTrackStep_m;
636 637 638 639 640

    /// if multiple TRACK commands
    long long globalTrackStep_m;

    /// current bunch number
frey_m's avatar
frey_m committed
641 642 643 644 645
    short numBunch_m;

    /// number of particles per bunch
    std::vector<size_t> bunchTotalNum_m;
    std::vector<size_t> bunchLocalNum_m;
646 647 648 649 650 651 652 653 654

    /// this parameter records the current steps since last bunch injection
    /// it helps to inject new bunches correctly in the restart run of OPAL-cycl
    /// it is stored during phase space dump.
    int SteptoLastInj_m;

    /*
      Data structure for particle load balance information
    */
kraus's avatar
kraus committed
655

656 657 658 659 660 661 662
    std::unique_ptr<size_t[]> globalPartPerNode_m;


    Distribution *dist_m;

    // flag to tell if we are a DC-beam
    bool dcBeam_m;
663
    double periodLength_m;
frey_m's avatar
frey_m committed
664
    std::shared_ptr<AbstractParticle<T, Dim> > pbase;
665 666 667 668
};

#include "PartBunchBase.hpp"

669
#endif