scattering events that upscatter the neutral particle by an energy of 5mK*k_B (for now hard-coded); Type is only used if DeletionLogger is se=pecified as "all" in the parameter file
139 lines
5.5 KiB
C++
Executable File
139 lines
5.5 KiB
C++
Executable File
#include "interactions/elastic_scattering.h"
|
|
|
|
#include "constants/physical_constants.h"
|
|
#include "simulation/drift_velocity.h"
|
|
#include "simulation/errors.h"
|
|
#include "simulation/kinematic.h"
|
|
#include "simulation/scattering_angle_distribution.h"
|
|
#include "simulation/velocity_distribution.h"
|
|
#include "constants/sim_constants.h"
|
|
#include "simulation/density_field.h"
|
|
#include "simulation/logger.h"
|
|
namespace interaction {
|
|
|
|
ElasticScattering::ElasticScattering(
|
|
std::function<double(double)> cross_section,
|
|
std::shared_ptr<species::Specie> target,
|
|
std::shared_ptr<ScatteringAngleDistribution> theta_distrib)
|
|
: Interaction(cross_section, target), theta_distrib_(theta_distrib) {}
|
|
|
|
InteractionOutput ElasticScattering::performInteraction(
|
|
particle::Particle& particle,
|
|
RandomNumbers* generator) {
|
|
#ifdef debug_level3
|
|
DEBUG_LEVEL_3("Perform elastic scattering.");
|
|
#endif
|
|
const blitz::TinyVector<double, 3> v_impact =
|
|
particle.velocity().cartesianEntries();
|
|
|
|
double E_i = kinematic::kineticEnergy(v_impact, particle.mass_kg());
|
|
// const auto x_impact = particle.position();
|
|
// const blitz::TinyVector<double, 3> v_target =
|
|
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
|
// target_->velocityDistribution()
|
|
// ->rollVelocity(x_impact, generator->engine())
|
|
// .cartesianEntries();
|
|
|
|
const blitz::TinyVector<double, 3> v_laboratory =
|
|
kinematic::velocityTargetFixed(v_impact, target_velocity_.cartesianEntries(),
|
|
particle.mass_kg(),
|
|
target_->mass_kg());
|
|
|
|
const double E_kin =
|
|
kinematic::kineticEnergy(v_laboratory, particle.mass_kg()) *
|
|
UnitConversion::JouleToeV;
|
|
|
|
const double theta = theta_distrib_->roll(generator->engine(), E_kin);
|
|
const double phi = generator->rollUniform(0., 2 * M_PI);
|
|
|
|
const blitz::TinyVector<double, 3> v_impact_new =
|
|
kinematic::rotateVelocityInCenterOfMassFrame(
|
|
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(),
|
|
target_->mass_kg(), theta, phi);
|
|
|
|
double E_iprime = kinematic::kineticEnergy(v_impact_new, particle.mass_kg());
|
|
|
|
// energy conservation: Ei + Et = Ei' + Et' <==> Et' - Et = Ei - Ei' (lab frame)
|
|
if(E_i - E_iprime >= threshold_increase_J) {
|
|
particle.specie()->deletionLogger()->logDeletion(particle, PhysicalDeletionType::large_energy_transfer);
|
|
}
|
|
|
|
particle.velocity(CartesianVector(v_impact_new));
|
|
|
|
return InteractionOutput();
|
|
}
|
|
|
|
double ElasticScattering::drawCollisionTime(particle::Particle& particle,
|
|
RandomNumbers* generator) {
|
|
CartesianVector particle_velocity = particle.velocity();
|
|
|
|
target_velocity_ = target_->velocityDistribution()->
|
|
rollVelocity(particle.cylinderPosition(),
|
|
generator->engine());
|
|
|
|
// // if no drift velocity is present, then assume target at rest otherwise
|
|
// // use the drift velocity
|
|
if(target_->driftVelocity()) {
|
|
// auto tmp = target_->driftVelocity()->driftVelocity(particle.position());
|
|
target_velocity_.add(target_->driftVelocity()->driftVelocity(
|
|
particle.cartesianPosition(), particle.cylinderPosition()),
|
|
particle.cartesianPosition());
|
|
}
|
|
|
|
// masses are irrelevant for the transformation
|
|
const blitz::TinyVector<double, 3> velocity_target_fixed =
|
|
kinematic::velocityTargetFixed(particle_velocity.cartesianEntries(),
|
|
target_velocity_.cartesianEntries(), 0, 0);
|
|
|
|
const double relative_velocity = kinematic::norm(velocity_target_fixed);
|
|
|
|
// std::stringstream out;
|
|
// out << "particle "<< particle.specie()->name() <<" velocity: "
|
|
// << particle_velocity.cartesianEntries();
|
|
// out << "\ntarget "<< target_->name() <<" velocity: "
|
|
// << target_velocity_.cartesianEntries();
|
|
// out << "\nabsolute relative velocity: " << relative_velocity;
|
|
|
|
// check if the relative velocity is smaller than an epsilon compared to the larger
|
|
// of the two present velocities (to avoid division by 0 if either is 0) probably
|
|
// a better version possible
|
|
if(relative_velocity/std::max(
|
|
kinematic::norm(particle_velocity.cartesianEntries()),
|
|
kinematic::norm(target_velocity_.cartesianEntries())
|
|
) < SimConstants::compare_epsilon) {
|
|
return std::numeric_limits<double>::max();
|
|
}
|
|
|
|
const double energy_eV =
|
|
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
|
|
UnitConversion::JouleToeV;
|
|
|
|
// out << "energy collision time: " << energy_eV;
|
|
|
|
const double crosssection = microscopicCrossSection(energy_eV,
|
|
particle.cylinderPosition());
|
|
// out << "\ncross section: " << crosssection;
|
|
const double density = target_->densityField()->density(particle.cylinderPosition());
|
|
|
|
// out << "\ninverse mfp: " << crosssection*density << ", sigma: " << crosssection;
|
|
// out << ", density: " << density;
|
|
|
|
const double random_number = generator->rollUniform(0.,1.);
|
|
if (random_number == 0) {
|
|
return std::numeric_limits<double>::max();
|
|
}
|
|
|
|
const double distance_target_fixed =
|
|
- 1./(crosssection * density) * log(random_number);
|
|
|
|
// out << "\ndistance in target fixed frame: " << distance_target_fixed;
|
|
|
|
const double time = distance_target_fixed / relative_velocity;
|
|
// out << "\ntime before collision: " << time;
|
|
// if(density != 0)
|
|
// DEBUG_LEVEL_1(out.str());
|
|
|
|
return time;
|
|
}
|
|
|
|
}; // namespace interaction
|