Commit ddc42579 authored by kraus's avatar kraus
Browse files

getting correct momentum when emitting

parent 05579314
......@@ -2959,3 +2959,7 @@ bool PartBunch::WeHaveEnergyBins() {
else
return false;
}
Vector_t PartBunch::get_pmean_Distribution() const {
return dist_m->get_pmean();
}
......@@ -324,6 +324,7 @@ public:
Vector_t get_prms() const;
Vector_t get_rprrms() const;
Vector_t get_pmean() const;
Vector_t get_pmean_Distribution() const;
Vector_t get_emit() const;
Vector_t get_norm_emit() const;
Vector_t get_hr() const;
......@@ -1148,7 +1149,7 @@ size_t PartBunch::getLoadBalance(int p) const {
return globalPartPerNode_m[p];
}
inline
inline
size_t PartBunch::getMinLocalNum() {
/// Get the minimal number of particles per node
if (minLocNum_m < 0)
......
......@@ -894,13 +894,15 @@ void ParallelTTracker::doAutoPhasing() {
Vector_t stashedP = itsBunch->get_pmean();
Vector_t initialR(0.0);
// TODO: get correct thermal energy of particles for Astra model
Vector_t initialP(0.0, 0.0, std::max(stashedP(2), 1e-6));
Vector_t initialP(0.0, 0.0, stashedP(2));
if (itsBunch->getTotalNum() > 0) { // we are not emiting otherwise there wouldn't be any particles yet
if (itsBunch->getTotalNum() > 0) { // not emiting
Vector_t stashedR = itsBunch->get_rmean();
initialR(2) = stashedR(2);
} else {
initialP(2) = itsBunch->get_pmean_Distribution()(2);
}
initialP(2) = std::max(initialP(2), 1e-6);
itsBunch->stash();
double zStop = itsOpalBeamline_m.calcBeamlineLenght();
......
......@@ -228,6 +228,7 @@ Distribution::Distribution():
energyBinHist_m(NULL),
randGenEmit_m(NULL),
pTotThermal_m(0.0),
pmean_m(0.0),
cathodeWorkFunc_m(0.0),
laserEnergy_m(0.0),
cathodeFermiEnergy_m(0.0),
......@@ -306,6 +307,7 @@ Distribution::Distribution(const std::string &name, Distribution *parent):
energyBinHist_m(NULL),
randGenEmit_m(parent->randGenEmit_m),
pTotThermal_m(parent->pTotThermal_m),
pmean_m(parent->pmean_m),
cathodeWorkFunc_m(parent->cathodeWorkFunc_m),
laserEnergy_m(parent->laserEnergy_m),
cathodeFermiEnergy_m(parent->cathodeFermiEnergy_m),
......@@ -4590,13 +4592,14 @@ void Distribution::SetupEmissionModelAstra(PartBunch &beam) {
gsl_rng_env_setup();
randGenEmit_m = gsl_rng_alloc(gsl_rng_default);
pmean_m = Vector_t(0.0, 0.0, 0.5 * pTotThermal_m);
}
void Distribution::SetupEmissionModelNone(PartBunch &beam) {
double wThermal = std::abs(Attributes::getReal(itsAttr[AttributesT::EKIN]));
pTotThermal_m = ConverteVToBetaGamma(wThermal, beam.getM());
pmean_m = Vector_t(0.0, 0.0, pTotThermal_m);
}
void Distribution::SetupEmissionModelNonEquil() {
......@@ -4615,6 +4618,9 @@ void Distribution::SetupEmissionModelNonEquil() {
gsl_rng_env_setup();
randGenEmit_m = gsl_rng_alloc(gsl_rng_default);
// TODO: get better estimate of pmean
pmean_m = 0.5 * (cathodeWorkFunc_m + emitEnergyUpperLimit_m);
}
void Distribution::SetupEnergyBins(double maxTOrZ, double minTOrZ) {
......@@ -4960,4 +4966,4 @@ void Distribution::WriteOutFileInjection() {
reduce(numberOfParticles, numberOfParticles, OpAddAssign());
}
}
}
\ No newline at end of file
}
......@@ -145,6 +145,7 @@ public:
const PartData &GetReference() const;
double GetTEmission();
Vector_t get_pmean() const;
double GetEkin() const;
double GetLaserEnergy() const;
double GetWorkFunctionRf() const;
......@@ -321,6 +322,7 @@ private:
// ASTRA and NONE photo emission model.
double pTotThermal_m; /// Total thermal momentum.
Vector_t pmean_m;
// NONEQUIL photo emission model.
double cathodeWorkFunc_m; /// Cathode material work function (eV).
......@@ -449,4 +451,9 @@ inline Inform &operator<<(Inform &os, const Distribution &d) {
return d.printInfo(os);
}
#endif // OPAL_Distribution_HH
\ No newline at end of file
inline
Vector_t Distribution::get_pmean() const {
return pmean_m;
}
#endif // OPAL_Distribution_HH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment