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:
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "constants/sim_constants.h"
|
||||
|
||||
bool isEqual(double a, double b) {
|
||||
inline bool isEqual(double a, double b) {
|
||||
return std::abs(a - b) < SimConstants::compare_epsilon;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#define DENSITY_FIELD_H
|
||||
|
||||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
#include "simulation/compare.h"
|
||||
#include "simulation/coordinates.h"
|
||||
#include "simulation/cpu_synchronizer.h"
|
||||
#include "simulation/energy_binning.h"
|
||||
@@ -38,6 +40,10 @@ class DynamicDensityField : public DensityField {
|
||||
double density(const Coordinate& position);
|
||||
double density(const Coordinate& position, double energy_eV);
|
||||
|
||||
double particleNumber();
|
||||
blitz::TinyVector<double, 4> drawPositionAndEnergy(std::mt19937* engine);
|
||||
void setDensityDistribution();
|
||||
|
||||
void resetDynamicDensityField();
|
||||
|
||||
blitz::Array<double, 3> densityArray();
|
||||
@@ -69,12 +75,19 @@ class DynamicDensityField : public DensityField {
|
||||
// num_bin_z: z >= z_max
|
||||
BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
||||
void recalculateDensityArray();
|
||||
void initPositionDistributions();
|
||||
|
||||
blitz::Array<double, 4> time_in_bin_s_;
|
||||
blitz::Array<long int, 4> deleted_particles_;
|
||||
blitz::Array<double, 4> density_per_m3_;
|
||||
blitz::Array<double, 3> bin_volume_m3_;
|
||||
|
||||
std::uniform_real_distribution<double> r_dist_;
|
||||
std::uniform_real_distribution<double> phi_dist_;
|
||||
std::uniform_real_distribution<double> z_dist_;
|
||||
std::piecewise_constant_distribution<double> E_dist_;
|
||||
std::uniform_real_distribution<double> density_dist_;
|
||||
|
||||
const CylinderBinning position_binning_;
|
||||
const EnergyBinning energy_binning_;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
class DriftVelocity;
|
||||
class VelocityDistribution;
|
||||
class DynamicDensityField;
|
||||
|
||||
namespace particle {
|
||||
class Particle;
|
||||
@@ -37,8 +38,16 @@ class Injector {
|
||||
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
||||
|
||||
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
|
||||
const double current_time,
|
||||
const int time_resolution_events);
|
||||
const double current_time);
|
||||
|
||||
void rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
std::shared_ptr<species::TrackedSpecie> specie,
|
||||
std::vector<particle::Particle>& queue,
|
||||
const double weight,
|
||||
const double injection_time);
|
||||
|
||||
void initInjectionTimeDistribution(double delta_t);
|
||||
|
||||
double timePassed() const;
|
||||
|
||||
private:
|
||||
@@ -46,6 +55,7 @@ class Injector {
|
||||
const double activity_;
|
||||
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
||||
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
|
||||
std::uniform_real_distribution<double> injection_time_distribution_;
|
||||
|
||||
particle::Particle rollNewParticle(
|
||||
std::mt19937* engine,
|
||||
|
||||
@@ -34,12 +34,14 @@ class Simulation {
|
||||
void init(Parameter& parameter);
|
||||
void start();
|
||||
void finalize();
|
||||
void processEvents(int events, const int time_resolution_events);
|
||||
void processEvents(int events, int density_events);
|
||||
void processUntilTermination(particle::Particle& particle);
|
||||
|
||||
private:
|
||||
std::vector<particle::Particle> determineInjectedParticles(
|
||||
RandomNumbers* random, const int time_resolution_events);
|
||||
std::vector<particle::Particle> determineInjectedParticles(RandomNumbers* random);
|
||||
std::vector<particle::Particle>
|
||||
determineInjectedDensityParticles(RandomNumbers* random,
|
||||
const int numberParticlesToDraw);
|
||||
|
||||
double meanFreePath(particle::Particle& particle, RandomNumbers* random);
|
||||
|
||||
@@ -69,9 +71,7 @@ class Simulation {
|
||||
std::shared_ptr<SimulationOutput> output_;
|
||||
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
||||
|
||||
std::vector<particle::Particle> queues_[2];
|
||||
int active_queue_;
|
||||
int non_active_queue_;
|
||||
std::vector<particle::Particle> queue_;
|
||||
};
|
||||
|
||||
#endif /* SIMULATION_H */
|
||||
|
||||
Reference in New Issue
Block a user