Added new test class, reworked some code

Started Implementing Ionization
This commit is contained in:
Christian
2018-11-07 12:11:24 +01:00
parent cf7ac857d2
commit 15851a540a
14 changed files with 559 additions and 222 deletions
+84 -1
View File
@@ -6,4 +6,87 @@
// Copyright © 2018 Christian Reiling. All rights reserved.
//
#include "tests.hpp"
#include "tests.h"
void runTests() {
std::string outputFilePath = "/Users/ChristianReiling/Documents/Masterarbeit/CodeTesting/Data/";
TestSimulation TEST;
TEST.injection (100000, outputFilePath + "injection.dat");
TEST.decaySpectrum(100000, outputFilePath + "decaySpectrum.dat");
TEST.rejectionBetaDecay(100000, outputFilePath + "rejectionBetaDecay.dat");
TEST.maxwellBoltzmann(100000, outputFilePath + "maxwellBoltzmann.dat");
TestParticle TESTPART;
TESTPART.sigmaEla_m2 (0, 20e3, 100000, outputFilePath + "sigmaEla_m2.dat");
TESTPART.randomTheta (18.6e3, 100000, outputFilePath + "randomTheta.dat");
}
void TestSimulation::injection (int numParticles, std::string outputFilePath) {
std::ofstream outFile;
outFile.open (outputFilePath);
for (int i = 0;i<numParticles;i++) {
outFile << inject() <<std::endl;
}
outFile.close();
}
void TestSimulation::decaySpectrum (int numPoints,std::string outputFilePath) {
std::ofstream outFile;
outFile.open (outputFilePath);
double x,y;
for (int i = 0;i<numPoints;i++) {
x = i * Etridecay_eV/(numPoints-1);
y = EnergyDistributionBetaDecay(x);
outFile << x <<";"<<y <<std::endl;
}
outFile.close();
}
void TestSimulation::rejectionBetaDecay(int numDecays, std::string outputFilePath) {
std::ofstream outFile;
outFile.open (outputFilePath);
for (int i = 0;i<numDecays;i++) {
outFile << getBetaDecayEnergyRejection_eV() <<std::endl;
}
outFile.close();
}
void TestSimulation::maxwellBoltzmann(int numDecays, std::string outputFilePath) {
std::ofstream outFile;
outFile.open (outputFilePath);
for (int i = 0;i<numDecays;i++) {
outFile << getEnergyBoltzmann_eV() <<std::endl;
}
outFile.close();
}
void TestParticle::sigmaEla_m2 (double Emin_eV, double Emax_eV, int numpoints, std::string outputFilePath) {
double E_eV,Estep_eV;
Estep_eV = Emax_eV/(numpoints-1);
m_eV = me_eV;
std::ofstream outFile;
outFile.open (outputFilePath);
for (int i = 0;i<numpoints;i++) {
E_eV = i*Estep_eV;
v_ms = calcV_ms(E_eV) , 0 , 0;
outFile << E_eV<<";"<<getSigmaEla_m2() <<std::endl;
}
outFile.close();
}
void TestParticle::randomTheta (double E_eV, int numCalculations, std::string outputFilePath) {
std::ofstream outFile;
m_eV = me_eV;
v_ms = calcV_ms(E_eV) , 0 , 0;
ranlib::Uniform<double> rngUni;
rngUni.seed(2342395328);
outFile.open (outputFilePath);
for (int i = 0;i<numCalculations;i++) {
outFile << getRandomTheta(&rngUni) <<std::endl;
}
outFile.close();
}