Bin based drawing implemented (debug output not
yet removed)
This commit is contained in:
@@ -48,6 +48,8 @@ class DynamicDensityField : public DensityField {
|
||||
|
||||
// return the particle number stored in the density of this object
|
||||
double particleNumber();
|
||||
// return the particle number at the given index
|
||||
double particleNumber(blitz::TinyVector<int, 5> index);
|
||||
|
||||
// returns true if the old pitch angle and the new pitch angle are in different bins
|
||||
// of the pitch angle binning
|
||||
|
||||
@@ -46,6 +46,12 @@ class PositionDistributionFromDensity {
|
||||
|
||||
// draw a position from the density provided at construction using the rejection method
|
||||
CylinderCoordinate drawPosition(std::mt19937* engine);
|
||||
|
||||
// draw a position uniformly distributed within the bin of the given index
|
||||
// (note that the r-dependence of the particle number in a uniform density distribution
|
||||
// is not incorporated)
|
||||
CylinderCoordinate drawPosition(std::mt19937* engine, int r_idx, int phi_idx,
|
||||
int z_idx);
|
||||
// sets the maximum density value needed for the rejection method
|
||||
// should not be called frequently, since during each call the density field is
|
||||
// recalculated from scratch by the DynamicDensityField object
|
||||
|
||||
@@ -46,14 +46,14 @@ class Injector {
|
||||
// the new particles are then appened to the vector queue
|
||||
// the magnetic field is necessary for the determination of the direction of the
|
||||
// injected particles
|
||||
// the weight scales the time a particle contributes to a certain bin
|
||||
// the weight_factor scales the time a particle contributes to a certain bin
|
||||
// and the injection time specifies the time the particle is injected (has to be
|
||||
// between T, T+\DeltaT)
|
||||
void drawNewParticleFromDensityField(std::mt19937* engine,
|
||||
std::shared_ptr<species::TrackedSpecie> specie,
|
||||
std::vector<particle::Particle>& queue,
|
||||
std::shared_ptr<MagneticField> field,
|
||||
const double weight,
|
||||
const double weight_factor,
|
||||
const double injection_time);
|
||||
|
||||
void initInjectionTimeDistribution(double delta_t);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
#include "blitz/array.h"
|
||||
|
||||
class RandomNumbers {
|
||||
public:
|
||||
RandomNumbers(int seed);
|
||||
@@ -19,4 +21,31 @@ class RandomNumbers {
|
||||
std::uniform_real_distribution<double> real_distribution_;
|
||||
};
|
||||
|
||||
// class to handle a random walk through a density field, where every
|
||||
// bin is visited exactly once
|
||||
class RandomIndex {
|
||||
public:
|
||||
// num_bins: contains the number of bins of all dimensions of a
|
||||
// density binning (order: radial, azimuthal, longitudinal,
|
||||
// pitch angle, energy)
|
||||
RandomIndex(blitz::TinyVector<int, 5> num_bins);
|
||||
|
||||
// get the next index
|
||||
blitz::TinyVector<int, 5> index();
|
||||
|
||||
// check if all bins have been visited
|
||||
bool visited_all();
|
||||
|
||||
// create a new random order and reset the check if all bins have been visited
|
||||
void reshuffle(std::mt19937* engine);
|
||||
|
||||
private:
|
||||
const blitz::TinyVector<int, 5> num_bins_;
|
||||
|
||||
std::vector<size_t> one_dimensional_indices_;
|
||||
|
||||
size_t total_bin_number_;
|
||||
size_t current_index_in_vector_;
|
||||
};
|
||||
|
||||
#endif /* RANDOM_NUMBERS_H */
|
||||
|
||||
@@ -38,7 +38,7 @@ class Simulation {
|
||||
// at the 0th timestep
|
||||
void processEvents(int events, const double beta_particle_weight);
|
||||
|
||||
void processDensityEvents(int events, const double weight_factor);
|
||||
void processDensityEvents(int particles_per_bin, const double weight_factor);
|
||||
void processUntilTermination(particle::Particle& particle);
|
||||
|
||||
private:
|
||||
@@ -48,7 +48,8 @@ class Simulation {
|
||||
RandomNumbers* random,
|
||||
const double weight_factor,
|
||||
const int current,
|
||||
std::map<std::string, double>& particleNumbers);
|
||||
std::map<std::string, double>& particleNumbers,
|
||||
bool& all_bins_done);
|
||||
|
||||
double meanFreePath(particle::Particle& particle, RandomNumbers* random,
|
||||
std::vector<double>& macroscopic_cross_sections_m);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "simulation/parameter.h"
|
||||
|
||||
class RandomIndex;
|
||||
class Mover;
|
||||
class Terminator;
|
||||
class Reflector;
|
||||
@@ -91,6 +92,9 @@ class TrackedSpecie : public Specie {
|
||||
// getter for the raw pointer to the VelocityDistributionFromDensityField object
|
||||
VelocityDistributionFromDensityField* velocityDistributionFromDensityField();
|
||||
|
||||
// getter for the raw pointer to the RandomIndex object
|
||||
RandomIndex* randomIndex();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DynamicDensityField> density_field_;
|
||||
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
||||
@@ -109,6 +113,8 @@ class TrackedSpecie : public Specie {
|
||||
position_distribution_from_density_;
|
||||
std::shared_ptr<VelocityDistributionFromDensityField>
|
||||
velocity_distribution_from_density_;
|
||||
|
||||
std::shared_ptr<RandomIndex> random_index_;
|
||||
};
|
||||
|
||||
class BackgroundSpecie : public Specie {
|
||||
|
||||
@@ -55,6 +55,15 @@ class VelocityDistributionFromDensityField : public VelocityDistribution {
|
||||
CartesianVector rollVelocity(
|
||||
const Coordinate& position, std::mt19937* engine,
|
||||
std::shared_ptr<MagneticField> magnetic_field);
|
||||
|
||||
// return a velocity vector drawn uniformly in the bin specifed by index
|
||||
CartesianVector drawVelocity(const blitz::TinyVector<int, 5> index,
|
||||
std::mt19937* engine);
|
||||
CartesianVector drawVelocity(const blitz::TinyVector<int, 5> index,
|
||||
std::mt19937* engine,
|
||||
const Coordinate& position,
|
||||
std::shared_ptr<MagneticField> magnetic_field);
|
||||
|
||||
private:
|
||||
// mass of the species of which the density field is a part of
|
||||
const double mass_kg_;
|
||||
|
||||
Reference in New Issue
Block a user