60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
//
|
|
// tests.cpp
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 17.10.18.
|
|
// Copyright © 2018 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#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");
|
|
}
|
|
|
|
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();
|
|
}
|
|
|