Bug fixes in mass terms.
Restructured Interaction Base classes and reviewed. Added Parameters for Setting Number of Integration Points for CS and for Population sices.
This commit is contained in:
@@ -9,71 +9,51 @@
|
||||
#ifndef interaction_base_hpp
|
||||
#define interaction_base_hpp
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
#include "sub_interaction_base.h"
|
||||
#include "particle.hpp"
|
||||
#include "population_base.h"
|
||||
|
||||
#include "process_base.h"
|
||||
#include "constants.h"
|
||||
#include "kinematics.h"
|
||||
#include "integrater.h"
|
||||
#include "error_types.h"
|
||||
|
||||
|
||||
class Interaction_Channel_Base : public Process_Base {
|
||||
Interaction_Base **SubInteractions;
|
||||
int numSubInteractions = 0;
|
||||
|
||||
UniRNG *rngUni;
|
||||
class InteractionOut {
|
||||
bool delete_current;
|
||||
Particle new_particles[3];
|
||||
int number_new_particles;
|
||||
|
||||
public:
|
||||
Interaction_Channel_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
InteractionOut() {reset();};
|
||||
void reset() {
|
||||
delete_current = false;
|
||||
number_new_particles = 0;
|
||||
}
|
||||
|
||||
void add(Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macro_sigma_m(const Particle &interPart);
|
||||
void set_delete_current(const bool &delete_current) {this->delete_current = delete_current;}
|
||||
bool get_delete_current() {return delete_current;}
|
||||
void add_new_particle(const Particle &newParticle) {
|
||||
new_particles[number_new_particles] = newParticle;
|
||||
number_new_particles++;
|
||||
}
|
||||
int get_number_new_particles() {return number_new_particles;}
|
||||
Particle *get_new_particles() {return new_particles;}
|
||||
};
|
||||
|
||||
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
||||
double macro_sigma_m = get_macro_sigma_m(*interPart);
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macro_sigma_m;
|
||||
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
currentStackedSigma += SubInteractions[i]->get_macro_sigma_m(*interPart);
|
||||
if (currentStackedSigma >= targetStackedSigma) {
|
||||
return SubInteractions[i]->do_Interaction(interPart);
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
inline double Interaction_Channel_Base::get_macro_sigma_m(const Particle &interPart) {
|
||||
double macro_sigma_m = 0;
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
macro_sigma_m += SubInteractions[i]->get_macro_sigma_m(interPart);
|
||||
}
|
||||
return macro_sigma_m;
|
||||
}
|
||||
|
||||
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||
if (numSubInteractions != 0) {
|
||||
Interaction_Base *tempArray[numSubInteractions];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
tempArray[i] = SubInteractions[i];
|
||||
}
|
||||
delete[] SubInteractions;
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
SubInteractions[i] = tempArray[i];
|
||||
}
|
||||
} else {
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
}
|
||||
SubInteractions[numSubInteractions] = addSubInteraction;
|
||||
numSubInteractions += 1;
|
||||
}
|
||||
|
||||
class Interaction_Base {
|
||||
protected:
|
||||
Population_Base *Population;
|
||||
UniRNG *rngUni;
|
||||
public:
|
||||
Interaction_Base(Population_Base *Population, UniRNG *rngUni) {
|
||||
this->Population = Population;
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
virtual double get_macro_sigma_m(const Particle &interPart) = 0;
|
||||
virtual InteractionOut do_Interaction (Particle *interPart) = 0;
|
||||
};
|
||||
|
||||
#endif /* interaction_base_h */
|
||||
|
||||
Reference in New Issue
Block a user