Bugfixes;
Restarts now reproduce longer Sims
This commit is contained in:
@@ -214,8 +214,9 @@ std::stringstream Hdf5Reader::readEngineString(std::string path) {
|
||||
size_t size = H5Tget_size(dtype);
|
||||
|
||||
if(size != SimConstants::engine_string_length_max) {
|
||||
ERROR("Size of the string is not the required size of 6730, size of string: "
|
||||
+ std::to_string(size));
|
||||
ERROR("Size of the string is not the required size of " +
|
||||
std::to_string(SimConstants::engine_string_length_max) +
|
||||
", size of string: " + std::to_string(size));
|
||||
}
|
||||
DEBUG_LEVEL_3("RestartInfo: " + std::to_string(H5Tdetect_class(dtype, H5T_STRING)));
|
||||
|
||||
|
||||
@@ -113,6 +113,11 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
||||
blitz::Array<long int, 4> deleted_particles = reader_.readD4LongInt(path_to_data);
|
||||
field->restartDeletedParticlesArray(deleted_particles);
|
||||
}
|
||||
|
||||
// set the density distribution and calculate the density
|
||||
{
|
||||
field->setDensityDistribution();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,9 @@ std::shared_ptr<Injector> buildInjector(
|
||||
json_path_append(path_to_injector, {"CreatedSpecies", std::string(key),
|
||||
"CreationVelocityDistribution"}));
|
||||
|
||||
// missing a check if the value is positive
|
||||
info.multiplicity = json_int(json_object_by_path(value, {"Multiplicity"}), 1);
|
||||
ASSERT_POSITIVE(&info.multiplicity, "The multiplicity has to be positive. " +
|
||||
specie_name + " multiplicity: " + std::to_string(info.multiplicity));
|
||||
injector_infos.push_back(info);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ namespace generator {
|
||||
DEBUG_LEVEL_3("Build Restart.");
|
||||
bool do_restart = json_bool(json_object_by_path(object, {"Do"}));
|
||||
if (!do_restart) {
|
||||
DEBUG_LEVEL_3("No Restart desired");
|
||||
DEBUG_LEVEL_0("No Restart desired.");
|
||||
return Restart(false, "", "");
|
||||
}
|
||||
|
||||
std::string filepath = readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||
std::string filepath = readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}))
|
||||
+ ".h5";
|
||||
DEBUG_LEVEL_3("Restart: file path:" + filepath);
|
||||
|
||||
std::string identifier;
|
||||
|
||||
@@ -364,10 +364,18 @@ void PoissonSolver::setPotential(blitz::Array<double, 3>& potential) {
|
||||
out << ". But expected a size of " << potential_.length();
|
||||
ERROR(out.str());
|
||||
}
|
||||
|
||||
// necessary since it's not guaranteed (or even likely) that both arrays
|
||||
// are indexed the same (i.e. potential_ is most likely starting from -1,
|
||||
// while the parameter array is most likely starting from 0)
|
||||
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
||||
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
||||
const int k_offset = potential.lbound(2) - potential_.lbound(2);
|
||||
|
||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||
potential_(i,j,k).value = potential(i,j,k);
|
||||
potential_(i,j,k).value = potential(i + i_offset,j + j_offset,k + k_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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