Working change, before making some adjustments in classes, structure.

This commit is contained in:
Christian
2019-01-15 09:49:36 +01:00
parent ae5546a3ed
commit 0534f00fbd
12 changed files with 451 additions and 168 deletions
+65
View File
@@ -14,6 +14,9 @@ void runTests() {
TEST.decaySpectrum(100000, outputFilePath + "decaySpectrum.dat");
TEST.rejectionBetaDecay(100000, outputFilePath + "rejectionBetaDecay.dat");
TEST.maxwellBoltzmann(100000, outputFilePath + "maxwellBoltzmann.dat");
TEST.SigmaTot_m2(10000, outputFilePath + "sigmaTot_m2.dat", -3, 9);
TEST.MFP_m(10000, outputFilePath + "MFP_m.dat", -3, 9);
}
void TestSimulation::injection (int numParticles, string outputFilePath) {
@@ -57,3 +60,65 @@ void TestSimulation::maxwellBoltzmann(int numDecays, string outputFilePath) {
outFile.close();
}
void TestSimulation::SigmaTot_m2(int numPointsPerPower, string outputFilePath, int EminPower, int EmaxPower) {
if (EminPower >= EmaxPower) {
cerr<<"TestSimulation::getMFP_m: Power of lower energy bound \">=\" upper energy bound."<<endl;
exit(1);
}
ofstream outFile;
outFile.open (outputFilePath.c_str());
Particle P1 = Particle(me_eV, 1, zeroVec(), electron);
Particle P2 = Particle(mT2_eV, ZT2, zeroVec(), tritium2);
Interaction Inter = Interaction(&P1, &P2);
double distance = 1./double(numPointsPerPower);
int numPoints = (EmaxPower - EminPower) * numPointsPerPower;
double power;
double energy_eV, sigma_m2;
blitz::TinyVector<double,3> speed;
for (int i=0;i<=numPoints;i++) {
power = EminPower + i*distance;
energy_eV = pow(10,power);
speed = 0,0, calcV_msFromEkin_eV(energy_eV, me_eV);
P2.setSpeed_ms(speed);
sigma_m2 = Inter.getSigmaTot_m2();
outFile<<energy_eV<<";"<<sigma_m2<<endl;
}
outFile.close();
}
void TestSimulation::MFP_m(int numPointsPerPower, string outputFilePath, int EminPower, int EmaxPower) {
if (EminPower >= EmaxPower) {
cerr<<"TestSimulation::getMFP_m: Power of lower energy bound \">=\" upper energy bound."<<endl;
exit(1);
}
ofstream outFile;
outFile.open (outputFilePath.c_str());
Particle P1 = Particle(me_eV, 1, zeroVec(), electron);
Particle P2 = Particle(mT2_eV, ZT2, zeroVec(), tritium2);
Interaction Inter = Interaction(&P1, &P2);
double distance = 1./double(numPointsPerPower);
int numPoints = (EmaxPower - EminPower) * numPointsPerPower;
double power;
double energy_eV, MFP_m;
blitz::TinyVector<double,3> speed;
for (int i=0;i<=numPoints;i++) {
power = EminPower + i*distance;
energy_eV = pow(10,power);
speed = 0,0, calcV_msFromEkin_eV(energy_eV, me_eV);
P2.setSpeed_ms(speed);
MFP_m = getMFP_m(Inter);
outFile<<energy_eV<<";"<<MFP_m<<endl;
}
outFile.close();
}