- Moved to array operations for main loops. - Changed to setting pointers to operator only once before loop. - Changed Population Containers - Added Recombination - Added Inelastic Scattering Kinematics - Reworked Elastic Scattering Cross Section - Reworked Elastic Scattering Kinematics - Reworked organisation of different particle species and corresponding operators
84 lines
2.2 KiB
C++
84 lines
2.2 KiB
C++
//
|
|
// interaction_base.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 24.04.19.
|
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef interaction_base_hpp
|
|
#define interaction_base_hpp
|
|
|
|
|
|
|
|
#include "sub_interaction_base.h"
|
|
|
|
#include "process_base.h"
|
|
|
|
|
|
class Interaction_Base : public Process_Base {
|
|
Sub_Interaction_Base **SubInteractions;
|
|
int numSubInteractions = 0;
|
|
|
|
UniRNG *rngUni;
|
|
|
|
public:
|
|
Interaction_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
|
this->rngUni = rngUni;
|
|
};
|
|
|
|
void add(Sub_Interaction_Base *addSubInteraction);
|
|
|
|
InteractionOut do_Interaction(Particle *interPart);
|
|
double get_macroSigma_m2(const Particle &interPart);
|
|
|
|
};
|
|
|
|
|
|
inline InteractionOut Interaction_Base::do_Interaction(Particle *interPart) {
|
|
double macroSigma_m2 = get_macroSigma_m2(*interPart);
|
|
|
|
double currentStackedSigma = zero;
|
|
double targetStackedSigma = rngUni->random() * macroSigma_m2;
|
|
|
|
|
|
for (int i = 0; i < numSubInteractions; i++) {
|
|
currentStackedSigma += SubInteractions[i]->get_macroSigma_m2(*interPart);
|
|
if (currentStackedSigma > targetStackedSigma) {
|
|
return (SubInteractions[i]->do_Interaction(interPart));
|
|
}
|
|
}
|
|
std::stringstream ss;
|
|
ss<<"Interaction_Base::do_Interactio: No Interaction selected.\n";
|
|
throw MyException (ss.str());
|
|
}
|
|
|
|
inline double Interaction_Base::get_macroSigma_m2(const Particle &interPart) {
|
|
double macroSigma_m2 = zero;
|
|
for (int i = 0; i < numSubInteractions; i++) {
|
|
macroSigma_m2 += SubInteractions[i]->get_macroSigma_m2(interPart);
|
|
}
|
|
return(macroSigma_m2);
|
|
}
|
|
|
|
inline void Interaction_Base::add(Sub_Interaction_Base *addSubInteraction) {
|
|
if (numSubInteractions != 0) {
|
|
Sub_Interaction_Base *tempArray[numSubInteractions];
|
|
for (int i = 0; i < numSubInteractions; i++) {
|
|
tempArray[i] = SubInteractions[i];
|
|
}
|
|
delete[] SubInteractions;
|
|
SubInteractions = new Sub_Interaction_Base *[numSubInteractions + 1];
|
|
for (int i = 0; i < numSubInteractions; i++) {
|
|
SubInteractions[i] = tempArray[i];
|
|
}
|
|
} else {
|
|
SubInteractions = new Sub_Interaction_Base *[numSubInteractions + 1];
|
|
}
|
|
SubInteractions[numSubInteractions] = addSubInteraction;
|
|
numSubInteractions += 1;
|
|
}
|
|
|
|
|
|
#endif /* interaction_base_h */
|