Basic neccessities to draw from a density field;
does not yet work correctly since the neccessary density field is reset after a time resolution step
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "simulation/kinematic.h"
|
||||
#include "simulation/particle.h"
|
||||
#include "simulation/species.h"
|
||||
#include "simulation/density_field.h"
|
||||
#include "simulation/velocity_distribution.h"
|
||||
#include <sstream>
|
||||
|
||||
@@ -45,19 +46,23 @@ particle::Particle Injector::rollNewParticle(
|
||||
CartesianVector(velocity), time_birth, weight);
|
||||
}
|
||||
|
||||
void Injector::initInjectionTimeDistribution(double delta_t) {
|
||||
injection_time_distribution_ =
|
||||
std::uniform_real_distribution<double>(0., delta_t);
|
||||
}
|
||||
|
||||
std::vector<particle::Particle> Injector::rollNewParticles(
|
||||
std::mt19937* engine, const double current_time,
|
||||
const int time_resolution_events) {
|
||||
std::mt19937* engine, const double current_time) {
|
||||
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 delta_t = time_resolution_events*timePassed();
|
||||
std::uniform_real_distribution<> injection_time(current_time - delta_t,
|
||||
current_time);
|
||||
const double time_birth = injection_time(*engine);
|
||||
|
||||
const double time_birth = current_time - injection_time_distribution_(*engine);
|
||||
|
||||
for (auto& injector_info : injector_infos_) {
|
||||
const double weight = 1./injector_info.multiplicity;
|
||||
|
||||
for (int i = 0; i < injector_info.multiplicity; i++) {
|
||||
new_particles.push_back(
|
||||
rollNewParticle(engine, position, injector_info.created_specie,
|
||||
@@ -68,6 +73,44 @@ std::vector<particle::Particle> Injector::rollNewParticles(
|
||||
return new_particles;
|
||||
}
|
||||
|
||||
void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
std::shared_ptr<species::TrackedSpecie> specie,
|
||||
std::vector<particle::Particle>& queue,
|
||||
const double weight,
|
||||
const double injection_time) {
|
||||
blitz::TinyVector<double, 4> particle_specs =
|
||||
specie->dynamicDensityField()->drawPositionAndEnergy(engine);
|
||||
// blitz::TinyVector<double, 4> particle_specs(0.01, 0, 1, 1);
|
||||
|
||||
// check if density was empty (i.e. Energy component is 0)
|
||||
if (particle_specs[3] == 0) {
|
||||
DEBUG_LEVEL_3(specie->name() + ": has zero density");
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LEVEL_3("Injected z position: " + std::to_string(particle_specs(2)));
|
||||
|
||||
const double v_abs = kinematic::velocity(particle_specs[3], specie->mass_kg());
|
||||
|
||||
std::uniform_real_distribution<double> distribution(0.0, 1.0);
|
||||
const double theta = distribution(*engine) * 2 * M_PI;
|
||||
const double phi = std::acos(1. - 2.*distribution(*engine));
|
||||
|
||||
// for now draw the particles with an isotropic velocity distribution,
|
||||
// is not realistic but as of now there is no information about the
|
||||
// velocity vector distribution in the respective cell
|
||||
blitz::TinyVector<double, 3> v_normal(std::cos(theta) * std::sin(phi),
|
||||
std::sin(theta) * std::sin(phi),
|
||||
std::cos(phi));
|
||||
|
||||
particle::Particle drawn_particle(specie, CylinderCoordinate(
|
||||
blitz::TinyVector<double, 3>(particle_specs[0],
|
||||
particle_specs[1], particle_specs[2])),
|
||||
CartesianVector(v_normal*v_abs), injection_time, weight);
|
||||
|
||||
queue.push_back(drawn_particle);
|
||||
}
|
||||
|
||||
double Injector::timePassed() const {
|
||||
return 1 / activity_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user