Commit 40bb5ecd authored by snuverink_j's avatar snuverink_j
Browse files

clean Distribution class from unused members/methods

parent f5a27b63
......@@ -46,6 +46,7 @@
#include <gsl/gsl_sf_erf.h>
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_qrng.h>
#include <sys/time.h>
......@@ -122,11 +123,7 @@ Distribution::Distribution():
ppVw_m(0.0),
vVThermal_m(0.0),
I_m(0.0),
E_m(0.0),
M_m(0.0),
referencePz_m(0.0),
referenceZ_m(0.0),
bega_m(0.0)
E_m(0.0)
{
setAttributes();
......@@ -223,13 +220,11 @@ Distribution::Distribution(const std::string &name, Distribution *parent):
vVThermal_m(parent->vVThermal_m),
I_m(parent->I_m),
E_m(parent->E_m),
M_m(parent->M_m),
tRise_m(parent->tRise_m),
tFall_m(parent->tFall_m),
sigmaRise_m(parent->sigmaRise_m),
sigmaFall_m(parent->sigmaFall_m),
cutoff_m(parent->cutoff_m),
bega_m(parent->bega_m)
cutoff_m(parent->cutoff_m)
{
gsl_rng_env_setup();
randGen_m = gsl_rng_alloc(gsl_rng_default);
......@@ -237,30 +232,12 @@ Distribution::Distribution(const std::string &name, Distribution *parent):
Distribution::~Distribution() {
if ((Ippl::getNodes() == 1) && (os_m.is_open()))
os_m.close();
if (energyBins_m != NULL) {
delete energyBins_m;
energyBins_m = NULL;
}
if (energyBinHist_m != NULL) {
gsl_histogram_free(energyBinHist_m);
energyBinHist_m = NULL;
}
if (randGen_m != NULL) {
gsl_rng_free(randGen_m);
randGen_m = NULL;
}
if (laserProfile_m) {
delete laserProfile_m;
laserProfile_m = NULL;
}
delete energyBins_m;
gsl_histogram_free(energyBinHist_m);
gsl_rng_free(randGen_m);
delete laserProfile_m;
}
/*
void Distribution::printSigma(SigmaGenerator<double,unsigned int>::matrix_type& M, Inform& out) {
for (int i=0; i<M.size1(); ++i) {
......@@ -293,34 +270,6 @@ size_t Distribution::getNumOfLocalParticlesToCreate(size_t n) {
return locNumber;
}
/**
* At the moment only write the header into the file dist.dat
* PartBunch will then append (very ugly)
* @param
* @param
* @param
*/
void Distribution::writeToFile() {
/*
if (Ippl::getNodes() == 1) {
if (os_m.is_open()) {
;
} else {
*gmsg << " Write distribution to file data/dist.dat" << endl;
std::string file("data/dist.dat");
os_m.open(file.c_str());
if (os_m.bad()) {
*gmsg << "Unable to open output file " << file << endl;
}
os_m << "# x y ti px py pz " << std::endl;
os_m.close();
}
}
*/
}
/// Distribution can only be replaced by another distribution.
bool Distribution::canReplaceBy(Object *object) {
return dynamic_cast<Distribution *>(object) != 0;
......@@ -1091,14 +1040,6 @@ void Distribution::chooseInputMomentumUnits(InputMomentumUnitsT::InputMomentumUn
}
double Distribution::convertBetaGammaToeV(double valueInBetaGamma, double massIneV) {
double value = std::copysign(sqrt(pow(valueInBetaGamma, 2.0) + 1.0) - 1.0, valueInBetaGamma);
if (std::abs(value) < std::numeric_limits<double>::epsilon())
value = std::copysign(1.0 + 0.5 * pow(valueInBetaGamma, 2.0), valueInBetaGamma);
return value * massIneV;
}
double Distribution::converteVToBetaGamma(double valueIneV, double massIneV) {
double value = std::copysign(sqrt(pow(std::abs(valueIneV) / massIneV + 1.0, 2.0) - 1.0), valueIneV);
if (std::abs(value) < std::numeric_limits<double>::epsilon())
......@@ -1107,10 +1048,6 @@ double Distribution::converteVToBetaGamma(double valueIneV, double massIneV) {
return value;
}
double Distribution::convertMeVPerCToBetaGamma(double valueInMeVPerC, double massIneV) {
return sqrt(pow(valueInMeVPerC * 1.0e6 * Physics::c / massIneV + 1.0, 2.0) - 1.0);
}
void Distribution::createDistributionBinomial(size_t numberOfParticles, double massIneV) {
setDistParametersBinomial(massIneV);
......@@ -1466,15 +1403,13 @@ void Distribution::createMatchedGaussDistribution(size_t numberOfParticles, doub
else {
*gmsg << "* Not converged for " << E_m*1E-6 << " MeV" << endl;
if (siggen)
delete siggen;
delete siggen;
throw OpalException("Distribution::CreateMatchedGaussDistribution",
"didn't find any matched distribution.");
}
if (siggen)
delete siggen;
delete siggen;
}
void Distribution::createDistributionGauss(size_t numberOfParticles, double massIneV) {
......@@ -1540,7 +1475,6 @@ void Distribution::createOpalCycl(PartBunch &beam,
E_m = (beam.getInitialGamma()-1.0)*beam.getM();
I_m = current;
bega_m = beam.getInitialGamma()*beam.getInitialBeta();
/*
* When scan mode is true, we need to destroy particles except
......@@ -4417,8 +4351,7 @@ void Distribution::setupParticleBins(double massIneV, PartBunch &beam) {
= static_cast<int>(std::abs(Attributes::getReal(itsAttr[Attrib::Distribution::NBIN])));
if (numberOfEnergyBins_m > 0) {
if (energyBins_m)
delete energyBins_m;
delete energyBins_m;
int sampleBins = static_cast<int>(std::abs(Attributes::getReal(itsAttr[Attrib::Legacy::Distribution::SBIN])));
energyBins_m = new PartBins(numberOfEnergyBins_m, sampleBins);
......
......@@ -19,9 +19,7 @@
// ------------------------------------------------------------------------
#include <iosfwd>
#include <fstream>
#include <forward_list>
#include <string>
#include <map>
#include "AbstractObjects/Definition.h"
#include "Algorithms/PartData.h"
......@@ -36,7 +34,6 @@
#include <gsl/gsl_rng.h>
#include <gsl/gsl_histogram.h>
#include <gsl/gsl_qrng.h>
#ifdef WITH_UNIT_TESTS
#include <gtest/gtest_prod.h>
......@@ -338,17 +335,6 @@ public:
void shiftBeam(double &maxTOrZ, double &minTOrZ);
double getEmissionTimeShift() const;
// in case if OPAL-cycl in restart mode
double GetBeGa() {return bega_m;}
double GetPr() {return referencePr_m;}
double GetPt() {return referencePt_m;}
double GetPz() {return referencePz_m;}
double GetR() {return referenceR_m;}
double GetTheta() {return referenceTheta_m;}
double GetZ() {return referenceZ_m;}
double GetPhi() {return phi_m;}
double GetPsi() {return psi_m;}
bool GetPreviousH5Local() {return previousH5Local_m;}
void setNumberOfDistributions(unsigned int n) { numberOfDistributions_m = n; }
......@@ -365,8 +351,8 @@ private:
Distribution(const std::string &name, Distribution *parent);
// Not implemented.
Distribution(const Distribution &);
void operator=(const Distribution &);
Distribution(const Distribution &) = delete;
void operator=(const Distribution &) = delete;
// void printSigma(SigmaGenerator<double,unsigned int>::matrix_type& M, Inform& out);
void addDistributions();
......@@ -380,9 +366,7 @@ private:
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);
size_t getNumberOfParticlesInFile(std::ifstream &inputFile);
class BinomialBehaviorSplitter {
......@@ -462,12 +446,9 @@ private:
void writeOutFileHeader();
void writeOutFileEmission();
void writeOutFileInjection();
void writeToFile();
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);
unsigned int numberOfDistributions_m;
......@@ -596,21 +577,8 @@ private:
// AAA This is for the matched distribution
double ex_m;
double ey_m;
double et_m;
double I_m;
double E_m;
double bg_m; /// beta gamma
double M_m; /// mass in terms of proton mass
std::string bfieldfn_m; /// only temporarly
// Some legacy members that need to be cleaned up.
/// time binned distribution with thermal energy
double tRise_m;
......@@ -619,18 +587,7 @@ private:
double sigmaFall_m;
double cutoff_m;
// Cyclotron stuff
double referencePr_m;
double referencePt_m;
double referencePz_m;
double referenceR_m;
double referenceTheta_m;
double referenceZ_m;
double bega_m;
// Cyclotron for restart in local mode
double phi_m;
double psi_m;
bool previousH5Local_m;
};
......
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