diff --git a/docs/masters/creiling/LateX/thesis.bib b/docs/masters/creiling/LateX/thesis.bib index 74ced08..4833fa1 100644 --- a/docs/masters/creiling/LateX/thesis.bib +++ b/docs/masters/creiling/LateX/thesis.bib @@ -2,13 +2,41 @@ %% http://bibdesk.sourceforge.net/ -%% Created for Christian Reiling at 2018-09-18 10:29:48 +0200 +%% Created for Christian Reiling at 2018-09-25 14:08:44 +0200 %% Saved with string encoding Unicode (UTF-8) +@article{0031-9155-38-12-010, + Abstract = {Electron cross-sections were summarized for an accurate simulation of the track structure of high energy electrons up to a few MeV in water vapour. Elastic scattering was described by the Rutherford formula taking the screening effect into account. Partial and total ionization cross-sections were calculated using Seltzer's formula based on the Weizsacker-Williams method. The total excitation cross-section was evaluated by a so-called Fano plot with parameters given by Berger and Wang. The validity of the cross-sections was examined by comparison with experimental and calculated data. Use of these cross-sections enabled the development of a Monte Carlo track structure code KURBUC encompassing the energy range between 10 eV and 10 MeV. Finally the tracks generated by KURBUC were compared with those generated by MOCA8B in terms of radial distributions of interactions, point kernel and frequencies of energy deposition in small cylindrical targets pertaining to biological macromolecules such as DNA.}, + Author = {S Uehara and H Nikjoo and D T Goodhead}, + Date-Added = {2018-09-25 14:08:38 +0200}, + Date-Modified = {2018-09-25 14:08:38 +0200}, + Journal = {Physics in Medicine & Biology}, + Number = {12}, + Pages = {1841}, + Title = {Cross-sections for water vapour for the Monte Carlo electron track structure code from 10 eV to the MeV region}, + Url = {http://stacks.iop.org/0031-9155/38/i=12/a=010}, + Volume = {38}, + Year = {1993}, + Bdsk-Url-1 = {http://stacks.iop.org/0031-9155/38/i=12/a=010}} + +@article{1742-6596-888-1-012071, + Abstract = {The Karlsruhe Tritium Neutrino Experiment (KATRIN) will perform a direct, kinematics-based measurement of the neutrino mass with a sensitivity of 200 meV (90 % C. L.), which will be reached after 3 years of measurement time. The neutrino mass is obtained by investigating the shape of the energy spectrum of tritium β-decay electrons close to the endpoint at 18.6 keV with a spectrometer of MAC-E filter type. This contribution reviews the current status of the tritium source cryostat and magnet system which is currently in its first cool-down phase. Furthermore, the next steps of the comprehensive pre-tritium measurement programme to characterise the apparatus and investigate important systematics are outlined. This work is supported by BMBF (05A14VK2) and the Helmholtz Association.}, + Author = {Florian Heizmann and Hendrik Seitz-Moskaliuk and KATRIN collaboration}, + Date-Added = {2018-09-25 14:07:20 +0200}, + Date-Modified = {2018-09-25 14:07:20 +0200}, + Journal = {Journal of Physics: Conference Series}, + Number = {1}, + Pages = {012071}, + Title = {The Windowless Gaseous Tritium Source (WGTS) of the KATRIN experiment}, + Url = {http://stacks.iop.org/1742-6596/888/i=1/a=012071}, + Volume = {888}, + Year = {2017}, + Bdsk-Url-1 = {http://stacks.iop.org/1742-6596/888/i=1/a=012071}} + @inbook{Plante_MCSIRT, Author = {Plante, Ianik and Cucinotta, Francis}, Booktitle = {Application of Monte Carlo Methods in Biology, Medicine and Other Fields of Science}, diff --git a/src/mc_electron/energyhisto.cpp b/src/mc_electron/energyhisto.cpp index b7830f0..b86b1a3 100644 --- a/src/mc_electron/energyhisto.cpp +++ b/src/mc_electron/energyhisto.cpp @@ -9,33 +9,28 @@ #include "energyhisto.h" -void Energyhisto::addContent(double z1, double z2, double Energy) { - int zLowBin = std::min(getZBin(z1),getZBin(z2)); - int zUpBin = std::max(getZBin(z1),getZBin(z2)); - int EBin = getEBin(Energy); +void Energyhisto::addContent(double z1_m, double z2_m, double Energy_eV) { + int zLowBin = std::min(getZBin(z1_m),getZBin(z2_m)); + int zUpBin = std::max(getZBin(z1_m),getZBin(z2_m)); + int EBin = getEBin(Energy_eV); data(blitz::Range(zLowBin,zUpBin),EBin) += 1; } -int Energyhisto::getZBin(double z) { - if (z<0 || z>wgtsLength) { - std::cerr<<"Energyhisto::getZBin: z = "<wgtsLength_m) { + std::cerr<<"Energyhisto::getZBin: z = "< maxEBin) { + } else if (E_eV > maxEBin) { return(numberEBins + 1); } else { - return(floor((E-minEBin)/EBinWidth)); + return(floor((E_eV-minEBin)/EBinWidth)); } } - - - - - diff --git a/src/mc_electron/energyhisto.h b/src/mc_electron/energyhisto.h index 7ac0c69..293e4d0 100644 --- a/src/mc_electron/energyhisto.h +++ b/src/mc_electron/energyhisto.h @@ -27,31 +27,31 @@ public: data.resize(numberZBins,numberEBins+2); // Under and Overflow Bins data = 0; - ZBinWidth = wgtsLength/numberZBins; + ZBinWidth = wgtsLength_m/numberZBins; EBinWidth = (maxEBin-minEBin)/numberEBins; - ZBinBoarders.resize(numberZBins+1); + ZBinBoarders_m.resize(numberZBins+1); for (int i=0;i ZBinBoarders, EBinBoarders; + blitz::Array ZBinBoarders_m, EBinBoarders_eV; blitz::Array data; }; diff --git a/src/mc_electron/katrin.cpp b/src/mc_electron/katrin.cpp index 450667d..556570e 100644 --- a/src/mc_electron/katrin.cpp +++ b/src/mc_electron/katrin.cpp @@ -9,19 +9,21 @@ #include "katrin.h" -blitz::TinyVector Katrin::getMagField(blitz::TinyVector position) { - blitz::TinyVector tmp(0.,0.,wgtsMagField); - return (tmp); + + +blitz::TinyVector Katrin::getMagField(blitz::TinyVector loc_m) { + blitz::TinyVector MagField_T; + MagField_T = 0,0,wgtsMagField_T; + return(MagField_T); } -blitz::TinyVector Katrin::getElField(blitz::TinyVector position) { - blitz::TinyVector tmp(0.,0.,0.); - return (tmp); +blitz::TinyVector Katrin::getElField(blitz::TinyVector loc_m) { + blitz::TinyVector ElField_Vm; + ElField_Vm = 0,0,0; + return (ElField_Vm); } -double Katrin::tritiumDensity(blitz::TinyVector position) { - return(0); +double Katrin::getTritiumDensity(blitz::TinyVector loc_m) { + return(wgtsTritiumDensity_m3); } - - diff --git a/src/mc_electron/katrin.h b/src/mc_electron/katrin.h index 11a6c0d..eb0a278 100644 --- a/src/mc_electron/katrin.h +++ b/src/mc_electron/katrin.h @@ -25,10 +25,10 @@ public: Katrin(){}; virtual ~Katrin(){}; - blitz::TinyVector getMagField(blitz::TinyVector); - blitz::TinyVector getElField(blitz::TinyVector); - double tritiumDensity(blitz::TinyVector); + + blitz::TinyVector getMagField(blitz::TinyVector loc_m); + blitz::TinyVector getElField(blitz::TinyVector loc_m); + double getTritiumDensity(blitz::TinyVector loc_m); }; - #endif diff --git a/src/mc_electron/main.cpp b/src/mc_electron/main.cpp index f09880a..c41bcc7 100644 --- a/src/mc_electron/main.cpp +++ b/src/mc_electron/main.cpp @@ -6,11 +6,10 @@ // Copyright © 2018 Christian Reiling. All rights reserved. // - #include "simulation.h" int main(int argc, const char * argv[]) { - Simulation SIM; - SIM.init(); - SIM.doit(); + Simulation Sim; + Sim.init(); + Sim.doit(); } diff --git a/src/mc_electron/parameter.h b/src/mc_electron/parameter.h index 899b1a5..20f44b6 100644 --- a/src/mc_electron/parameter.h +++ b/src/mc_electron/parameter.h @@ -16,32 +16,33 @@ class Parameter { public: - virtual ~Parameter(){}; Parameter() { + // Simulation Specs seed = (int)value("seed"); numTotalParticles = (long int)value("numTotalParticles"); - dt = value("dt"); + dt_s = value("dt_s"); injectionMethod = (int)value("injectionMethod"); - deltaKinEnergy = value("deltaKinEnergy"); - MBKinEnergy = value("MBKinEnergy"); - numberZBins = (int)value ("numberZBins"); - minEBin = value ("minEBin"); - maxEBin = value ("maxEBin"); - numberEBins = (int)value ("numberEBins"); + deltaKinEnergy_eV = value("deltaKinEnergy_eV"); + MBKinEnergy_eV = value("MBKinEnergy_eV"); - wgtsMagField = value("wgtsMagField"); - wgtsLength = value("wgtsLength"); - wgtsDiameter = value("wgtsDiameter"); - - - constPi = value("constPi"); - constc = value("constc"); - constme = value("constme"); - constqe = value("constqe"); + // Katrin Specs + wgtsMagField_T = value("wgtsMagField_T"); + wgtsLength_m = value("wgtsLength_m"); + wgtsRadius_m = value("wgtsRadius_m"); + wgtsTritiumDensity_m3 = value("wgtsTritiumDensity_m3"); } + // Natural Constants + const double pi = 3.1415; + const double c_nat = 1.; + const double c_ms = 299792458; + const double me_eV = 0.511e6; + const double qe_e = 1; + const double re_m = 2.817940322719e-15; + +private: double value(std::string strin, char* ext = (char*)("cat")) { char* str = strdup(strin.c_str()); double temp; @@ -90,30 +91,33 @@ public: } protected: - std::string configFilePath; - - //Simulation specs + //Simulation Specs int seed; long int numTotalParticles; - double dt; + double dt_s; int injectionMethod; - double deltaKinEnergy; - double MBKinEnergy; - int numberZBins; - double minEBin; - double maxEBin; - int numberEBins; + double deltaKinEnergy_eV; + double MBKinEnergy_eV; + //KATRIN Specs - double wgtsMagField; - double wgtsLength; - double wgtsDiameter; + double wgtsMagField_T; + double wgtsLength_m; + double wgtsRadius_m; + double wgtsTritiumDensity_m3; + + // Help Functions + double v_ms(double Ekin_eV) { + double gamma = 1. + Ekin_eV/me_eV; + double beta = sqrt(1 - pow(gamma,-2)); + return(beta * c_ms); + } + double Ekin_eV(double speedAbs_ms) { + double beta = speedAbs_ms/c_ms; + double gamma = pow(1 - pow(beta,2),-0.5); + return ( (gamma-1) * me_eV * pow(c_nat,2) ); + } - // physical constants - double constPi; - double constc; - double constme; - double constqe; }; diff --git a/src/mc_electron/parameters.cat b/src/mc_electron/parameters.cat index 9f9243f..d85d3ff 100644 --- a/src/mc_electron/parameters.cat +++ b/src/mc_electron/parameters.cat @@ -1,9 +1,9 @@ seed = 2342395328 -numTotalParticles = 10 -dt = 0.00001 +numTotalParticles = 100 +dt_s = 0.00000001 injectionMethod = 2 -deltaKinEnergy = 10 -MBKinEnergy = 4.14e-22 J +deltaKinEnergy_eV = 100 +MBKinEnergy_eV = 100 numberZBins = 10 minEBin = 0 @@ -11,13 +11,10 @@ maxEBin = 10 numberEBins = 10 -wgtsMagField = 2.5 -wgtsLength = 10 -wgtsDiameter = 10 +wgtsMagField_T = 2.5 +wgtsLength_m = 10 +wgtsRadius_m = 0.045 +wgtsTritiumDensity_m3 = 5e21 +wgtsTemp_K = 27. - -constPi = 3.14159265 -constc = 299792458 -constme = 9.10938356e-31 m -constqe = −1.6021766208e-19 C diff --git a/src/mc_electron/particle.cpp b/src/mc_electron/particle.cpp index bfac881..7fda9f9 100644 --- a/src/mc_electron/particle.cpp +++ b/src/mc_electron/particle.cpp @@ -43,8 +43,17 @@ std::ostream& operator<<(std::ostream& os, const species& SpecOut) { } std::ostream& operator<<(std::ostream& os, const Particle& partOut) { - os << "(" << partOut.id<<","< x,v; + double m_eV; + double q_e; + blitz::TinyVector x_m; + blitz::TinyVector v_ms; species s; - long int id, parentId; + unsigned long int Id; + unsigned long int parentId; public: virtual ~Particle() { } - Particle(){} - Particle(double mass, double charge,blitz::TinyVector loc, blitz::TinyVector speed, double idnum, double parentIdnum, species spec) { - m = mass; - q = charge; - x = loc; - v = speed; - id = idnum; + Particle(double mass_eV, double charge_e,blitz::TinyVector loc_m, blitz::TinyVector speed_ms, double idnum, double parentIdnum, species spec) { + m_eV = mass_eV; + q_e = charge_e; + x_m = loc_m; + v_ms = speed_ms; + Id = idnum; parentId = parentIdnum; s = spec; } //Particle(Array props); //Create from Array - double getMass() { - return(m); + // Get Properties Methods + double getMass_eV() { + return(m_eV); } - double getCharge() { - return(q); + double getCharge_e() { + return(q_e); } - blitz::TinyVector getLoc() { - return(x); + blitz::TinyVector getLoc_m() { + return(x_m); } - blitz::TinyVector getSpeed() { - return(v); + blitz::TinyVector getSpeed_ms() { + return(v_ms); } double getId() { - return(id); + return(Id); } double getParentId() { return(parentId); } - double getRadius() { - return (sqrt( pow(x[0],2) + pow(x[1],2) )); + double getRadius_m() { + return (sqrt( pow(x_m[0],2) + pow(x_m[1],2) )); } - double getSpeedAbs() { - return (sqrt( pow(v[0],2) + pow(v[1],2) + pow(v[2],2))); + double getSpeedAbs_ms() { + return (sqrt( pow(v_ms[0],2) + pow(v_ms[1],2) + pow(v_ms[2],2))); } - double getEnergy(); // muss noch implementiert werden + double getKinEnergy_eV() { + // Implement Constants here, else Particle::Parameters + const double c_ms = 299792458; + const double me_eV = 0.511e6; + double SpeedAbs_ms = sqrt( pow(v_ms[0],2) + pow(v_ms[1],2) + pow(v_ms[2],2) ); + double beta = SpeedAbs_ms/c_ms; + double gamma = pow(1- pow(beta,2),-0.5); + return ( (gamma-1) * me_eV); + } + // Set Properties Methods + void setLoc_m(blitz::TinyVector xnew_m) {x_m = xnew_m; }; + void setSpeed_ms(blitz::TinyVector vnew_ms) {v_ms = vnew_ms; }; - void setLoc(blitz::TinyVector xnew) {x = xnew; }; - void setSpeed(blitz::TinyVector vnew) {v = vnew; }; + // Write Methods + friend std::ostream& operator<<(std::ostream& os, const Particle& partOut); +}; + + + +// Some Code, maybe required later + /* blitz::TinyVector locChange(blitz::TinyVector dx, int i, blitz::TinyVector xmin, blitz::TinyVector nx, blitz::TinyVector dvdt); blitz::TinyVector speedChange(blitz::TinyVector dv, int i); - friend std::ostream& operator<<(std::ostream& os, const Particle& partOut); - - /* void copyol(particle*); Array prop(Array); virtual Array array(); // ********************** warum virtual???? ****************************** //void copyol(particle); */ -}; - - - - - /* class particle_info : public particle { @@ -152,4 +162,6 @@ public: }; */ +// Other Functions + #endif diff --git a/src/mc_electron/simulation.cpp b/src/mc_electron/simulation.cpp index 419786e..351de6a 100644 --- a/src/mc_electron/simulation.cpp +++ b/src/mc_electron/simulation.cpp @@ -7,76 +7,85 @@ // #include "simulation.h" - +// void Simulation::init() { } void Simulation::doit() { - double MFP; - blitz::TinyVector oldLoc, newLoc; - // Iterator nicht mit push_back möglich - // Laufe vorderstes Teilchen bis zum Tod durch, entferne es dann aus der Liste + double energy_eV,sigTot_m2, density_m3,MFP_m; + blitz::TinyVector oldLoc_m, newLoc_m; while (numInjectedParticles < numTotalParticles) { - inject(); - - while (particleQueue.size()>0) { - // Run Code for first particle in Queue - - MFP = calcMFP(); - oldLoc = particleQueue[0].getLoc(); - - std::cout << "Before move: " <getKinEnergy_eV(); + sigTot_m2 = sigmaTot_m2(energy_eV); + density_m3 = Kat.getTritiumDensity(particleQueueIt->getLoc_m()); + MFP_m = 1/ ( density_m3 * sigTot_m2); + oldLoc_m = particleQueueIt->getLoc_m(); + newLoc_m = move(*particleQueueIt ,MFP_m); + if (movedOutside(newLoc_m)) { + // Reflexion oder Absorbtion? Erstmal Reflexion + newLoc_m = moveToLocOfDeath(*particleQueueIt); + particleQueueIt->setLoc_m(newLoc_m); + + writeToLogger(*particleQueueIt); + goto particleDied; + } + + particleQueueIt->setLoc_m(newLoc_m); + writeToLogger(*particleQueueIt); + + + /* + switch (getprocess()) { + case "ElasticScattering": + break; + case "Ionization": + break; + case "Recombination"; + + partQueue.erase(partQueue.begin()); + continue; + break; + default: + cerr<<"getprocess() returned unknown event"< loc, speed; - double r,phi,z; + +// Simulation Methods +Particle Simulation::inject() { + blitz::TinyVector loc_m, speed_ms; + double r_m,phi_rad,z_m; blitz::TinyVector speedDir; - double Ekin,absSpeed; + double Ekin_eV,absSpeed_ms; - r = rngUni.random()*wgtsDiameter; - phi = rngUni.random()*2*constPi; - z = rngUni.random()*wgtsLength; - loc = r*cos(phi),r*sin(phi),z; + r_m = rngUni.random()*wgtsRadius_m; + phi_rad = rngUni.random()*2*pi; + z_m = rngUni.random()*wgtsLength_m; + loc_m = r_m*cos(phi_rad),r_m*sin(phi_rad),z_m; // Add Code taking in account tritium density speedDir = rngUni.random(),rngUni.random(),rngUni.random(); @@ -85,67 +94,121 @@ void Simulation::inject() { switch(injectionMethod) { case 1: // Fermi - Ekin = 1.; //Implement Later + Ekin_eV = 1.; //Implement Later break; case 2: //Delta - Ekin = deltaKinEnergy; + Ekin_eV = deltaKinEnergy_eV; break; case 3: //Maxwell Boltzman - Ekin = 1.; //Implement Later + Ekin_eV = 1.; //Implement Later break; default: std::cerr<<"Invalid Injection Method./n"; exit(1); break; } - - absSpeed = sqrt( pow(constc,2) - ( pow(constme,2)*pow(constc,6) ) / pow( Ekin + constme*pow(constc,2) , 2 ) ); - speed = absSpeed * speedDir; + + absSpeed_ms = v_ms(Ekin_eV); + speed_ms = absSpeed_ms * speedDir; - particleQueue.assign(1,Particle(constme,constqe,loc, speed,numInjectedParticles,NULL,electron)); - numInjectedParticles++; + return (Particle(me_eV,qe_e,loc_m, speed_ms,numInjectedParticles,NULL,electron)); } -void Simulation::move(double MFP,int queueNum) { - if (queueNum > particleQueue.size()-1) { - std::cerr<<"queueNum outside of size"< Simulation::move(Particle inputParticle,double distance_m) { //Pseudocode, lineare bewegung - blitz::TinyVector SpeedDir; - SpeedDir = 1./sqrt(dot(particleQueue[queueNum].getSpeed(),particleQueue[queueNum].getSpeed()))*particleQueue[queueNum].getSpeed(); - particleQueue[queueNum].setLoc(particleQueue[queueNum].getLoc() + SpeedDir*MFP); + blitz::TinyVector oldLoc_m = inputParticle.getLoc_m(); + blitz::TinyVector v_ms =inputParticle.getSpeed_ms(); + blitz::TinyVector SpeedDir = pow(dot(v_ms,v_ms),-0.5)*v_ms; + return( oldLoc_m + SpeedDir*distance_m); } -bool Simulation::movedOutside(int queueNum) { - if (queueNum > particleQueue.size()-1) { - std::cerr<<"queueNum outside of size"< loc_m) { + double r_m = sqrt( pow(loc_m(0),2) + pow(loc_m(1),2) ); + return ( ! (loc_m[2]>0 && loc_m[2] < wgtsLength_m && r_m < wgtsRadius_m ) ); +} + +blitz::TinyVector Simulation::moveToLocOfDeath(Particle inputParticle) { + + // Führe methode 1 step für move ein, die einen einzelnen Schritt in move ausführt und benutze diese, bis an Rand + double stepsize = inputParticle.getSpeedAbs_ms()*dt_s; + blitz::TinyVector loc_m = inputParticle.getLoc_m(); + blitz::TinyVector rVec_m; + double r_m; + + // Include saftey calc for too small stepsize + + int countfordebug = 0; + while (!movedOutside(loc_m) ) { + loc_m = move (inputParticle,stepsize); + inputParticle.setLoc_m(loc_m); + countfordebug++; + } + + if (loc_m(2) < 0) { + loc_m(2) = 0; + } else if (loc_m(2) > wgtsLength_m) { + loc_m(2) = wgtsLength_m; } - blitz::TinyVector loc = particleQueue[queueNum].getLoc(); - double r = particleQueue[queueNum].getRadius(); - return (!(loc[2]>0 && loc[2] oldLoc, int queueNum) { - double stepsize = particleQueue[queueNum].getSpeedAbs()*dt; - particleQueue[queueNum].setLoc(oldLoc); - while (!movedOutside(queueNum) ) { - move (stepsize,queueNum); + r_m = sqrt(pow(loc_m(0),2)+pow(loc_m(1),2)); + if (r_m > wgtsRadius_m) { + loc_m(0) = wgtsRadius_m/r_m * loc_m(0); + loc_m(1) = wgtsRadius_m/r_m * (loc_m(1)); } - if (particleQueue[queueNum].getLoc()(2)<0) { - particleQueue[queueNum].getLoc()(2) = 0; - } else if (particleQueue[queueNum].getLoc()(2)>wgtsLength) { - particleQueue[queueNum].getLoc()(2) = wgtsLength; + return (loc_m); +} + + +// Logging Methods +void Simulation::writeToLogger(Particle inputParticle) { + std::string textLine; + + + particleLogger.push_back(textLine); +} + + +void Simulation::writeToFile(std::vector *particleLogger) { + // Write all electrons to one file, just append them, ID for identification + // Writing after every particle is very time intense.... Buffer and write only once every... + + outFile.open (outputName,std::ios::app); + for (particleLoggerIt = particleLogger->begin() ; particleLoggerIt != particleLogger->end() ; particleLoggerIt++) { + outFile << *particleLoggerIt< Create Outfile_1 + // -yes-> Create Outfile_i+1 }; - void init(void); void doit(void); - void inject(); - void output(void); - void move(double MFP,int queueNum=0); - bool movedOutside(int queueNum=0); - void moveToLocOfDeath(blitz::TinyVector oldLoc, int queueNum=0); - - double calcMFP(); - protected: - Katrin KAT; + // Simulation Objects + Katrin Kat; ranlib::Uniform rngUni; - - double t; - double id; - - std::vector particleQueue; int numInjectedParticles; + std::vector particleQueue, newParticles; std::vector::iterator particleQueueIt; + + // Logging Objects + int step; + std::string outputName; + std::vector particleLogger; + std::vector::iterator particleLoggerIt; + std::ofstream outFile; + + // Simulation Methods + Particle inject(); + blitz::TinyVector move(Particle inputParticle,double distance_m); + bool movedOutside(blitz::TinyVector loc_m); + blitz::TinyVector moveToLocOfDeath(Particle inputParticle); + + // Logging Methods + void writeToLogger(Particle inputParticle); + void writeToFile(std::vector *particleLogger); + + // Cross Sections + double sigmaTot_m2(double Ekin_eV); + double sigmaEla_m2(double Ekin_eV); + double dSigmaEladOmega_m2 (double Ekin_eV, double Theta_rad, double Phi_rad); + + }; #endif