updated version
This commit is contained in:
+32
-39
@@ -22,45 +22,24 @@ public:
|
||||
|
||||
Parameter()
|
||||
{
|
||||
configFilePath = "parameters.cat";
|
||||
seed = (int)getVariable("seed");
|
||||
totalParticles = (long int)getVariable("totalParticles");
|
||||
dt = getVariable("dt");
|
||||
magFieldSetValue = getVariable("magFieldSetValue");
|
||||
seed = (int)value("seed");
|
||||
numTotalParticles = (long int)value("numTotalParticles");
|
||||
dt = value("dt");
|
||||
injectionMethod = (int)value("injectionMethod");
|
||||
deltaKinEnergy = value("deltaKinEnergy");
|
||||
MBKinEnergy = value("MBKinEnergy");
|
||||
|
||||
wgtsMagField = value("wgtsMagField");
|
||||
wgtsLength = value("wgtsLength");
|
||||
wgtsDiameter = value("wgtsDiameter");
|
||||
|
||||
|
||||
constPi = value("constPi");
|
||||
constc = value("constc");
|
||||
constme = value("constme");
|
||||
constqe = value("constqe");
|
||||
}
|
||||
|
||||
|
||||
double getVariable(string varName) // Reads Parameter from config file
|
||||
{
|
||||
string varTemp;
|
||||
double valueTemp;
|
||||
ifstream configFile;
|
||||
|
||||
configFile.open (configFilePath);
|
||||
if (!configFile)
|
||||
{
|
||||
cout<< configFilePath <<" not found " <<endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (configFile >> varTemp >> valueTemp)
|
||||
{
|
||||
if (varName.compare(varTemp)==0)
|
||||
{
|
||||
configFile.close();
|
||||
return(valueTemp);
|
||||
}
|
||||
configFile.ignore(numeric_limits<streamsize>::max(), '\n'); // jump to end of line
|
||||
}
|
||||
configFile.close();
|
||||
std::cout<< varName << " not found." <<std::endl;
|
||||
exit(1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
double value(char *str, char* ext = "cat") // Reads Parameter from config file
|
||||
{
|
||||
double temp;
|
||||
@@ -107,14 +86,28 @@ public:
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
protected:
|
||||
string configFilePath;
|
||||
|
||||
//Simulation specs
|
||||
int seed;
|
||||
long int totalParticles;
|
||||
long int numTotalParticles;
|
||||
double dt;
|
||||
double magFieldSetValue;
|
||||
int injectionMethod;
|
||||
double deltaKinEnergy;
|
||||
double MBKinEnergy;
|
||||
|
||||
//KATRIN Specs
|
||||
double wgtsMagField;
|
||||
double wgtsLength;
|
||||
double wgtsDiameter;
|
||||
|
||||
// physical constants
|
||||
double constPi;
|
||||
double constc;
|
||||
double constme;
|
||||
double constqe;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user