Bin based drawing implemented (debug output not
yet removed)
This commit is contained in:
+24
-10
@@ -9,6 +9,7 @@
|
||||
#include "simulation/density_field.h"
|
||||
#include "simulation/velocity_distribution.h"
|
||||
#include "simulation/electromagnetic_field.h"
|
||||
#include "simulation/random_numbers.h"
|
||||
#include <sstream>
|
||||
|
||||
Injector::Injector(
|
||||
@@ -87,18 +88,27 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
std::shared_ptr<species::TrackedSpecie> specie,
|
||||
std::vector<particle::Particle>& queue,
|
||||
std::shared_ptr<MagneticField> magnetic_field,
|
||||
const double weight,
|
||||
const double weight_factor,
|
||||
const double injection_time) {
|
||||
// draw the position
|
||||
CylinderCoordinate position =
|
||||
specie->positionDistributionFromDensity()->drawPosition(engine);
|
||||
blitz::TinyVector<int, 5> index = specie->randomIndex()->index();
|
||||
|
||||
// check if density was empty (i.e. phi value lower than 0)
|
||||
if (position.cylinderEntries()(1) < 0) {
|
||||
DEBUG_LEVEL_3(specie->name() + ": has zero density");
|
||||
std::stringstream out;
|
||||
out << "drawn index: " << index;
|
||||
// DEBUG_LEVEL_1(out.str());
|
||||
const double num_part_in_bin = specie->densityForDrawing()->particleNumber(index);
|
||||
out << "\nnumber of particles (" << specie->name() << ") at index: " << num_part_in_bin;
|
||||
|
||||
if(num_part_in_bin == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// draw the position
|
||||
CylinderCoordinate position =
|
||||
specie->positionDistributionFromDensity()->drawPosition(engine,
|
||||
index(0), index(1), index(2));
|
||||
|
||||
out << "\ndrawn position: " << position.cylinderEntries();
|
||||
|
||||
DEBUG_LEVEL_3("Injected z position: " +
|
||||
std::to_string(position.cylinderEntries()(2)));
|
||||
DEBUG_LEVEL_3("Injected r position: " +
|
||||
@@ -112,16 +122,20 @@ void Injector::drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
if(kinematic::norm(magnetic_field->value(position).
|
||||
cartesianEntries(position)) == 0) {
|
||||
velocity = specie->velocityDistributionFromDensityField()->
|
||||
rollVelocity(position, engine);
|
||||
drawVelocity(index, engine);
|
||||
} else {
|
||||
velocity = specie->velocityDistributionFromDensityField()->
|
||||
rollVelocity(position, engine, magnetic_field);
|
||||
drawVelocity(index, engine, position, magnetic_field);
|
||||
}
|
||||
|
||||
out << "\ndrawn velocity: " << velocity.cartesianEntries();
|
||||
DEBUG_LEVEL_2(out.str());
|
||||
|
||||
particle::Particle drawn_particle(specie, position,
|
||||
velocity, injection_time, weight);
|
||||
velocity, injection_time, weight_factor*num_part_in_bin);
|
||||
|
||||
queue.push_back(drawn_particle);
|
||||
|
||||
}
|
||||
|
||||
double Injector::timePassed() const {
|
||||
|
||||
Reference in New Issue
Block a user