39 lines
1.4 KiB
C++
Executable File
39 lines
1.4 KiB
C++
Executable File
#include "interactions/excitation.h"
|
|
|
|
#include "constants/physical_constants.h"
|
|
#include "simulation/errors.h"
|
|
#include "simulation/kinematic.h"
|
|
#include "simulation/species.h"
|
|
|
|
namespace interaction {
|
|
|
|
Excitation::Excitation(std::function<double(double)> cross_section,
|
|
std::shared_ptr<species::Specie> target,
|
|
double excitation_energy_eV)
|
|
: Interaction(cross_section, target),
|
|
excitation_energy_eV_(excitation_energy_eV) {
|
|
ASSERT_POSITIVE(&excitation_energy_eV_,
|
|
"The exitation energy must be positive.");
|
|
}
|
|
|
|
InteractionOutput Excitation::performInteraction(particle::Particle& particle,
|
|
RandomNumbers* generator) {
|
|
#ifdef debug_level3
|
|
DEBUG_LEVEL_3("Perform excitation.");
|
|
#endif
|
|
const blitz::TinyVector<double, 3> v_impact =
|
|
particle.velocity().cartesianEntries();
|
|
const blitz::TinyVector<double, 3> n_impact =
|
|
v_impact / kinematic::norm(v_impact);
|
|
|
|
const double E_kin = kinematic::kineticEnergy(v_impact, particle.mass_kg()) *
|
|
UnitConversion::JouleToeV;
|
|
const double E_kin_new = E_kin - excitation_energy_eV_;
|
|
|
|
const blitz::TinyVector<double, 3> v_impact_new =
|
|
kinematic::velocityVector(E_kin_new, n_impact, particle.mass_kg());
|
|
particle.velocity(CartesianVector(v_impact_new));
|
|
return InteractionOutput();
|
|
}
|
|
|
|
}; // namespace interaction
|