Minior Changes on new structure, exported elastic cross section to seperate file.
Please enter the commit message for your changes. Lines starting
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// random_operations.h
|
||||
// mc_electron
|
||||
//
|
||||
// Created by Christian Reiling on 30.04.19.
|
||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef random_operations_h
|
||||
#define random_operations_h
|
||||
|
||||
#include "kinematics.h"
|
||||
|
||||
#include <random/uniform.h>
|
||||
#include <random/normal.h>
|
||||
|
||||
typedef ranlib::Uniform<double> UniRNG;
|
||||
typedef ranlib::NormalUnit<double> NormalRNG;
|
||||
|
||||
|
||||
class RNG_Base {
|
||||
public:
|
||||
RNG_Base(UniRNG *rngUni, NormalRNG *rngNormal) {
|
||||
this->rngUni = rngUni;
|
||||
this->rngNormal = rngNormal;
|
||||
};
|
||||
protected:
|
||||
UniRNG *rngUni;
|
||||
NormalRNG *rngNormal;
|
||||
};
|
||||
|
||||
|
||||
inline vec3 roll_uniform_direction(ranlib::Uniform<double> *rngUni) {
|
||||
vec3 dir;
|
||||
double phi = 2*pi*rngUni->random();
|
||||
double theta = pi*rngUni->random();
|
||||
dir = sin(theta)*cos(phi) , sin(theta)*sin(phi) , cos(theta);
|
||||
return(dir);
|
||||
}
|
||||
|
||||
inline double roll_MBEnergy(const double &Temp_K, const double &mass_eV,ranlib::NormalUnit<double> *rngNormal) {
|
||||
|
||||
double C = kb_eVK*Temp_K/mass_eV;
|
||||
double beta = 0;
|
||||
double sum = 0;
|
||||
for (int i=0;i<3;i++) {
|
||||
sum += pow(rngNormal->random(),2);
|
||||
}
|
||||
beta = sqrt(C*(sum));
|
||||
|
||||
return((calc_gamma_from_beta(beta)-1)*mass_eV);
|
||||
}
|
||||
|
||||
inline double roll_Rejectionmethod(double (*pdf)(double), double xmin, double xmax, double pmax, ranlib::Uniform<double> *rngUni) {
|
||||
// get Energy distribution using Rejection Method
|
||||
double xcan,eta1,eta2;
|
||||
do {
|
||||
eta1 = rngUni->random();
|
||||
eta2 = rngUni->random();
|
||||
xcan = xmin + eta1*(xmax - xmin);
|
||||
} while( eta2*pmax > pdf(xcan) );
|
||||
return(xcan);
|
||||
}
|
||||
|
||||
#endif /* random_operations_h */
|
||||
Reference in New Issue
Block a user