65 lines
2.3 KiB
C++
Executable File
65 lines
2.3 KiB
C++
Executable File
#ifndef INTERACTION_H
|
|
#define INTERACTION_H
|
|
|
|
#include "simulation/particle.h"
|
|
#include "simulation/random_numbers.h"
|
|
#include "simulation/species.h"
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace interaction {
|
|
|
|
// class to define the output of an interaction
|
|
class InteractionOutput {
|
|
public:
|
|
// Constructor: incident particle is not flagged for deletion
|
|
InteractionOutput();
|
|
|
|
// if new_decider is true then the incident particle of the interaction is
|
|
// flagged for deletion
|
|
void deleteCurrentParticle(bool new_decider);
|
|
// return if the incident particle is flagged for deletion
|
|
bool deleteCurrentParticle();
|
|
// add particles that are created (not the incident) particles to the InteractionOutput
|
|
void add(const particle::Particle& new_particle);
|
|
// return the vector of particles that have been created by an interactoin
|
|
std::vector<particle::Particle> newParticles();
|
|
|
|
private:
|
|
// flag if the incident particle should be deleted
|
|
bool delete_current_particle_;
|
|
// vector for the interaction products (no including the incident particle even if it's not
|
|
// destroyed by the interaction)
|
|
std::vector<particle::Particle> new_particles_;
|
|
};
|
|
|
|
// parent class for all interactions (cannot be instantiated)
|
|
class Interaction {
|
|
public:
|
|
// Constructor: takes a function describing the cross section of used for the interaction as a function of energy (in eV)
|
|
// a shared_ptr to the Specie of the target species
|
|
Interaction(std::function<double(double)> cross_section,
|
|
std::shared_ptr<species::Specie> target);
|
|
|
|
// return the value of the cross section at the energy (in eV) energy_eV in m^2
|
|
virtual double microscopicCrossSection(double energy_eV);
|
|
// calculate the density scaled cross section for the Particle particle
|
|
// interacting with the defined target Specie (returns cross section * target density) (units: m^-1)
|
|
// assumes that v_particle >> v_target
|
|
virtual double macroscopicCrossSection(particle::Particle& particle);
|
|
|
|
// pure virtual function defining the specifics of the actual interaction
|
|
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
|
RandomNumbers* generator) = 0;
|
|
|
|
protected:
|
|
std::function<double(double)> cross_section_;
|
|
std::shared_ptr<species::Specie> target_;
|
|
};
|
|
|
|
}; // namespace interaction
|
|
|
|
#endif /* INTERACTION_H */
|