Commit 906807da authored by adelmann's avatar adelmann 🎗
Browse files

new function for calculation of Emean NEEED to check it this is ok

parent 4b7951a9
......@@ -1728,7 +1728,9 @@ void PartBunch::calcBeamParameters() {
reduce(gamma, gamma, OpAddAssign());
gamma /= N;
eKin_m = (gamma - 1.0) * m0;
calcEMean();
// calculate energy spread
dE_m = prms_m(2) * sqrt(eKin_m * (eKin_m + 2.*m0) / (1. + eKin_m * (eKin_m + 2.*m0) / (m0 * m0)));
......@@ -2048,14 +2050,7 @@ void PartBunch::calcBeamParameters_cycl() {
DDy_m = moments_m(5, 3) / TotalNp;
// calculate mean energy
eKin_m = 0.0;
for(unsigned int k = 0; k < locNp; k++)
eKin_m += (sqrt(dot(P[k], P[k]) + 1.0) - 1.0) * getM() * 1e-6;
localeKin = eKin_m / locNp;
// sum energy of all nodes
reduce(eKin_m, eKin_m, OpAddAssign());
eKin_m /= TotalNp;
calcEMean();
double meanLocalBetaGamma = sqrt(pow(1 + localeKin / (getM() * 1.0e-6), 2.0) - 1);
......@@ -2069,6 +2064,20 @@ void PartBunch::calcBeamParameters_cycl() {
}
void PartBunch::calcEMean() {
const double locNp = static_cast<double>(this->getLocalNum());
const double TotalNp = static_cast<double>(this->getTotalNum());
eKin_m = 0.0;
for(unsigned int k = 0; k < locNp; k++)
//eKin_m += (sqrt(dot(P[k], P[k]) + 1.0) - 1.0) * getM() * 1e-6;
eKin_m += (sqrt(P[k](2)*P[k](2) + 1.0) - 1.0) * getM() * 1e-6;
reduce(eKin_m, eKin_m, OpAddAssign());
eKin_m /= TotalNp;
}
size_t PartBunch::boundp_destroyT() {
......
......@@ -517,6 +517,10 @@ private:
double calculateAngle(double x, double y);
double calculateAngle2(double x, double y);
void calcEMean(); // update eKin_m;
/*
Member variables starts here
*/
......
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