Commit 66ea7642 authored by albajacas_a's avatar albajacas_a
Browse files

Merge branch '649-inputmounits-is-now-ev-c-instead-of-ev' into 'master'

Resolve "INPUTMOUNITS is now eV/c instead of eV"

See merge request !490
parents bf453fa2 1a22c767
...@@ -47,7 +47,7 @@ namespace Util { ...@@ -47,7 +47,7 @@ namespace Util {
} }
inline inline
double convertMomentumeVToBetaGamma(double p, double mass) { double convertMomentumEVoverCToBetaGamma(double p, double mass) {
return p / mass; return p / mass;
} }
......
...@@ -873,11 +873,17 @@ void Distribution::chooseInputMomentumUnits(InputMomentumUnitsT::InputMomentumUn ...@@ -873,11 +873,17 @@ void Distribution::chooseInputMomentumUnits(InputMomentumUnitsT::InputMomentumUn
std::string inputUnits = Attributes::getString(itsAttr[Attrib::Distribution::INPUTMOUNITS]); std::string inputUnits = Attributes::getString(itsAttr[Attrib::Distribution::INPUTMOUNITS]);
if (inputUnits == "NONE") if (inputUnits == "NONE")
inputMoUnits_m = InputMomentumUnitsT::NONE; inputMoUnits_m = InputMomentumUnitsT::NONE;
else if (inputUnits == "EV") else if (inputUnits == "EVOVERC")
inputMoUnits_m = InputMomentumUnitsT::EV; inputMoUnits_m = InputMomentumUnitsT::EVOVERC;
else if (inputUnits == "") {
*gmsg << "No momentum units were specified, using default units (see manual)." << endl;
inputMoUnits_m = inputMoUnits;
}
else else
inputMoUnits_m = inputMoUnits; throw OpalException("Distribution::chooseInputMomentumUnits",
"Unkown momentum units '" + inputUnits +
"' !\nINPUTMOUNITS should be 'NONE' or 'EVOVERC'. " +
"See manual for more information.");
} }
void Distribution::createDistributionBinomial(size_t numberOfParticles, double massIneV) { void Distribution::createDistributionBinomial(size_t numberOfParticles, double massIneV) {
...@@ -1065,10 +1071,10 @@ void Distribution::createDistributionFromFile(size_t /*numberOfParticles*/, doub ...@@ -1065,10 +1071,10 @@ void Distribution::createDistributionFromFile(size_t /*numberOfParticles*/, doub
if (saveProcessor >= (unsigned)Ippl::getNodes()) if (saveProcessor >= (unsigned)Ippl::getNodes())
saveProcessor = 0; saveProcessor = 0;
if (inputMoUnits_m == InputMomentumUnitsT::EV) { if (inputMoUnits_m == InputMomentumUnitsT::EVOVERC) {
P(0) = Util::convertMomentumeVToBetaGamma(P(0), massIneV); P(0) = Util::convertMomentumEVoverCToBetaGamma(P(0), massIneV);
P(1) = Util::convertMomentumeVToBetaGamma(P(1), massIneV); P(1) = Util::convertMomentumEVoverCToBetaGamma(P(1), massIneV);
P(2) = Util::convertMomentumeVToBetaGamma(P(2), massIneV); P(2) = Util::convertMomentumEVoverCToBetaGamma(P(2), massIneV);
} }
pmean_m += P; pmean_m += P;
...@@ -1356,10 +1362,10 @@ void Distribution::createOpalCycl(PartBunchBase<double, 3> *beam, ...@@ -1356,10 +1362,10 @@ void Distribution::createOpalCycl(PartBunchBase<double, 3> *beam,
setupParticleBins(beam->getM(),beam); setupParticleBins(beam->getM(),beam);
/* /*
* Set what units to use for input momentum units. Default is * Set what units to use for input momentum units. Default in OPAL-cycl
* eV. * is eV/c.
*/ */
chooseInputMomentumUnits(InputMomentumUnitsT::EV); chooseInputMomentumUnits(InputMomentumUnitsT::EVOVERC);
/* /*
* Determine the number of particles for each distribution. For OPAL-cycl * Determine the number of particles for each distribution. For OPAL-cycl
...@@ -1413,8 +1419,8 @@ void Distribution::createOpalT(PartBunchBase<double, 3> *beam, ...@@ -1413,8 +1419,8 @@ void Distribution::createOpalT(PartBunchBase<double, 3> *beam,
// This is PC from BEAM // This is PC from BEAM
double deltaP = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETP]); double deltaP = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETP]);
if (inputMoUnits_m == InputMomentumUnitsT::EV) { if (inputMoUnits_m == InputMomentumUnitsT::EVOVERC) {
deltaP = Util::convertMomentumeVToBetaGamma(deltaP, beam->getM()); deltaP = Util::convertMomentumEVoverCToBetaGamma(deltaP, beam->getM());
} }
avrgpz_m = beam->getP()/beam->getM() + deltaP; avrgpz_m = beam->getP()/beam->getM() + deltaP;
...@@ -1422,7 +1428,7 @@ void Distribution::createOpalT(PartBunchBase<double, 3> *beam, ...@@ -1422,7 +1428,7 @@ void Distribution::createOpalT(PartBunchBase<double, 3> *beam,
totalNumberParticles_m = numberOfParticles; totalNumberParticles_m = numberOfParticles;
/* /*
* Set what units to use for input momentum units. Default is * Set what units to use for input momentum units. Default in OPAL-T is
* unitless (i.e. BetaXGamma, BetaYGamma, BetaZGamma). * unitless (i.e. BetaXGamma, BetaYGamma, BetaZGamma).
*/ */
chooseInputMomentumUnits(InputMomentumUnitsT::NONE); chooseInputMomentumUnits(InputMomentumUnitsT::NONE);
...@@ -3330,7 +3336,7 @@ void Distribution::setAttributes() { ...@@ -3330,7 +3336,7 @@ void Distribution::setAttributes() {
itsAttr[Attrib::Distribution::INPUTMOUNITS] itsAttr[Attrib::Distribution::INPUTMOUNITS]
= Attributes::makeUpperCaseString("INPUTMOUNITS", "Tell OPAL what input units are for momentum." = Attributes::makeUpperCaseString("INPUTMOUNITS", "Tell OPAL what input units are for momentum."
" Currently \"NONE\" or \"EV\".", ""); " Currently \"NONE\" or \"EVOVERC\".", "");
// Attributes for beam emission. // Attributes for beam emission.
itsAttr[Attrib::Distribution::EMITTED] itsAttr[Attrib::Distribution::EMITTED]
...@@ -3643,10 +3649,10 @@ void Distribution::setSigmaP_m(double massIneV) { ...@@ -3643,10 +3649,10 @@ void Distribution::setSigmaP_m(double massIneV) {
} }
// Check what input units we are using for momentum. // Check what input units we are using for momentum.
if (inputMoUnits_m == InputMomentumUnitsT::EV) { if (inputMoUnits_m == InputMomentumUnitsT::EVOVERC) {
sigmaP_m[0] = Util::convertMomentumeVToBetaGamma(sigmaP_m[0], massIneV); sigmaP_m[0] = Util::convertMomentumEVoverCToBetaGamma(sigmaP_m[0], massIneV);
sigmaP_m[1] = Util::convertMomentumeVToBetaGamma(sigmaP_m[1], massIneV); sigmaP_m[1] = Util::convertMomentumEVoverCToBetaGamma(sigmaP_m[1], massIneV);
sigmaP_m[2] = Util::convertMomentumeVToBetaGamma(sigmaP_m[2], massIneV); sigmaP_m[2] = Util::convertMomentumEVoverCToBetaGamma(sigmaP_m[2], massIneV);
} }
} }
...@@ -4139,10 +4145,10 @@ void Distribution::shiftDistCoordinates(double massIneV) { ...@@ -4139,10 +4145,10 @@ void Distribution::shiftDistCoordinates(double massIneV) {
WARNMSG("PT & PZ are obsolete and will be ignored. The moments of the beam is defined with PC" << endl); WARNMSG("PT & PZ are obsolete and will be ignored. The moments of the beam is defined with PC" << endl);
// Check input momentum units. // Check input momentum units.
if (inputMoUnits_m == InputMomentumUnitsT::EV) { if (inputMoUnits_m == InputMomentumUnitsT::EVOVERC) {
deltaPx = Util::convertMomentumeVToBetaGamma(deltaPx, massIneV); deltaPx = Util::convertMomentumEVoverCToBetaGamma(deltaPx, massIneV);
deltaPy = Util::convertMomentumeVToBetaGamma(deltaPy, massIneV); deltaPy = Util::convertMomentumEVoverCToBetaGamma(deltaPy, massIneV);
deltaPz = Util::convertMomentumeVToBetaGamma(deltaPz, massIneV); deltaPz = Util::convertMomentumEVoverCToBetaGamma(deltaPz, massIneV);
} }
size_t endIdx = startIdx + particlesPerDist_m[i]; size_t endIdx = startIdx + particlesPerDist_m[i];
...@@ -4422,9 +4428,9 @@ void Distribution::adjustPhaseSpace(double massIneV) { ...@@ -4422,9 +4428,9 @@ void Distribution::adjustPhaseSpace(double massIneV) {
double deltaPx = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETPX]); double deltaPx = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETPX]);
double deltaPy = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETPY]); double deltaPy = Attributes::getReal(itsAttr[Attrib::Distribution::OFFSETPY]);
// Check input momentum units. // Check input momentum units.
if (inputMoUnits_m == InputMomentumUnitsT::EV) { if (inputMoUnits_m == InputMomentumUnitsT::EVOVERC) {
deltaPx = Util::convertMomentumeVToBetaGamma(deltaPx, massIneV); deltaPx = Util::convertMomentumEVoverCToBetaGamma(deltaPx, massIneV);
deltaPy = Util::convertMomentumeVToBetaGamma(deltaPy, massIneV); deltaPy = Util::convertMomentumEVoverCToBetaGamma(deltaPy, massIneV);
} }
double avrg[6]; double avrg[6];
......
...@@ -73,7 +73,7 @@ namespace EmissionModelT ...@@ -73,7 +73,7 @@ namespace EmissionModelT
namespace InputMomentumUnitsT namespace InputMomentumUnitsT
{ {
enum InputMomentumUnitsT {NONE, enum InputMomentumUnitsT {NONE,
EV EVOVERC
}; };
} }
......
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