Prepared structure for precalculating values.
Reduced number of energy bins and intergration precision to 5.
This commit is contained in:
@@ -15,24 +15,24 @@
|
||||
#include "process_base.h"
|
||||
|
||||
|
||||
class Interaction_Base : public Process_Base {
|
||||
Sub_Interaction_Base **SubInteractions;
|
||||
class Interaction_Channel_Base : public Process_Base {
|
||||
Interaction_Base **SubInteractions;
|
||||
int numSubInteractions = 0;
|
||||
|
||||
UniRNG *rngUni;
|
||||
|
||||
public:
|
||||
Interaction_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
Interaction_Channel_Base(species this_species, UniRNG *rngUni) : Process_Base (this_species) {
|
||||
this->rngUni = rngUni;
|
||||
};
|
||||
|
||||
void add(Sub_Interaction_Base *addSubInteraction);
|
||||
void add(Interaction_Base *addSubInteraction);
|
||||
|
||||
InteractionOut do_Interaction(Particle *interPart);
|
||||
double get_macroSigma_m(const Particle &interPart);
|
||||
};
|
||||
|
||||
inline InteractionOut Interaction_Base::do_Interaction(Particle *interPart) {
|
||||
inline InteractionOut Interaction_Channel_Base::do_Interaction(Particle *interPart) {
|
||||
double macroSigma_m = get_macroSigma_m(*interPart);
|
||||
double currentStackedSigma = 0;
|
||||
double targetStackedSigma = rngUni->random() * macroSigma_m;
|
||||
@@ -44,12 +44,12 @@ inline InteractionOut Interaction_Base::do_Interaction(Particle *interPart) {
|
||||
}
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss<<"Interaction_Base::do_Interaction: No Interactions added.\n";
|
||||
ss<<"Interaction_Channel_Base::do_Interaction: No Interactions added.\n";
|
||||
throw MyException (ss.str());
|
||||
}
|
||||
|
||||
|
||||
inline double Interaction_Base::get_macroSigma_m(const Particle &interPart) {
|
||||
inline double Interaction_Channel_Base::get_macroSigma_m(const Particle &interPart) {
|
||||
double macroSigma_m = 0;
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
macroSigma_m += SubInteractions[i]->get_macroSigma_m(interPart);
|
||||
@@ -57,19 +57,19 @@ inline double Interaction_Base::get_macroSigma_m(const Particle &interPart) {
|
||||
return macroSigma_m;
|
||||
}
|
||||
|
||||
inline void Interaction_Base::add(Sub_Interaction_Base *addSubInteraction) {
|
||||
inline void Interaction_Channel_Base::add(Interaction_Base *addSubInteraction) {
|
||||
if (numSubInteractions != 0) {
|
||||
Sub_Interaction_Base *tempArray[numSubInteractions];
|
||||
Interaction_Base *tempArray[numSubInteractions];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
tempArray[i] = SubInteractions[i];
|
||||
}
|
||||
delete[] SubInteractions;
|
||||
SubInteractions = new Sub_Interaction_Base *[numSubInteractions + 1];
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
for (int i = 0; i < numSubInteractions; i++) {
|
||||
SubInteractions[i] = tempArray[i];
|
||||
}
|
||||
} else {
|
||||
SubInteractions = new Sub_Interaction_Base *[numSubInteractions + 1];
|
||||
SubInteractions = new Interaction_Base *[numSubInteractions + 1];
|
||||
}
|
||||
SubInteractions[numSubInteractions] = addSubInteraction;
|
||||
numSubInteractions += 1;
|
||||
|
||||
Reference in New Issue
Block a user