Files
karl/src/interactions/ionization.cpp
T

174 lines
6.3 KiB
C++
Executable File

#include "interactions/ionization.h"
#include <math.h>
#include "constants/physical_constants.h"
#include "constants/sim_constants.h"
#include "simulation/drift_velocity.h"
#include "simulation/kinematic.h"
#include "simulation/particle.h"
#include "simulation/velocity_distribution.h"
namespace interaction {
ElectronIonization::ElectronIonization(
std::function<double(double)> cross_section,
std::shared_ptr<species::Specie> target,
std::shared_ptr<species::TrackedSpecie> electron,
std::shared_ptr<species::TrackedSpecie> ion,
std::shared_ptr<IonizationEnergyDistribution> distribution,
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
double ionization_energy_eV)
: Interaction(cross_section, target),
electron_(electron),
ion_(ion),
energy_distribution_(distribution),
angle_distribution_(angle_distribution),
ionization_energy_eV_(ionization_energy_eV) {}
InteractionOutput ElectronIonization::performInteraction(
particle::Particle& particle,
RandomNumbers* generator) {
DEBUG_LEVEL_3("Perform ionization.");
const blitz::TinyVector<double, 3> v_impact =
particle.velocity().cartesianEntries();
const auto x_impact = particle.position();
blitz::TinyVector<double, 3> v_target;
blitz::TinyVector<double, 3> v_laboratory;
double E_impact;
do {
v_target =
target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
target_->velocityDistibution()
->rollVelocity(x_impact, generator->engine())
.cartesianEntries();
v_laboratory = kinematic::velocityTargetFixed(
v_impact, v_target, particle.mass_kg(), target_->mass_kg());
E_impact = kinematic::kineticEnergy(v_laboratory, particle.mass_kg()) *
UnitConversion::JouleToeV;
} while (E_impact <= ionization_energy_eV_);
const double E_impact_new =
energy_distribution_->rollImpactParticleEnergyAfterCollision(E_impact,
generator);
const double E_ejected =
std::max(0., E_impact - E_impact_new - ionization_energy_eV_);
const double polar_angle_impact_new = generator->rollUniform(0., 2 * M_PI);
const double polar_angle_ejected = (polar_angle_impact_new - M_PI) < 0.
? (polar_angle_impact_new + M_PI)
: (polar_angle_impact_new - M_PI);
const double azimuth_angle_impact_new =
angle_distribution_->rollAzimuthImpactParticleAfterCollision(
E_impact, E_impact_new, generator);
const double azimuth_angle_ejected =
angle_distribution_->rollAzimuthEjectedParticleAfterCollision(
E_impact, E_ejected, generator);
const double v_lab_impact_new =
kinematic::velocity(E_impact_new, particle.mass_kg());
const double v_lab_ejected =
kinematic::velocity(E_ejected, electron_->mass_kg());
const blitz::TinyVector<double, 3> v_lab_norm =
v_laboratory / kinematic::norm(v_laboratory);
const blitz::TinyVector<double, 3> v_impact_new =
kinematic::rotateVector(v_lab_norm, azimuth_angle_impact_new,
polar_angle_impact_new) *
v_lab_impact_new +
v_target;
const blitz::TinyVector<double, 3> v_ejected =
kinematic::rotateVector(v_lab_norm, azimuth_angle_ejected,
polar_angle_ejected) *
v_lab_ejected +
v_target;
particle.velocity(v_impact_new);
InteractionOutput output;
output.add(
particle::Particle(electron_, x_impact, CartesianVector(v_ejected)));
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target)));
return output;
}
IonizationEnergyDistribution::IonizationEnergyDistribution(
std::function<double(double, double)> d2_cross_section,
double ionization_energy_eV)
: d2_cross_section_(d2_cross_section),
ionization_energy_eV_(ionization_energy_eV) {}
double IonizationEnergyDistribution::rollImpactParticleEnergyAfterCollision(
double impact_energy,
RandomNumbers* generator) {
// using rejection method:
// assuming cross section is highest at smallest numbers
const double energy_after_min = SimConstants::random_lower_limit;
const double energy_after_max = impact_energy - ionization_energy_eV_;
const double cross_section_min = 0;
const double cross_section_max =
d2_cross_section_(impact_energy, energy_after_min);
double energy_after;
double cross_section;
do {
energy_after = generator->rollUniform(energy_after_min, energy_after_max);
cross_section =
generator->rollUniform(cross_section_min, cross_section_max);
} while (cross_section > d2_cross_section_(impact_energy, energy_after));
// outgoing particles are indistiquishable
energy_after = energy_after > (impact_energy - ionization_energy_eV_) / 2.
? energy_after
: (impact_energy - ionization_energy_eV_) - energy_after;
return energy_after;
}
double
IonizationScatteringAngleDistribution::rollAzimuthImpactParticleAfterCollision(
double impact_energy,
double energy_impact_particle_new,
RandomNumbers* generator) {
// "after Transport of low energy electrons in nitrogen and air" B.Grosswendt,
// E.Waibel
if (energy_impact_particle_new > 100) {
return std::asin(
std::sqrt((energy_impact_particle_new / impact_energy) /
((1 - energy_impact_particle_new / impact_energy) *
(impact_energy / (2 * HEPunits::me)) +
1)));
} else {
return generator->rollUniform(0., M_PI / 4.);
}
}
double
IonizationScatteringAngleDistribution::rollAzimuthEjectedParticleAfterCollision(
double impact_energy,
double energy_impactParticle_new,
RandomNumbers* generator) {
// "after Transport of low energy electrons in nitrogen and air" B.Grosswendt,
// E.Waibel
if (energy_impactParticle_new > 200) {
return std::asin(
std::sqrt((1 - energy_impactParticle_new / impact_energy) /
(1 + energy_impactParticle_new / (2 * HEPunits::me))));
} else if (energy_impactParticle_new >= 50) {
if (generator->rollUniform(0., 1.) < 0.9) {
return generator->rollUniform(M_PI / 4, M_PI / 2);
} else {
return generator->rollUniform(0., M_PI);
}
} else {
return generator->rollUniform(0., M_PI);
}
};
}; // namespace interaction