Files
katrin-plasma/src/mc_electron/particle.h
T
Christian 15851a540a Added new test class, reworked some code
Started Implementing Ionization
2018-11-07 12:11:24 +01:00

123 lines
3.0 KiB
C++

//
// particle.h
// mc_electron
//
// Created by Christian Reiling on 20.09.18.
// Copyright © 2018 Christian Reiling. All rights reserved.
//
#ifndef particle_hpp
#define particle_hpp
#include <stdio.h>
#include <math.h>
#include <vector>
#include <iostream>
#include <fstream>
#include "blitz/array.h"
#include "blitz/tinyvec2.h"
#include <random/uniform.h>
#include "constants.h"
typedef enum species{undef, electron, positron, proton, tritium, tritium2, helium, deuterium, DT}species;
std::ostream& operator<<(std::ostream& os, const species& SpecOut);
class Particle: protected Constants
{
protected:
double m_eV;
double q_e;
blitz::TinyVector<double,3> x_m;
blitz::TinyVector<double,3> v_ms;
species s;
unsigned long int Id;
unsigned long int parentId;
double r_m();
double vAbs_ms();
double beta();
double gamma();
double calcEkin_eV();
double elaTau();
double elaEta();
public:
virtual ~Particle() {}
Particle() {}
Particle(double mass_eV, double charge_e,blitz::TinyVector<double,3> loc_m, blitz::TinyVector<double,3> 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(double mass_eV,blitz::TinyVector<double,3> speed_ms) { //Resting dummy for elastic scattering
blitz::TinyVector<double,3> zero;
zero = 0,0,0;
m_eV = mass_eV;
q_e = 0;
x_m = zero;
v_ms = speed_ms;
Id = 0;
parentId = 0;
s = undef;
}
// Get Properties Methods
double getMass_eV() { return(m_eV); }
double getCharge_e() { return(q_e); }
blitz::TinyVector<double,3> getLoc_m() { return(x_m); }
blitz::TinyVector<double,3> getSpeed_ms() { return(v_ms); }
double getId() { return(Id); }
double getParentId() { return(parentId); }
double getRadius_m() { return ( r_m() ); }
double getSpeedAbs_ms() { return (vAbs_ms() ); }
double getKinEnergy_eV() { return (calcEkin_eV() ); }
// Set Properties Methods
void setLoc_m(blitz::TinyVector<double, 3> xnew_m) {x_m = xnew_m; };
void setSpeed_ms(blitz::TinyVector<double, 3> vnew_ms) {v_ms = vnew_ms; };
// Boris Push
public:
double borisFly_m(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s);
protected:
void changeLocFly(double dt_s);
void changeSpeedBoris(blitz::TinyVector<double, 3> E_Vm , blitz::TinyVector<double, 3> B_T , double dt_s);
// Interactions
public:
double getSigmaTot_m2() { return (getSigmaEla_m2()+getSigmaIon_m2()); }
protected:
void elasticKinematicClassical(Particle *P2, double theta, double phi);
blitz::TinyVector<double,3> getNewDir(double theta,double phi,blitz::TinyVector<double,3> oldDir);
// Elastic Scattering
public:
double getSigmaEla_m2();
void doElaScat (ranlib::Uniform<double> *rngUni);
protected:
double getRandomTheta(ranlib::Uniform<double> *rngUni);
// Ionization
public:
double getSigmaIon_m2();
void doIon (ranlib::Uniform<double> *rngUni);
// Write Methods
public:
friend std::ostream& operator<<(std::ostream& os, const Particle& partOut);
};
#endif