small fixes and cosmetic changes
This commit is contained in:
@@ -79,6 +79,9 @@ void CpuSynchronizer::synchronize(DynamicDensityField* field,
|
||||
if (reset) {
|
||||
density_for_drawing->time_in_bin_s_ = field->time_in_bin_s_;
|
||||
density_for_drawing->deleted_particles_ = field->deleted_particles_;
|
||||
// try setting the distribution for drawing the density here, since ideally it
|
||||
// the density array and the distribution only have to be set once
|
||||
density_for_drawing->setDensityDistribution();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,19 +227,18 @@ blitz::TinyVector<double, 4> DynamicDensityField::drawPositionAndEnergy(
|
||||
std::mt19937* engine) {
|
||||
// if the density is empty, then return a TinyVector filled with 0s as
|
||||
// an indiction of that (probably not the best solution)
|
||||
recalculateDensityArray();
|
||||
|
||||
// stuff below not optimal, since it's done for every particle that is drawn,
|
||||
// but maybe not certain that otherwise the density is right...
|
||||
// recalculateDensityArray();
|
||||
if (isEqual(blitz::max(density_per_m3_), 0.)) {
|
||||
DEBUG_LEVEL_3("Density is empty");
|
||||
return blitz::TinyVector<double, 4> (0,0,0,0);
|
||||
}
|
||||
setDensityDistribution();
|
||||
// setDensityDistribution();
|
||||
double random_r, random_z, random_phi, random_E, random_n;
|
||||
double density_in_random_cell;
|
||||
|
||||
// random_r = 0.01;
|
||||
// random_phi = 0.;
|
||||
// random_z = 1.;
|
||||
// draw random position (independent of the Energy)
|
||||
do {
|
||||
DEBUG_LEVEL_3("Missed.");
|
||||
random_r = std::sqrt(r_dist_(*engine));
|
||||
@@ -327,7 +326,7 @@ void DynamicDensityField::resetDynamicDensityField() {
|
||||
|
||||
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
||||
// make sure that the timer can only be restarted once (per dynamicDensityField object)
|
||||
// probably not necessary, but whatever
|
||||
// probably not necessary, but whatever...
|
||||
if(timer_restarted_) {
|
||||
return;
|
||||
}
|
||||
@@ -344,11 +343,7 @@ void DynamicDensityField::restartTimeInBin(blitz::Array<double, 4> time_in_bin)
|
||||
out << " for time_in_bin array";
|
||||
ERROR(out.str());
|
||||
}
|
||||
std::stringstream out;
|
||||
out << "Before: " << time_in_bin_s_;
|
||||
time_in_bin_s_ = time_in_bin.copy();
|
||||
out << "After: " << time_in_bin_s_;
|
||||
// DEBUG_LEVEL_0(out.str());
|
||||
}
|
||||
|
||||
void DynamicDensityField::restartDeletedParticlesArray(
|
||||
|
||||
@@ -80,7 +80,6 @@ void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
const double injection_time) {
|
||||
blitz::TinyVector<double, 4> particle_specs =
|
||||
specie->densityForDrawing()->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) {
|
||||
@@ -97,7 +96,7 @@ void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
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,
|
||||
// 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),
|
||||
@@ -105,11 +104,11 @@ void Injector::rollNewParticleFromDensityField(std::mt19937* engine,
|
||||
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);
|
||||
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);
|
||||
queue.push_back(drawn_particle);
|
||||
}
|
||||
|
||||
double Injector::timePassed() const {
|
||||
|
||||
@@ -128,7 +128,10 @@ void Simulation::start() {
|
||||
|
||||
const double delta_t = time_resolution_events*injector_->timePassed();
|
||||
|
||||
if(delta_t != timer_->getDeltaT()) {
|
||||
// if delta_t of the timer after creation and potential restart is 0, then
|
||||
// it's indicative of no restart having occured (a simulation with a delta_t
|
||||
// of 0 would not be sensible)
|
||||
if(timer_->getDeltaT() != 0 && delta_t != timer_->getDeltaT()) {
|
||||
std::stringstream out;
|
||||
out << "Old delta t: " << timer_->getDeltaT();
|
||||
out << "; new delta t: " << delta_t;
|
||||
@@ -448,7 +451,6 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
||||
}
|
||||
if (current == 0) {
|
||||
DEBUG_LEVEL_0("particle number " + pair.second->name() + ": " + std::to_string(particleNumberDensity));
|
||||
// DEBUG_LEVEL_0("weight: " + std::to_string(particleNumberDensity/numberParticlesToDraw));
|
||||
}
|
||||
injector_->rollNewParticleFromDensityField(random->engine(),
|
||||
pair.second,
|
||||
|
||||
Reference in New Issue
Block a user