reduced number of calls to atan2 (in mover only

for the Boris push algo), changed drawing of
uniformly distributed unit vector
This commit is contained in:
2025-05-28 15:18:13 +02:00
parent a33e97187e
commit e2167fb75b
3 changed files with 50 additions and 27 deletions
+13 -5
View File
@@ -62,20 +62,25 @@ double Interaction::microscopicCrossSection(double energy_eV) {
return cross_section_(energy_eV);
}
// think i need to include the magnetic field for it to be really correct
double Interaction::drawCollisionTime(particle::Particle& particle,
RandomNumbers* generator) {
CartesianVector particle_velocity = particle.velocity();
CylinderCoordinate particle_cylinderPosition(particle.position().cylinderEntries());
target_velocity_ = target_->velocityDistribution()->
rollVelocity(particle.position(), generator->engine());
// if no drift velocity is present, then assume target at rest otherwise
// use the drift velocity
// // if no drift velocity is present, then assume target at rest otherwise
// // use the drift velocity
if(target_->driftVelocity()) {
target_velocity_.add(target_->driftVelocity()->driftVelocity(particle.position()),
// auto tmp = target_->driftVelocity()->driftVelocity(particle.position());
target_velocity_.add(target_->driftVelocity()->driftVelocity(particle_cylinderPosition),
particle.position());
}
// target_velocity_ = CartesianVector(blitz::TinyVector<double, 3>(0.,0.,0.));
// masses are irrelevant for the transformation
const blitz::TinyVector<double, 3> velocity_target_fixed =
kinematic::velocityTargetFixed(particle_velocity.cartesianEntries(),
@@ -104,8 +109,11 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
UnitConversion::JouleToeV;
// out << "energy collision time: " << energy_eV;
const double crosssection = microscopicCrossSection(energy_eV);
const double density = target_->densityField()->density(particle.position());
// out << "\ncross section: " << crosssection;
const double density = target_->densityField()->density(particle_cylinderPosition);
// out << "\ninverse mfp: " << crosssection*density << ", sigma: " << crosssection;
// out << ", density: " << density;
@@ -116,7 +124,7 @@ double Interaction::drawCollisionTime(particle::Particle& particle,
}
const double distance_target_fixed =
- 1./(crosssection * density) * log(generator->rollUniform(0.,1.));
- 1./(crosssection * density) * log(random_number);
// out << "\ndistance in target fixed frame: " << distance_target_fixed;