Major changes:
- 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
This commit is contained in:
@@ -9,62 +9,75 @@
|
||||
#ifndef interaction_base_hpp
|
||||
#define interaction_base_hpp
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "particle.hpp"
|
||||
#include "population.hpp"
|
||||
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
class InteractionOut {
|
||||
bool deleteCur;
|
||||
std::deque <Particle> newParticles;
|
||||
#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:
|
||||
InteractionOut() {reset();};
|
||||
|
||||
void reset() {
|
||||
deleteCur = false;
|
||||
newParticles.empty();
|
||||
}
|
||||
|
||||
void set_deleteCur(const bool &deleteCur) {this->deleteCur = deleteCur;}
|
||||
void set_newParticles(const std::deque<Particle> &newParticles) {this->newParticles = newParticles;}
|
||||
void add_newParticle(const Particle &newParticle) {newParticles.push_back(newParticle);}
|
||||
|
||||
void appendDeque(std::deque<Particle> *Que, int *currentNewID) {
|
||||
Particle curPart;
|
||||
for (std::deque<Particle>::iterator Itr = newParticles.begin();Itr!=newParticles.end();Itr++) {
|
||||
curPart = (*Itr);
|
||||
curPart.set_Id(*currentNewID);
|
||||
currentNewID++;
|
||||
Que->push_back(curPart);
|
||||
}
|
||||
}
|
||||
|
||||
bool terminateCurrent() const {return(deleteCur);};
|
||||
//std::deque<Particle> get_newParticles() const {return(newParticles);};
|
||||
};
|
||||
|
||||
|
||||
class Interaction : public RNG_Base {
|
||||
protected:
|
||||
Population *Pop;
|
||||
species Species;
|
||||
|
||||
public:
|
||||
Interaction(species Species, Population *Pop, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
|
||||
this->Species = Species;
|
||||
this->Pop = Pop;
|
||||
Interaction_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
|
||||
species get_Species() const {return(Species);}
|
||||
void add(Sub_Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macroSigma_m2(const Particle &interPart);
|
||||
|
||||
virtual double get_macroSigma_m2(const Particle &interPart) const = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) const = 0;
|
||||
};
|
||||
|
||||
|
||||
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 */
|
||||
|
||||
Reference in New Issue
Block a user