Decoupled the number of events simulated from

the timestep;
Bug with density drawing present
(if CPU syncs don't line up with the timestep)
This commit is contained in:
2025-02-12 14:07:43 +01:00
parent e205e7469e
commit 047cfa8491
5 changed files with 73 additions and 50 deletions
+14 -8
View File
@@ -40,9 +40,13 @@ particle::Particle Injector::rollNewParticle(
velocity,
mother_drift_velocity_->driftVelocity(position).cartesianEntries());
}
#if defined debug_level3
std::stringstream out;
out << created_specie->name() << " created at time: " << time_birth << "s.";
DEBUG_LEVEL_3(out.str());
#endif
return particle::Particle(created_specie, position,
CartesianVector(velocity), time_birth, weight);
}
@@ -53,26 +57,28 @@ void Injector::initInjectionTimeDistribution(double delta_t) {
}
std::vector<particle::Particle> Injector::rollNewParticles(
std::mt19937* engine, const double current_time) {
std::mt19937* engine, const double current_time,
const double beta_particle_weight) {
// pull drawing from the position distribution into the "multiplicity" loop?
// (would improve resolution stuff in space as well as just in velocity direction
// especially for slow particles, i.e. ions)
CylinderCoordinate position = position_distribution_->rollPosition(engine);
DEBUG_LEVEL_3("Injected z position: " +
std::to_string(position.cylinderEntries()(2)));
std::vector<particle::Particle> new_particles;
const double time_birth = current_time - injection_time_distribution_(*engine);
for (auto& injector_info : injector_infos_) {
const double weight = 1./injector_info.multiplicity;
CylinderCoordinate position = position_distribution_->rollPosition(engine);
DEBUG_LEVEL_3("Injected z position: " +
std::to_string(position.cylinderEntries()(2)));
for (int i = 0; i < injector_info.multiplicity; i++) {
// for (int i = 0; i < injector_info.multiplicity; i++) {
new_particles.push_back(
rollNewParticle(engine, position, injector_info.created_specie,
injector_info.creation_velocity_distribution,
time_birth, weight));
}
time_birth, beta_particle_weight));
// }
}
return new_particles;
}