Distribution.h 26 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#ifndef OPAL_Distribution_HH
#define OPAL_Distribution_HH

// ------------------------------------------------------------------------
// $RCSfile: Distribution.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Distribution
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:44 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include <iosfwd>
#include <fstream>
22
#include <forward_list>
gsell's avatar
gsell committed
23 24 25
#include <string>
#include <map>

26 27
#include "AbstractObjects/Definition.h"
#include "Algorithms/PartData.h"
28

29
#include "Algorithms/Vektor.h"
30
#include "Beamlines/Beamline.h"
31
#include "Attributes/Attributes.h"
gsell's avatar
gsell committed
32

33 34 35 36 37 38 39 40
#include "Ippl.h"

#include "H5hut.h"

#include <gsl/gsl_rng.h>
#include <gsl/gsl_histogram.h>
#include <gsl/gsl_qrng.h>

41 42 43
#ifdef WITH_UNIT_TESTS
#include <gtest/gtest_prod.h>
#endif
44

45
class Beam;
46 47 48 49 50
class PartBunch;
class PartBins;
class EnvelopeBunch;
class BoundaryGeometry;
class LaserProfile;
51
class H5PartWrapper;
gsell's avatar
gsell committed
52

53 54 55 56 57 58 59 60 61 62
namespace DistrTypeT
{
    enum DistrTypeT {NODIST,
                    FROMFILE,
                    GAUSS,
                    BINOMIAL,
                    FLATTOP,
                    SURFACEEMISSION,
                    SURFACERANDCREATE,
                    GUNGAUSSFLATTOPTH,
63 64
	            ASTRAFLATTOPTH,
		    MATCHEDGAUSS
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                    };
}

namespace EmissionModelT
{
    enum EmissionModelT {NONE,
                         ASTRA,
                         NONEQUIL
                        };
}

namespace InputMomentumUnitsT
{
    enum InputMomentumUnitsT {NONE,
                              EV
                              };
}

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
namespace Attrib
{
    namespace Distribution
    {
        enum AttributesT {
            TYPE,
            FNAME,
            WRITETOFILE,
            WEIGHT,
            INPUTMOUNITS,
            EMITTED,
            EMISSIONSTEPS,
            EMISSIONMODEL,
            EKIN,
            ELASER,
            W,
            FE,
            CATHTEMP,
            NBIN,
            XMULT,
            YMULT,
            ZMULT,
            TMULT,
            PXMULT,
            PYMULT,
            PZMULT,
            OFFSETX,
            OFFSETY,
            OFFSETZ,
            OFFSETT,
            OFFSETPX,
            OFFSETPY,
            OFFSETPZ,
            SIGMAX,
            SIGMAY,
            SIGMAR,
            SIGMAZ,
            SIGMAT,
            TPULSEFWHM,
            TRISE,
            TFALL,
            SIGMAPX,
            SIGMAPY,
            SIGMAPZ,
            MX,
            MY,
            MZ,
            MT,
            CUTOFFX,
            CUTOFFY,
            CUTOFFR,
            CUTOFFLONG,
            CUTOFFPX,
            CUTOFFPY,
            CUTOFFPZ,
            FTOSCAMPLITUDE,
            FTOSCPERIODS,
            R,                          // the correlation matrix (a la transport)
            CORRX,
            CORRY,
            CORRZ,
            CORRT,
            R51,
            R52,
            R61,
            R62,
            LASERPROFFN,
            IMAGENAME,
            INTENSITYCUT,
            FLIPX,
            FLIPY,
            ROTATE90,
            ROTATE180,
            ROTATE270,
            NPDARKCUR,
            INWARDMARGIN,
            EINITHR,
            FNA,
            FNB,
            FNY,
            FNVYZERO,
            FNVYSECOND,
            FNPHIW,
            FNBETA,
            FNFIELDTHR,
            FNMAXEMI,
            SECONDARYFLAG,
            NEMISSIONMODE,
            VSEYZERO,                   // sey_0 in Vaughn's model.
            VEZERO,                     // Energy related to sey_0 in Vaughan's model.
            VSEYMAX,                    // sey max in Vaughan's model.
            VEMAX,                      // Emax in Vaughan's model.
            VKENERGY,                   // Fitting parameter denotes the roughness of
            // surface for impact energy in Vaughn's model.
            VKTHETA,                    // Fitting parameter denotes the roughness of
            // surface for impact angle in Vaughn's model.
            VVTHERMAL,                  // Thermal velocity of Maxwellian distribution
            // of secondaries in Vaughan's model.
            VW,
            SURFMATERIAL,               // Add material type, currently 0 for copper
            // and 1 for stainless steel.
            EX,                         // below is for the matched distribution
            EY,
            ET,
            MAGSYM,                     // number of sector magnets
            LINE,
            FMAPFN,
            FMTYPE,                     // field map type used in matched gauss distribution
            RESIDUUM,
            MAXSTEPSCO,
            MAXSTEPSSI,
            ORDERMAPS,
            E2,
            RGUESS,
            ID1,                       // special particle that the user can set
            ID2,                       // special particle that the user can set
            SCALABLE,
            SIZE
        };
    }

    namespace Legacy
    {
        namespace Distribution
        {
            enum LegacyAttributesT {
                // DESCRIPTION OF THE DISTRIBUTION:
210 211
                DISTRIBUTION = Attrib::Distribution::SIZE,
                DEBIN,
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
                SBIN,
                SIGMAPT,
                CUTOFF,
                T,
                PT,
                // ALPHAX,
                // ALPHAY,
                // BETAX,
                // BETAY,
                // DX,
                // DDX,
                // DY,
                // DDY,
                SIZE
            };
        }
    }
}

231 232 233 234 235
/*
 * Class Distribution
 *
 * Defines the initial beam that is injected or emitted into the simulation.
 */
gsell's avatar
gsell committed
236 237 238 239 240 241 242 243 244

class Distribution: public Definition {

public:

    Distribution();
    virtual ~Distribution();

    virtual bool canReplaceBy(Object *object);
245
    virtual Distribution *clone(const std::string &name);
gsell's avatar
gsell committed
246 247 248
    virtual void execute();
    virtual void update();

249 250
    size_t getNumOfLocalParticlesToCreate(size_t n);

251 252
    void createBoundaryGeometry(PartBunch &p, BoundaryGeometry &bg);
    void createOpalCycl(PartBunch &beam,
253
                        size_t numberOfParticles,
254
			double current, const Beamline &bl,
255
                        bool scan);
256
    void createOpalE(Beam *beam,
257 258 259 260
                     std::vector<Distribution *> addedDistributions,
                     EnvelopeBunch *envelopeBunch,
                     double distCenter,
                     double Bz0);
261
    void createOpalT(PartBunch &beam,
262 263 264
                     std::vector<Distribution *> addedDistributions,
                     size_t &numberOfParticles,
                     bool scan);
265 266 267 268
    void createOpalT(PartBunch &beam, size_t &numberOfParticles, bool scan);
    void createPriPart(PartBunch *beam, BoundaryGeometry &bg);
    void doRestartOpalT(PartBunch &p, size_t Np, int restartStep, H5PartWrapper *h5wrapper);
    void doRestartOpalCycl(PartBunch &p, size_t Np, int restartStep,
269
                        const int specifiedNumBunch, H5PartWrapper *h5wrapper);
270 271 272
    void doRestartOpalE(EnvelopeBunch &p, size_t Np, int restartStep, H5PartWrapper *h5wrapper);
    size_t emitParticles(PartBunch &beam, double eZ);
    double getPercentageEmitted() const;
273
    static Distribution *find(const std::string &name);
gsell's avatar
gsell committed
274

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
    void eraseXDist();
    void eraseBGxDist();
    void eraseYDist();
    void eraseBGyDist();
    void eraseTOrZDist();
    void eraseBGzDist();
    bool getIfDistEmitting();
    int getLastEmittedEnergyBin();
    double getMaxTOrZ();
    double getMinTOrZ();
    size_t getNumberOfEmissionSteps();
    int getNumberOfEnergyBins();
    double getEmissionDeltaT();
    double getEnergyBinDeltaT();
    double getWeight();
    std::vector<double>& getXDist();
    std::vector<double>& getBGxDist();
    std::vector<double>& getYDist();
    std::vector<double>& getBGyDist();
    std::vector<double>& getTOrZDist();
    std::vector<double>& getBGzDist();
gsell's avatar
gsell committed
296

297
    /// Return the embedded CLASSIC PartData.
298 299
    const PartData &getReference() const;
    double getTEmission();
300

kraus's avatar
kraus committed
301
    Vector_t get_pmean() const;
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
    double getEkin() const;
    double getLaserEnergy() const;
    double getWorkFunctionRf() const;

    size_t getNumberOfDarkCurrentParticles();
    double getDarkCurrentParticlesInwardMargin();
    double getEInitThreshold();
    double getWorkFunction();
    double getFieldEnhancement();
    size_t getMaxFNemissionPartPerTri();
    double getFieldFNThreshold();
    double getFNParameterA();
    double getFNParameterB();
    double getFNParameterY();
    double getFNParameterVYZero();
    double getFNParameterVYSecond();
    int    getSecondaryEmissionFlag();
    bool   getEmissionMode() ;

    std::string getTypeofDistribution();

    double getvSeyZero();//return sey_0 in Vaughan's model
    double getvEZero();//return the energy related to sey_0 in Vaughan's model
    double getvSeyMax();//return sey max in Vaughan's model
    double getvEmax();//return Emax in Vaughan's model
    double getvKenergy();//return fitting parameter denotes the roughness of surface for impact energy in Vaughan's model
    double getvKtheta();//return fitting parameter denotes the roughness of surface for impact angle in Vaughan's model
    double getvVThermal();//return thermal velocity of Maxwellian distribution of secondaries in Vaughan's model
    double getVw();//return velocity scalar for parallel plate benchmark;
    int getSurfMaterial();//material type for Furman-Pivi's model 0 for copper, 1 for stainless steel
gsell's avatar
gsell committed
332 333 334

    Inform &printInfo(Inform &os) const;

335
    bool Rebin();
336 337 338 339
    void setDistToEmitted(bool emitted);
    void setDistType();
    void shiftBeam(double &maxTOrZ, double &minTOrZ);
    double getEmissionTimeShift() const;
gsell's avatar
gsell committed
340

341
    // in case if OPAL-cycl in restart mode
342
    double GetBeGa() {return bega_m;}
343
    double GetPr() {return referencePr_m;}
344 345
    double GetPt() {return referencePt_m;}
    double GetPz() {return referencePz_m;}
346 347
    double GetR() {return referenceR_m;}
    double GetTheta() {return referenceTheta_m;}
348
    double GetZ() {return referenceZ_m;}
gsell's avatar
gsell committed
349

350 351 352 353
    double GetPhi() {return phi_m;}
    double GetPsi() {return psi_m;}
    bool GetPreviousH5Local() {return previousH5Local_m;}

354
    void setNumberOfDistributions(unsigned int n) { numberOfDistributions_m = n; }
355 356

    DistrTypeT::DistrTypeT getType() const;
357
private:
358
#ifdef WITH_UNIT_TESTS
359 360
    FRIEND_TEST(GaussTest, FullSigmaTest1);
    FRIEND_TEST(GaussTest, FullSigmaTest2);
361 362
    FRIEND_TEST(BinomialTest, FullSigmaTest1);
    FRIEND_TEST(BinomialTest, FullSigmaTest2);
363
#endif
364

365
    Distribution(const std::string &name, Distribution *parent);
366

gsell's avatar
gsell committed
367 368 369 370
    // Not implemented.
    Distribution(const Distribution &);
    void operator=(const Distribution &);

371
    //    void printSigma(SigmaGenerator<double,unsigned int>::matrix_type& M, Inform& out);
372
    void addDistributions();
373 374
    void applyEmissionModel(double lowEnergyLimit, double &px, double &py, double &pz, std::vector<double> &additionalRNs);
    void applyEmissModelAstra(double &px, double &py, double &pz, std::vector<double> &additionalRNs);
375
    void applyEmissModelNone(double &pz);
376
    void applyEmissModelNonEquil(double eZ, double &px, double &py, double &pz, std::vector<double> &additionalRNs);
377 378 379 380 381 382 383 384 385
    void create(size_t &numberOfParticles, double massIneV);
    void calcPartPerDist(size_t numberOfParticles);
    void checkEmissionParameters();
    void checkIfEmitted();
    void checkParticleNumber(size_t &numberOfParticles);
    void chooseInputMomentumUnits(InputMomentumUnitsT::InputMomentumUnitsT inputMoUnits);
    double convertBetaGammaToeV(double valueInbega, double mass);
    double converteVToBetaGamma(double valueIneV, double massIneV);
    double convertMeVPerCToBetaGamma(double valueInMeVPerC, double massIneV);
kraus's avatar
kraus committed
386
    size_t getNumberOfParticlesInFile(std::ifstream &inputFile);
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414

    class BinomialBehaviorSplitter {
    public:
        virtual ~BinomialBehaviorSplitter()
        { }

        virtual double get(double rand) = 0;
    };

    class MDependentBehavior: public BinomialBehaviorSplitter {
    public:
        MDependentBehavior(const MDependentBehavior &rhs):
            ami_m(rhs.ami_m)
        {}

        MDependentBehavior(double a)
        { ami_m = 1.0 / a; }

        virtual double get(double rand);
    private:
        double ami_m;
    };

    class GaussianLikeBehavior: public BinomialBehaviorSplitter {
    public:
        virtual double get(double rand);
    };

415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
    void createDistributionBinomial(size_t numberOfParticles, double massIneV);
    void createDistributionFlattop(size_t numberOfParticles, double massIneV);
    void createDistributionFromFile(size_t numberOfParticles, double massIneV);
    void createDistributionGauss(size_t numberOfParticles, double massIneV);
    void createMatchedGaussDistribution(size_t numberOfParticles, double massIneV);
    void destroyBeam(PartBunch &beam);
    void fillEBinHistogram();
    void fillParticleBins();
    size_t findEBin(double tOrZ);
    void generateAstraFlattopT(size_t numberOfParticles);
    void generateBinomial(size_t numberOfParticles);
    void generateFlattopLaserProfile(size_t numberOfParticles);
    void generateFlattopT(size_t numberOfParticles);
    void generateFlattopZ(size_t numberOfParticles);
    void generateGaussZ(size_t numberOfParticles);
    void generateLongFlattopT(size_t numberOfParticles);
    void generateTransverseGauss(size_t numberOfParticles);
    void initializeBeam(PartBunch &beam);
    void injectBeam(PartBunch &beam);
    void printDist(Inform &os, size_t numberOfParticles) const;
    void printDistBinomial(Inform &os) const;
    void printDistFlattop(Inform &os) const;
    void printDistFromFile(Inform &os) const;
    void printDistGauss(Inform &os) const;
    void printDistMatchedGauss(Inform &os) const;
    void printDistSurfEmission(Inform &os) const;
    void printDistSurfAndCreate(Inform &os) const;
    void printEmissionModel(Inform &os) const;
    void printEmissionModelAstra(Inform &os) const;
    void printEmissionModelNone(Inform &os) const;
    void printEmissionModelNonEquil(Inform &os) const;
    void printEnergyBins(Inform &os) const;
    void reflectDistribution(size_t &numberOfParticles);
    void scaleDistCoordinates();
    void setAttributes();
    void setDistParametersBinomial(double massIneV);
    void setDistParametersFlattop(double massIneV);
    void setDistParametersGauss(double massIneV);
    void setEmissionTime(double &maxT, double &minT);
    void setFieldEmissionParameters();
    void setupEmissionModel(PartBunch &beam);
    void setupEmissionModelAstra(PartBunch &beam);
    void setupEmissionModelNone(PartBunch &beam);
    void setupEmissionModelNonEquil();
    void setupEnergyBins(double maxTOrZ, double minTOrZ);
    void setupParticleBins(double massIneV, PartBunch &beam);
    void shiftDistCoordinates(double massIneV);
    void writeOutFileHeader();
    void writeOutFileEmission();
    void writeOutFileInjection();
    void writeToFile();
466 467 468 469 470

    std::string distT_m;                 /// Distribution type. Declared as string
    DistrTypeT::DistrTypeT distrTypeT_m; /// and list type for switch statements.
    std::ofstream os_m;                  /// Output file to write distribution.
    void writeToFileCycl(PartBunch &beam, size_t Np);
gsell's avatar
gsell committed
471

472 473
    unsigned int numberOfDistributions_m;

474 475
    bool emitting_m;                     /// Distribution is an emitted, and is currently
                                         /// emitting, rather than an injected, beam.
gsell's avatar
gsell committed
476

477 478 479
    bool scan_m;                         /// If we are doing a scan, we need to
                                         /// destroy existing particles before
                                         /// each run.
gsell's avatar
gsell committed
480

481 482
    PartData particleRefData_m;          /// Reference data for particle type (charge,
                                         /// mass etc.)
gsell's avatar
gsell committed
483

484 485 486
    /// Vector of distributions to be added to this distribution.
    std::vector<Distribution *> addedDistributions_m;
    std::vector<size_t> particlesPerDist_m;
gsell's avatar
gsell committed
487

488 489
    /// Emission Model.
    EmissionModelT::EmissionModelT emissionModel_m;
gsell's avatar
gsell committed
490

491 492 493 494 495 496 497 498 499 500 501 502 503 504
    /// Emission parameters.
    double tEmission_m;
    double tBin_m;
    double currentEmissionTime_m;
    int currentEnergyBin_m;
    int currentSampleBin_m;
    int numberOfEnergyBins_m;       /// Number of energy bins the distribution
                                    /// is broken into. Used for an emitted beam.
    int numberOfSampleBins_m;       /// Number of samples to use per energy bin
                                    /// when emitting beam.
    PartBins *energyBins_m;         /// Distribution energy bins.
    gsl_histogram *energyBinHist_m; /// GSL histogram used to define energy bin
                                    /// structure.

505
    gsl_rng *randGen_m;             /// Random number generator
506 507 508

    // ASTRA and NONE photo emission model.
    double pTotThermal_m;           /// Total thermal momentum.
kraus's avatar
kraus committed
509
    Vector_t pmean_m;
510 511 512 513 514 515 516 517

    // NONEQUIL photo emission model.
    double cathodeWorkFunc_m;       /// Cathode material work function (eV).
    double laserEnergy_m;           /// Laser photon energy (eV).
    double cathodeFermiEnergy_m;    /// Cathode material Fermi energy (eV).
    double cathodeTemp_m;           /// Cathode temperature (K).
    double emitEnergyUpperLimit_m;  /// Upper limit on emission energy distribution (eV).

kraus's avatar
kraus committed
518
    std::vector<std::vector<double> > additionalRNs_m;
519

520 521 522
    size_t totalNumberParticles_m;
    size_t totalNumberEmittedParticles_m;

523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
    // Beam coordinate containers.
    std::vector<double> xDist_m;
    std::vector<double> pxDist_m;
    std::vector<double> yDist_m;
    std::vector<double> pyDist_m;
    std::vector<double> tOrZDist_m;
    std::vector<double> pzDist_m;

    // Initial coordinates for file write.
    std::vector<double> xWrite_m;
    std::vector<double> pxWrite_m;
    std::vector<double> yWrite_m;
    std::vector<double> pyWrite_m;
    std::vector<double> tOrZWrite_m;
    std::vector<double> pzWrite_m;
    std::vector<size_t> binWrite_m;

540
    // for compatibility reasons
541
    double avrgpz_m;
542 543 544



545 546 547 548 549 550 551 552 553 554
    //Distribution parameters.
    InputMomentumUnitsT::InputMomentumUnitsT inputMoUnits_m;
    double sigmaTRise_m;
    double sigmaTFall_m;
    double tPulseLengthFWHM_m;
    Vector_t sigmaR_m;
    Vector_t sigmaP_m;
    Vector_t cutoffR_m;
    Vector_t cutoffP_m;
    Vector_t mBinomial_m;
555
    SymTenzor<double, 6> correlationMatrix_m;
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

    // Laser profile.
    std::string laserProfileFileName_m;
    std::string laserImageName_m;
    double laserIntensityCut_m;
    LaserProfile *laserProfile_m;

    /*
     * Dark current calculation parameters.
     */
    size_t darkCurrentParts_m;      /// Number of dark current particles.
    double darkInwardMargin_m;      /// Dark current particle initialization position.
                                    /// Inward along the triangle normal, positive.
                                    /// Inside the geometry.
    double eInitThreshold_m;        /// Field threshold (MV/m) beyond which particles
                                    /// will be initialized.
    double workFunction_m;          /// Work function of surface material (eV).
    double fieldEnhancement_m;      /// Field enhancement factor beta for Fowler-
                                    /// Nordheim emission.
    double fieldThrFN_m;            /// Field threshold for Fowler-Nordheim
                                    /// emission (MV/m).
    size_t maxFN_m;                 /// Max. number of electrons emitted from a
                                    /// single triangle for Fowler-Nordheim emission.
    double paraFNA_m;               /// Empirical constant A in Fowler-Nordheim
                                    /// emission model.
    double paraFNB_m;               /// Empirical constant B in Fowler-Nordheim
                                    /// emission model.
    double paraFNY_m;               /// Constant for image charge effect parameter y(E)
                                    /// in Fowler-Nordheim emission model.
    double paraFNVYSe_m;            /// Second order constant for v(y) function in
                                    /// Fowler-Nordheim emission model.
    double paraFNVYZe_m;            /// Zero order constant for v(y) function in
                                    /// Fowler-Nordheim emission model.
    int    secondaryFlag_m;         /// Select the secondary model type:
                                    ///     0           ==> no secondary emission.
                                    ///     1           ==> Furman-Pivi
                                    ///     2 or larger ==> Vaughan's model
    double ppVw_m;                  /// Velocity scalar for parallel plate benchmark.
    double vVThermal_m;             /// Thermal velocity of Maxwellian distribution
                                    /// of secondaries in Vaughan's model.


598 599 600 601 602 603 604
    // AAA This is for the matched distribution
    double ex_m;
    double ey_m;
    double et_m;

    double I_m;
    double E_m;
adelmann's avatar
adelmann committed
605 606
    double bg_m;                      /// beta gamma
    double M_m;                       /// mass in terms of proton mass
607 608
    std::string bfieldfn_m;           /// only temporarly

609 610


611 612


613 614
    // Some legacy members that need to be cleaned up.

gsell's avatar
gsell committed
615 616 617 618 619 620 621
    /// time binned distribution with thermal energy
    double tRise_m;
    double tFall_m;
    double sigmaRise_m;
    double sigmaFall_m;
    double cutoff_m;

622
    // Cyclotron stuff
623
    double referencePr_m;
624
    double referencePt_m;
adelmann's avatar
adelmann committed
625
    double referencePz_m;
626 627
    double referenceR_m;
    double referenceTheta_m;
adelmann's avatar
adelmann committed
628
    double referenceZ_m;
629
    double bega_m;
630

631 632 633 634
    // Cyclotron for restart in local mode
    double phi_m;
    double psi_m;
    bool previousH5Local_m;
gsell's avatar
gsell committed
635 636 637 638 639 640
};

inline Inform &operator<<(Inform &os, const Distribution &d) {
    return d.printInfo(os);
}

kraus's avatar
kraus committed
641 642 643 644 645
inline
Vector_t Distribution::get_pmean() const {
    return pmean_m;
}

646 647 648 649 650
inline
DistrTypeT::DistrTypeT Distribution::getType() const {
    return distrTypeT_m;
}

651 652
inline
double Distribution::getPercentageEmitted() const {
653 654 655
    return (double)totalNumberEmittedParticles_m / (double)totalNumberParticles_m;
}

656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801
inline
double Distribution::getEkin() const {
    return Attributes::getReal(itsAttr[Attrib::Distribution::EKIN]);
}

inline
double Distribution::getLaserEnergy() const {
    return Attributes::getReal(itsAttr[Attrib::Distribution::ELASER]);
}

inline
double Distribution::getWorkFunctionRf() const {
    return Attributes::getReal(itsAttr[Attrib::Distribution::W]);
}

inline
size_t Distribution::getNumberOfDarkCurrentParticles() {
    return (size_t) Attributes::getReal(itsAttr[Attrib::Distribution::NPDARKCUR]);
}

inline
double Distribution::getDarkCurrentParticlesInwardMargin() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::INWARDMARGIN]);
}

inline
double Distribution::getEInitThreshold() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::EINITHR]);
}

inline
double Distribution::getWorkFunction() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNPHIW]);
}

inline
double Distribution::getFieldEnhancement() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNBETA]);
}

inline
size_t Distribution::getMaxFNemissionPartPerTri() {
    return (size_t) Attributes::getReal(itsAttr[Attrib::Distribution::FNMAXEMI]);
}

inline
double Distribution::getFieldFNThreshold() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNFIELDTHR]);
}

inline
double Distribution::getFNParameterA() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNA]);
}

inline
double Distribution::getFNParameterB() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNB]);
}

inline
double Distribution::getFNParameterY() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNY]);
}

inline
double Distribution::getFNParameterVYZero() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNVYZERO]);
}

inline
double Distribution::getFNParameterVYSecond() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::FNVYSECOND]);
}

inline
int Distribution::getSecondaryEmissionFlag() {
    return Attributes::getReal(itsAttr[Attrib::Distribution::SECONDARYFLAG]);
}

inline
bool Distribution::getEmissionMode() {
    return Attributes::getBool(itsAttr[Attrib::Distribution::NEMISSIONMODE]);
}

inline
std::string Distribution::getTypeofDistribution() {
    return (std::string) Attributes::getString(itsAttr[Attrib::Distribution::TYPE]);
}

inline
double Distribution::getvSeyZero() {
    // return sey_0 in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VSEYZERO]);
}

inline
double Distribution::getvEZero() {
    // return the energy related to sey_0 in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VEZERO]);
}

inline
double Distribution::getvSeyMax() {
    // return sey max in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VSEYMAX]);
}

inline
double Distribution::getvEmax() {
    // return Emax in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VEMAX]);
}

inline
double Distribution::getvKenergy() {
    // return fitting parameter denotes the roughness of surface for
    // impact energy in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VKENERGY]);
}

inline
double Distribution::getvKtheta() {
    // return fitting parameter denotes the roughness of surface for
    // impact angle in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VKTHETA]);
}

inline
double Distribution::getvVThermal() {
    // thermal velocity of Maxwellian distribution of secondaries in Vaughan's model
    return Attributes::getReal(itsAttr[Attrib::Distribution::VVTHERMAL]);
}

inline
double Distribution::getVw() {
    // velocity scalar for parallel plate benchmark;
    return Attributes::getReal(itsAttr[Attrib::Distribution::VW]);
}

inline
int Distribution::getSurfMaterial() {
    // Surface material number for Furman-Pivi's Model;
    return (int)Attributes::getReal(itsAttr[Attrib::Distribution::SURFMATERIAL]);
}

kraus's avatar
kraus committed
802
#endif // OPAL_Distribution_HH