PartBunchBase.h 17.5 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 16 17 18 19 20 21 22 23
#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"
#include "Utilities/SwitcherError.h"
#include "Physics/Physics.h"

#include <iosfwd>
#include <vector>

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

frey_m's avatar
frey_m committed
25
class Distribution;
26 27 28

template <class T, int, int> class FMatrix;
template <class T, int> class FVector;
29 30 31 32

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

39
    typedef std::pair<Vector_t, Vector_t> VectorPair_t;
kraus's avatar
kraus committed
40

41
    static const unsigned Dimension = Dim;
kraus's avatar
kraus committed
42

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

45
public:
kraus's avatar
kraus committed
46

47
    PartBunchBase(AbstractParticle<T, Dim>* pb);
kraus's avatar
kraus committed
48

frey_m's avatar
frey_m committed
49
    virtual ~PartBunchBase() { }
kraus's avatar
kraus committed
50

51
    /*
52
     * Bunch common member functions
53
     */
kraus's avatar
kraus committed
54

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

57
    /// Conversion.
frey_m's avatar
frey_m committed
58 59 60
    PartBunchBase(AbstractParticle<T, Dim>* pb,
                  const std::vector<OpalParticle> &,
                  const PartData *ref); //TODO
kraus's avatar
kraus committed
61

62
    PartBunchBase(const PartBunchBase &rhs); //TODO
kraus's avatar
kraus committed
63

64 65
    // 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
66

67
    bool getIfBeamEmitting();
kraus's avatar
kraus committed
68

69
    int getLastEmittedEnergyBin();
kraus's avatar
kraus committed
70

71
    size_t getNumberOfEmissionSteps();
kraus's avatar
kraus committed
72

73
    int getNumberOfEnergyBins();
kraus's avatar
kraus committed
74

75
    void Rebin();
kraus's avatar
kraus committed
76

77
    void setEnergyBins(int numberOfEnergyBins);
kraus's avatar
kraus committed
78

79
    bool weHaveEnergyBins();
kraus's avatar
kraus committed
80

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

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

87 88
    void setDistribution(Distribution *d,
                         std::vector<Distribution *> addedDistributions,
89
                         size_t &np);
kraus's avatar
kraus committed
90

91
    bool isGridFixed();
92

93
    bool hasBinning();
kraus's avatar
kraus committed
94 95


96 97 98
    /*
       Energy bins related functions
     */
kraus's avatar
kraus committed
99

100
    void setTEmission(double t);
kraus's avatar
kraus committed
101

102
    double getTEmission();
kraus's avatar
kraus committed
103

104
    bool doEmission();
kraus's avatar
kraus committed
105

106
    bool weHaveBins() const;
kraus's avatar
kraus committed
107

108
    void setPBins(PartBins *pbin);
kraus's avatar
kraus committed
109

110
    void setPBins(PartBinsCyc *pbin);
kraus's avatar
kraus committed
111

112 113 114 115
    /** \brief Emit particles in the given bin
        i.e. copy the particles from the bin structure into the
        particle container
    */
116
    size_t emitParticles(double eZ);
kraus's avatar
kraus committed
117

118
    void updateNumTotal();
kraus's avatar
kraus committed
119

120
    void rebin();
kraus's avatar
kraus committed
121

122
    int getNumBins();
kraus's avatar
kraus committed
123

124
    int getLastemittedBin();
kraus's avatar
kraus committed
125

126
    /** \brief Compute the gammas of all bins */
127
    void calcGammas();
kraus's avatar
kraus committed
128

129
    void calcGammas_cycl();
kraus's avatar
kraus committed
130

131 132
    /** \brief Get gamma of one bin */
    double getBinGamma(int bin);
kraus's avatar
kraus committed
133

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

137
    /** \brief Set the charge of all other the ones in bin to zero */
138
    void setBinCharge(int bin);
kraus's avatar
kraus committed
139

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

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

146 147
    void setBeamFrequency(double v);

148 149 150
    /*
       Mesh and Field Layout related functions
     */
kraus's avatar
kraus committed
151

152
    virtual void boundp();
kraus's avatar
kraus committed
153

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

frey_m's avatar
frey_m committed
157 158
    /** This is only temporary in order to get the collimator and pepperpot workinh */
    size_t boundp_destroyT();
kraus's avatar
kraus committed
159

frey_m's avatar
frey_m committed
160
    size_t destroyT();
kraus's avatar
kraus committed
161

162 163 164
    /*
       Read out coordinates
     */
kraus's avatar
kraus committed
165

166 167
    virtual double getPx(int i);
    virtual double getPy(int i);
168 169 170
    virtual double getPz(int i);

    virtual double getPx0(int i);
171
    virtual double getPy0(int i);
172 173 174 175 176 177 178 179 180

    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
181

182
    void get_bounds(Vector_t &rmin, Vector_t &rmax);
kraus's avatar
kraus committed
183

184
    void getLocalBounds(Vector_t &rmin, Vector_t &rmax);
kraus's avatar
kraus committed
185

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

188
    std::pair<Vector_t, double> getLocalBoundingSphere();
kraus's avatar
kraus committed
189 190


191 192 193
    /*
       Compatibility function push_back
     */
kraus's avatar
kraus committed
194

195
    void push_back(OpalParticle p);
kraus's avatar
kraus committed
196

197 198
    void set_part(FVector<double, 6> z, int ii);

199
    void set_part(OpalParticle p, int ii);
kraus's avatar
kraus committed
200

201
    OpalParticle get_part(int ii);
kraus's avatar
kraus committed
202

203 204 205 206 207 208
    /// 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
209

210
    void   setdT(double dt);
211 212 213 214
    double getdT() const;

    void   setT(double t);
    double getT() const;
kraus's avatar
kraus committed
215

216 217 218 219 220 221 222
    /**
     * get the spos of the primary beam
     *
     * @param none
     *
     */
    double get_sPos();
kraus's avatar
kraus committed
223

224 225 226
    void set_sPos(double s);

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

228 229 230 231 232 233 234 235 236 237 238 239
    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;
frey_m's avatar
frey_m committed
240
    virtual Vector_t get_hr() const;
241 242 243 244 245 246

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

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

frey_m's avatar
frey_m committed
248
    virtual void set_meshEnlargement(double dh);
249 250 251

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

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

255
    void calcBeamParameters();
kraus's avatar
kraus committed
256

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

259 260
    double getCouplingConstant() const;
    void setCouplingConstant(double c);
kraus's avatar
kraus committed
261

262 263 264 265 266 267 268
    // 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
269

270 271 272 273 274 275 276 277
    /// \brief Need Ek for the Schottky effect calculation (eV)
    double getEkin() const;

    /// Need the work function for the Schottky effect calculation (eV)
    double getWorkFunctionRf() const;

    /// Need the laser energy for the Schottky effect calculation (eV)
    double getLaserEnergy() const;
kraus's avatar
kraus committed
278

279 280 281 282 283
    /// get the total charge per simulation particle
    double getCharge() const;

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

285
    virtual void setSolver(FieldSolver *fs);
kraus's avatar
kraus committed
286

287
    bool hasFieldSolver();
kraus's avatar
kraus committed
288

289
    std::string getFieldSolverType() const;
kraus's avatar
kraus committed
290

291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
    void setLPath(double s);
    double getLPath() const;

    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;

    void setNumBunch(int n);
    int getNumBunch() const;

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

314 315
    void setSteptoLastInj(int n);
    int getSteptoLastInj();
kraus's avatar
kraus committed
316

317 318
    /// calculate average angle of longitudinal direction of bins
    double calcMeanPhi();
kraus's avatar
kraus committed
319

320 321
    /// 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
322

323 324 325 326 327 328 329
    double getQ() const;
    double getM() const;
    double getP() const;
    double getE() const;

    void resetQ(double q);
    void resetM(double m);
kraus's avatar
kraus committed
330

331 332 333 334 335 336
    double getdE();
    double getInitialBeta() const;
    double getInitialGamma() const;
    virtual double getGamma(int i);
    virtual double getBeta(int i);
    virtual void actT();
kraus's avatar
kraus committed
337

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

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

342 343 344 345 346 347
    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
348

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

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

353
    void correctEnergy(double avrgp);
kraus's avatar
kraus committed
354

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

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

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

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

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

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

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

372
    virtual void computeSelfFields() = 0;
373 374

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

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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

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

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

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

439 440 441
    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
442

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

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


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

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

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

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


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


471 472 473 474 475 476 477 478
    // 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

479
    ParticleAttrib< Vector_t > Bf;    // b field vector
480 481 482 483 484
    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.
kraus's avatar
kraus committed
485 486


487 488 489
    Vector_t RefPartR_m;
    Vector_t RefPartP_m;
    CoordinateSystemTrafo toLabTrafo_m;
kraus's avatar
kraus committed
490 491


492 493 494 495 496 497
    /// avoid calls to Ippl::myNode()
    int myNode_m;

    /// avoid calls to Ippl::getNodes()
    int nodes_m;

498
    /// if the grid does not have to adapt
499 500 501 502 503 504 505 506 507 508
    bool fixed_grid;

    // The structure for particle binning
    PartBins *pbin_m;

    std::unique_ptr<LossDataSink> lossDs_m;

    // save particles in case of one core
    std::unique_ptr<Inform> pmsg_m;
    std::unique_ptr<std::ofstream> f_stream;
kraus's avatar
kraus committed
509

510 511 512
    /// timer for IC, can not be in Distribution.h
    IpplTimings::TimerRef distrReload_m;
    IpplTimings::TimerRef distrCreate_m;
513

514 515 516 517 518
    // 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
519

520 521
    /// timer for selfField calculation
    IpplTimings::TimerRef selfFieldTimer_m;
kraus's avatar
kraus committed
522

523 524 525
    // get 2nd order momentum matrix
    FMatrix<double, 2 * Dim, 2 * Dim> getSigmaMatrix();

frey_m's avatar
frey_m committed
526
protected:
527
    IpplTimings::TimerRef boundpTimer_m;
528 529
    IpplTimings::TimerRef boundpBoundsTimer_m;
    IpplTimings::TimerRef boundpUpdateTimer_m;
530 531 532
    IpplTimings::TimerRef statParamTimer_m;

    IpplTimings::TimerRef histoTimer_m;
kraus's avatar
kraus committed
533 534


535
    const PartData *reference;
kraus's avatar
kraus committed
536 537


538 539 540 541 542 543 544 545 546 547
//     /*
//       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
548

549 550 551 552 553 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 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
    /// 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;
    /// energy spread of the beam in keV
    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;

    /// for coordinate transformation to Ks
    /// Ks is the coordinate system to calculate statistics
    Quaternion_t QKs3D_m;
    /// holds the referernce particle
    Vector_t     Ks3DRefr_m;
    Vector_t     Ks3DRefp_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;
    /// 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
619

620 621
    /// counter to store the distributin dump
    int distDump_m;
kraus's avatar
kraus committed
622

623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
    ///
    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;

    /// path length from the start point
    double lPath_m;

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

    /// step in a TRACK command
647
    long long localTrackStep_m;
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662

    /// if multiple TRACK commands
    long long globalTrackStep_m;

    /// current bunch number
    int numBunch_m;

    /// 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
663

664 665 666 667 668 669 670
    std::unique_ptr<size_t[]> globalPartPerNode_m;


    Distribution *dist_m;

    // flag to tell if we are a DC-beam
    bool dcBeam_m;
671
    double periodLength_m;
frey_m's avatar
frey_m committed
672
    std::shared_ptr<AbstractParticle<T, Dim> > pbase;
673 674 675 676
};

#include "PartBunchBase.hpp"

677
#endif