Bugfixes;
Restarts now reproduce longer Sims
This commit is contained in:
@@ -248,6 +248,8 @@ blitz::TinyVector<double, 4> DynamicDensityField::drawPositionAndEnergy(
|
||||
|
||||
density_in_random_cell = density(CylinderCoordinate(
|
||||
blitz::TinyVector<double, 3> (random_r, random_phi, random_z)));
|
||||
DEBUG_LEVEL_3("Density in drawn cell: " + std::to_string(density_in_random_cell));
|
||||
DEBUG_LEVEL_3("drawn density: " + std::to_string(random_n));
|
||||
} while (random_n >= density_in_random_cell);
|
||||
|
||||
const blitz::TinyVector<int, 3> position_bin =
|
||||
@@ -343,7 +345,7 @@ void DynamicDensityField::restartTimeInBin(blitz::Array<double, 4> time_in_bin)
|
||||
out << " for time_in_bin array";
|
||||
ERROR(out.str());
|
||||
}
|
||||
time_in_bin_s_ = time_in_bin.copy();
|
||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
||||
}
|
||||
|
||||
void DynamicDensityField::restartDeletedParticlesArray(
|
||||
@@ -355,7 +357,7 @@ void DynamicDensityField::restartDeletedParticlesArray(
|
||||
out << " for deleted_particles array";
|
||||
ERROR(out.str());
|
||||
}
|
||||
deleted_particles_ = deleted_particles.copy();
|
||||
deleted_particles_ = deleted_particles.copy().reindex(deleted_particles_.lbound());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -37,7 +37,14 @@ MaxwellBoltzmann::MaxwellBoltzmann(double temperature_K)
|
||||
}
|
||||
|
||||
double MaxwellBoltzmann::rollEnergy(std::mt19937* engine) {
|
||||
return distribution_(*engine);
|
||||
double value = distribution_(*engine);
|
||||
// this makes (the test case) reproduceable through restart
|
||||
// but it does impact the efficiency of the drawing (simple test
|
||||
// resultet in about an increase of 50% for the function call)
|
||||
// however, i think that that time increse is almost negligible
|
||||
// compared to the rest of the operations in the simulation
|
||||
distribution_.reset();
|
||||
return value;
|
||||
}
|
||||
|
||||
Constant::Constant(double constant_eV) : constant_eV_(constant_eV) {
|
||||
|
||||
@@ -260,11 +260,21 @@ void Simulation::processEvents(int events, int density_events, int cpu_syncs) {
|
||||
|
||||
} else {
|
||||
DEBUG_LEVEL_2("Current density event: " +
|
||||
std::to_string(current_density_event));
|
||||
std::to_string(current_density_event));
|
||||
//maybe use a different event name?
|
||||
SimulationTimer::eventStartPoint(std::string("DensityParticleInjection"));
|
||||
new_particles = determineInjectedDensityParticles(random_.get(), density_events, current_density_event);
|
||||
SimulationTimer::eventStopPoint(std::string("DensityParticleInjection"));
|
||||
#if defined debug_level3
|
||||
for(auto& particle : new_particles) {
|
||||
std::stringstream output_ss;
|
||||
output_ss << particle.specie()->name() << " with velocity (cart): ";
|
||||
output_ss << particle.velocity().cartesianEntries();
|
||||
output_ss << " and position (cart)";
|
||||
output_ss << particle.position().cartesianEntries();
|
||||
DEBUG_LEVEL_3(output_ss.str());
|
||||
}
|
||||
#endif
|
||||
current_density_event += 1;
|
||||
}
|
||||
if(new_particles.empty())
|
||||
@@ -442,6 +452,9 @@ std::vector<particle::Particle> Simulation::determineInjectedDensityParticles(
|
||||
}
|
||||
const double injection_time = timer_->time() - timer_->getDeltaT();
|
||||
for(auto& pair: tracked_species_) {
|
||||
// not ideal, gets recalculated each time a new particle is drawn from the density,
|
||||
// which does not change except after a timestep, but think the rejection method is
|
||||
// much more time consuming anyways... might optimize in the future
|
||||
// particle number of the denstiy, i.e. the integral over the density
|
||||
const double particleNumberDensity =
|
||||
pair.second->densityForDrawing()->particleNumber();
|
||||
|
||||
Reference in New Issue
Block a user