Removed cpu syncs inbetween a timestep; Changed Density field accordingly
This commit is contained in:
@@ -24,7 +24,6 @@ struct TrackedSpeciesBuilderInfo {
|
|||||||
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
std::shared_ptr<DriftVelocity> drift_velocity;
|
||||||
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
||||||
std::shared_ptr<DynamicDensityField> density_drawing_field;
|
|
||||||
|
|
||||||
double mass_kg;
|
double mass_kg;
|
||||||
double charge_C;
|
double charge_C;
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ class PoissonSolver {
|
|||||||
int num_cycles,
|
int num_cycles,
|
||||||
bool do_solver);
|
bool do_solver);
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 3> charge_density,
|
void solvePotential(const blitz::Array<double, 3> charge_density);
|
||||||
const bool solve);
|
|
||||||
blitz::Array<double, 3> potential();
|
blitz::Array<double, 3> potential();
|
||||||
std::shared_ptr<VectorField> staticElectricField();
|
std::shared_ptr<VectorField> staticElectricField();
|
||||||
const CylinderBinning* densityBinning();
|
const CylinderBinning* densityBinning();
|
||||||
|
|||||||
@@ -21,11 +21,9 @@ class CpuSynchronizer {
|
|||||||
|
|
||||||
void synchronize(
|
void synchronize(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
tracked_species, bool reset);
|
tracked_species);
|
||||||
|
|
||||||
void synchronize(DynamicDensityField* field,
|
void synchronize(DynamicDensityField* field);
|
||||||
DynamicDensityField* density_for_drawing,
|
|
||||||
bool reset);
|
|
||||||
void synchronize(CurrentCollector* collector);
|
void synchronize(CurrentCollector* collector);
|
||||||
void synchronize(DeletionLogger* logger);
|
void synchronize(DeletionLogger* logger);
|
||||||
void synchronize(Timer* timer, Timer* last_sync_timer);
|
void synchronize(Timer* timer, Timer* last_sync_timer);
|
||||||
@@ -36,8 +34,6 @@ class CpuSynchronizer {
|
|||||||
*/
|
*/
|
||||||
void sumToAll(blitz::Array<double, 4>& array,
|
void sumToAll(blitz::Array<double, 4>& array,
|
||||||
blitz::Array<double, 4>& last_sync_array);
|
blitz::Array<double, 4>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<double, 5>& array,
|
|
||||||
blitz::Array<double, 5>& last_sync_array);
|
|
||||||
void sumToAll(blitz::Array<double, 3>& array,
|
void sumToAll(blitz::Array<double, 3>& array,
|
||||||
blitz::Array<double, 3>& last_sync_array);
|
blitz::Array<double, 3>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<long int, 4>& array,
|
void sumToAll(blitz::Array<long int, 4>& array,
|
||||||
@@ -46,6 +42,9 @@ class CpuSynchronizer {
|
|||||||
blitz::Array<long int, 5>& last_sync_array);
|
blitz::Array<long int, 5>& last_sync_array);
|
||||||
void sumToAll(double& value, double& last_sync_value);
|
void sumToAll(double& value, double& last_sync_value);
|
||||||
void sumToAll(long int& value, long int& last_sync_value);
|
void sumToAll(long int& value, long int& last_sync_value);
|
||||||
|
|
||||||
|
// array has to be the delta of the timestep
|
||||||
|
void sumToAll(blitz::Array<double, 5>& array);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CPU_SYNCHRONIZER_H */
|
#endif /* CPU_SYNCHRONIZER_H */
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<Reflector> reflector,
|
std::shared_ptr<Reflector> reflector,
|
||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity,
|
std::shared_ptr<DriftVelocity> drift_velocity);
|
||||||
std::shared_ptr<DynamicDensityField> density_for_drawing);
|
|
||||||
|
|
||||||
DensityField* densityField();
|
DensityField* densityField();
|
||||||
VelocityDistribution* velocityDistribution();
|
VelocityDistribution* velocityDistribution();
|
||||||
@@ -79,8 +78,6 @@ class TrackedSpecie : public Specie {
|
|||||||
DeletionLogger* deletionLogger();
|
DeletionLogger* deletionLogger();
|
||||||
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
||||||
|
|
||||||
DynamicDensityField* densityForDrawing();
|
|
||||||
|
|
||||||
CurrentCollector* currentCollector();
|
CurrentCollector* currentCollector();
|
||||||
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
@@ -102,7 +99,6 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<CurrentCollector> current_collector_;
|
std::shared_ptr<CurrentCollector> current_collector_;
|
||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
||||||
|
|
||||||
std::shared_ptr<DynamicDensityField> density_for_drawing_;
|
|
||||||
// necessary for interactions between TrackedSpecies
|
// necessary for interactions between TrackedSpecies
|
||||||
std::shared_ptr<VelocityDistributionFromDensityField>
|
std::shared_ptr<VelocityDistributionFromDensityField>
|
||||||
velocity_distribution_from_density_;
|
velocity_distribution_from_density_;
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ void Restart::restart(
|
|||||||
for(const auto& pair: species) {
|
for(const auto& pair: species) {
|
||||||
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
||||||
restart_identifier_;
|
restart_identifier_;
|
||||||
restartDrawingDensityField(pair.second->densityForDrawing(), path);
|
restartDrawingDensityField(pair.second->dynamicDensityField(), path);
|
||||||
// pair.second->positionDistributionFromDensity()->setMaximumDensity();
|
// pair.second->positionDistributionFromDensity()->setMaximumDensity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,13 +296,6 @@ void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
|||||||
json_path_append(b.second.path_in_json,
|
json_path_append(b.second.path_in_json,
|
||||||
{"DensityField", "DynamicDensityField"}),
|
{"DensityField", "DynamicDensityField"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
|
||||||
// not the optimal solution! (has to be optimized)
|
|
||||||
b.second.density_drawing_field = buildDynamicDensityField(
|
|
||||||
parameter,
|
|
||||||
json_path_append(b.second.path_in_json,
|
|
||||||
{"DensityField", "DynamicDensityField"}),
|
|
||||||
timer_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +317,7 @@ void SpeciesBuilder::buildSpecies() {
|
|||||||
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
||||||
b.second.mover, b.second.terminator, b.second.reflector,
|
b.second.mover, b.second.terminator, b.second.reflector,
|
||||||
b.second.density_field, b.second.velocity_distribution,
|
b.second.density_field, b.second.velocity_distribution,
|
||||||
b.second.drift_velocity, b.second.density_drawing_field));
|
b.second.drift_velocity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ double Recombination::drawCollisionTime(particle::Particle& particle,
|
|||||||
// const double density = target_->densityField()->density(particle.cylinderPosition());
|
// const double density = target_->densityField()->density(particle.cylinderPosition());
|
||||||
// Use the density for drawing field, since it contains the density of the earlier
|
// Use the density for drawing field, since it contains the density of the earlier
|
||||||
// timestep
|
// timestep
|
||||||
const double density = recombination_target_->densityForDrawing()
|
const double density = recombination_target_->dynamicDensityField()
|
||||||
->density(particle.cylinderPosition());
|
->density(particle.cylinderPosition());
|
||||||
|
|
||||||
// recombination_target_->densityForDrawing()->recalculateDensityArray();
|
// recombination_target_->densityForDrawing()->recalculateDensityArray();
|
||||||
@@ -223,10 +223,10 @@ double Recombination::drawCollisionTime(particle::Particle& particle,
|
|||||||
if(density > 0 && std::isnan(crosssection)) {
|
if(density > 0 && std::isnan(crosssection)) {
|
||||||
std::stringstream msg;
|
std::stringstream msg;
|
||||||
msg << particle.specie()->name() << particle.cartesianPosition().cartesianEntries();
|
msg << particle.specie()->name() << particle.cartesianPosition().cartesianEntries();
|
||||||
msg << " " << recombination_target_->densityForDrawing()->positionBinning()->bin(particle.cylinderPosition().cylinderEntries());
|
msg << " " << recombination_target_->dynamicDensityField()->positionBinning()->bin(particle.cylinderPosition().cylinderEntries());
|
||||||
msg << ": Recombination: density is not nan but the cross section is ";
|
msg << ": Recombination: density is not nan but the cross section is ";
|
||||||
msg << density << ", " << crosssection;
|
msg << density << ", " << crosssection;
|
||||||
msg << recombination_target_->densityForDrawing()->sliceSpectrumArray(particle.cylinderPosition());
|
msg << recombination_target_->dynamicDensityField()->sliceSpectrumArray(particle.cylinderPosition());
|
||||||
ERROR(msg.str());
|
ERROR(msg.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
blitz::Range(density_binning.binIndexMin()(2),
|
blitz::Range(density_binning.binIndexMin()(2),
|
||||||
density_binning.binIndexMax()(2)));
|
density_binning.binIndexMax()(2)));
|
||||||
zero_chargedensity = 0.;
|
zero_chargedensity = 0.;
|
||||||
solvePotential(zero_chargedensity, true);
|
solvePotential(zero_chargedensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 3> charge_density, const bool solve) {
|
const blitz::Array<double, 3> charge_density) {
|
||||||
if (!(do_solver_) || !(solve)) {
|
if (!(do_solver_)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
|
|||||||
@@ -17,14 +17,10 @@ void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array,
|
|||||||
last_sync_array += delta;
|
last_sync_array += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array,
|
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array) {
|
||||||
blitz::Array<double, 5>& last_sync_array) {
|
|
||||||
int size = array.size();
|
int size = array.size();
|
||||||
blitz::Array<double, 5> delta(array.extent());
|
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE,
|
||||||
delta = array - last_sync_array;
|
|
||||||
MPI_Allreduce(MPI_IN_PLACE, delta.data(), size, MPI_DOUBLE,
|
|
||||||
MPI_SUM, MPI_COMM_WORLD);
|
MPI_SUM, MPI_COMM_WORLD);
|
||||||
last_sync_array += delta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array,
|
void CpuSynchronizer::sumToAll(blitz::Array<long int, 4>& array,
|
||||||
@@ -84,19 +80,13 @@ void CpuSynchronizer::synchronize(Timer* timer, Timer* last_sync_timer) {
|
|||||||
last_sync_timer->setTime(last_sync_time_s);
|
last_sync_timer->setTime(last_sync_time_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::synchronize(DynamicDensityField* field,
|
// synchronize density field across cpus and set the
|
||||||
DynamicDensityField* density_for_drawing,
|
// array storing the previous timestep
|
||||||
bool reset) {
|
void CpuSynchronizer::synchronize(DynamicDensityField* field) {
|
||||||
if (field) {
|
if (field) {
|
||||||
sumToAll(field->time_in_bin_s_, field->sync_time_in_bin_s_);
|
sumToAll(field->sync_time_in_bin_s_);
|
||||||
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
||||||
|
field->recalculateDensityArray();
|
||||||
// has to be moved somewhere else i think
|
|
||||||
if (reset) {
|
|
||||||
field->recalculateDensityArray();
|
|
||||||
density_for_drawing->time_in_bin_s_ = field->time_in_bin_s_;
|
|
||||||
density_for_drawing->density_per_m3_ = field->density_per_m3_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +149,12 @@ void CpuSynchronizer::synchronize(DeletionLogger* logger) {
|
|||||||
|
|
||||||
void CpuSynchronizer::synchronize(
|
void CpuSynchronizer::synchronize(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
tracked_species, bool reset) {
|
tracked_species) {
|
||||||
MPI_Barrier(MPI_COMM_WORLD);
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
auto it = tracked_species.begin();
|
auto it = tracked_species.begin();
|
||||||
|
|
||||||
for (auto& pair : tracked_species) {
|
for (auto& pair : tracked_species) {
|
||||||
synchronize(pair.second->dynamicDensityField(),
|
synchronize(pair.second->dynamicDensityField());
|
||||||
pair.second->densityForDrawing(), reset);
|
|
||||||
synchronize(pair.second->currentCollector());
|
synchronize(pair.second->currentCollector());
|
||||||
synchronize(pair.second->deletionLogger());
|
synchronize(pair.second->deletionLogger());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
|||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||||
|
|
||||||
time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
sync_time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
||||||
pitch_angle_bin, energy_bin) += weight;
|
pitch_angle_bin, energy_bin) += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,10 +308,8 @@ blitz::Array<double, 1> DynamicDensityField::sliceTimeInBinArray(
|
|||||||
energy_bin);
|
energy_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resets the field that logs the new density
|
||||||
void DynamicDensityField::resetDynamicDensityField() {
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
//timer_->resetTime(); // time stays global
|
|
||||||
time_in_bin_s_ = 0.;
|
|
||||||
density_per_m3_ = 0.;
|
|
||||||
sync_time_in_bin_s_ = 0.;
|
sync_time_in_bin_s_ = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,10 +139,6 @@ void Simulation::finalize() {
|
|||||||
void Simulation::start() {
|
void Simulation::start() {
|
||||||
SIM_INFO("Starting Simulation.");
|
SIM_INFO("Starting Simulation.");
|
||||||
|
|
||||||
// stride wrt the number of beta decay events per CPU
|
|
||||||
const int event_stride =
|
|
||||||
parameter_.intValue(json_path({"Simulation", "EventStride"}), 1);
|
|
||||||
|
|
||||||
// number of timesteps to be simulated
|
// number of timesteps to be simulated
|
||||||
const int number_timesteps = parameter_.intValue(json_path({"Simulation",
|
const int number_timesteps = parameter_.intValue(json_path({"Simulation",
|
||||||
"NumberTimesteps"}), 1);
|
"NumberTimesteps"}), 1);
|
||||||
@@ -161,18 +157,13 @@ void Simulation::start() {
|
|||||||
injector_->setWeights(time_resolution_events, beta_decay_events);
|
injector_->setWeights(time_resolution_events, beta_decay_events);
|
||||||
|
|
||||||
SIM_INFO("Number of Timesteps: " + std::to_string(number_timesteps));
|
SIM_INFO("Number of Timesteps: " + std::to_string(number_timesteps));
|
||||||
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
SIM_INFO("Number of injected particles per timestep: " + std::to_string(beta_decay_events));
|
||||||
|
|
||||||
int leftover_events_time_resolution = beta_decay_events;
|
|
||||||
|
|
||||||
const double delta_t = time_resolution_events*injector_->timePassed();
|
const double delta_t = time_resolution_events*injector_->timePassed();
|
||||||
|
|
||||||
timer_->setDeltaT(delta_t);
|
timer_->setDeltaT(delta_t);
|
||||||
injector_->initInjectionTimeDistribution(delta_t);
|
injector_->initInjectionTimeDistribution(delta_t);
|
||||||
|
|
||||||
int num_cpu_syncs = 0;
|
|
||||||
bool reset = true;
|
|
||||||
|
|
||||||
timer_->increaseTimestep(delta_t);
|
timer_->increaseTimestep(delta_t);
|
||||||
|
|
||||||
while (timestep < number_timesteps) {
|
while (timestep < number_timesteps) {
|
||||||
@@ -181,10 +172,6 @@ void Simulation::start() {
|
|||||||
out << "Timeinterval: " << timer_->time() << "s.";
|
out << "Timeinterval: " << timer_->time() << "s.";
|
||||||
DEBUG_LEVEL_3(out.str());
|
DEBUG_LEVEL_3(out.str());
|
||||||
#endif
|
#endif
|
||||||
// calculate the number of beta events to be simulated before a
|
|
||||||
// cpu sync is done
|
|
||||||
int events_of_cycle =
|
|
||||||
eventsOfCycle(event_stride, leftover_events_time_resolution);
|
|
||||||
|
|
||||||
#ifdef debug_level1
|
#ifdef debug_level1
|
||||||
DEBUG_LEVEL_1("Events of cycle: " + std::to_string(events_of_cycle));
|
DEBUG_LEVEL_1("Events of cycle: " + std::to_string(events_of_cycle));
|
||||||
@@ -194,14 +181,10 @@ void Simulation::start() {
|
|||||||
|
|
||||||
if(timestep%(std::max(number_timesteps/100, 1)) == 0)
|
if(timestep%(std::max(number_timesteps/100, 1)) == 0)
|
||||||
SIM_INFO("Processing timestep: " + std::to_string(timestep));
|
SIM_INFO("Processing timestep: " + std::to_string(timestep));
|
||||||
#ifdef debug
|
|
||||||
SIM_INFO("Leftover events this timestep this CPU: " +
|
|
||||||
std::to_string(leftover_events_time_resolution));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// process both density and beta events before a cpu synchronization
|
// process both density and beta events before a cpu synchronization
|
||||||
processDensityEvents();
|
processDensityEvents();
|
||||||
processEvents(events_of_cycle);
|
processEvents(beta_decay_events);
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
||||||
@@ -209,10 +192,6 @@ void Simulation::start() {
|
|||||||
std::to_string(leftover_events_time_resolution));
|
std::to_string(leftover_events_time_resolution));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
leftover_events_time_resolution -= events_of_cycle;
|
|
||||||
|
|
||||||
reset = !(leftover_events_time_resolution > 0);
|
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
SIM_INFO("Cpu sync.");
|
SIM_INFO("Cpu sync.");
|
||||||
#endif
|
#endif
|
||||||
@@ -221,58 +200,53 @@ void Simulation::start() {
|
|||||||
// otherwise it would be more difficult to set it... (cpu synchronizer
|
// otherwise it would be more difficult to set it... (cpu synchronizer
|
||||||
// is a friend class of the density field, i.e. has access to the
|
// is a friend class of the density field, i.e. has access to the
|
||||||
// private members)
|
// private members)
|
||||||
cpu_synchronizer_->synchronize(tracked_species_, reset);
|
cpu_synchronizer_->synchronize(tracked_species_);
|
||||||
num_cpu_syncs += 1;
|
timer_->increaseTimestep(delta_t);
|
||||||
|
timestep++;
|
||||||
SimulationTimer::eventStopPoint(std::string("CpuSync"));
|
SimulationTimer::eventStopPoint(std::string("CpuSync"));
|
||||||
|
|
||||||
// can probably be moved into the reset section and therefore
|
|
||||||
// the parameter 'reset' could probably be removed
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
SIM_INFO("Poisson step.");
|
SIM_INFO("Poisson step.");
|
||||||
#endif
|
#endif
|
||||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||||
// only solves the potential anew if 'reset' is true
|
|
||||||
poisson_solver_->solvePotential(chargedensity(), reset);
|
poisson_solver_->solvePotential(chargedensity());
|
||||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||||
|
|
||||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
SIM_INFO("Perform output.");
|
SIM_INFO("Perform output.");
|
||||||
#endif
|
#endif
|
||||||
SimulationTimer::eventStartPoint(std::string("Output"));
|
SimulationTimer::eventStartPoint(std::string("Output"));
|
||||||
// only write inactive queue, obvi not correct if written between timesteps
|
|
||||||
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get(),
|
output_->writeSimulationData(timestep, tracked_species_, poisson_solver_.get(),
|
||||||
random_->engine(), storage_queue_[inactive_storage],
|
random_->engine(), storage_queue_[inactive_storage],
|
||||||
timestep + 1 + injectionGroupOffset);
|
timestep + injectionGroupOffset);
|
||||||
|
|
||||||
SimulationTimer::eventStopPoint(std::string("Output"));
|
SimulationTimer::eventStopPoint(std::string("Output"));
|
||||||
|
|
||||||
SimulationTimer::eventStartPoint("Reset");
|
SimulationTimer::eventStartPoint("Reset");
|
||||||
if(reset) {
|
|
||||||
#if defined(debug_level2) || defined(debug_level3)
|
#if defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG("Number of particles in active storage queue: "
|
DEBUG("Number of particles in active storage queue: "
|
||||||
+ std::to_string(storage_queue_[active_storage].size()));
|
+ std::to_string(storage_queue_[active_storage].size()));
|
||||||
DEBUG("Number of particles in inactive storage queue: "
|
DEBUG("Number of particles in inactive storage queue: "
|
||||||
+ std::to_string(storage_queue_[inactive_storage].size()));
|
+ std::to_string(storage_queue_[inactive_storage].size()));
|
||||||
#endif
|
#endif
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
SIM_INFO("Do resets and increase the timestep for timeresolution.");
|
SIM_INFO("Do resets and increase the timestep for timeresolution.");
|
||||||
#endif
|
#endif
|
||||||
active_storage = (active_storage + 1) % 2;
|
active_storage = (active_storage + 1) % 2;
|
||||||
inactive_storage = (inactive_storage + 1) % 2;
|
inactive_storage = (inactive_storage + 1) % 2;
|
||||||
|
|
||||||
for(auto& pair : tracked_species_) {
|
for(auto& pair : tracked_species_) {
|
||||||
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
||||||
|
|
||||||
pair.second->currentCollector()->resetCurrentCollector();
|
pair.second->currentCollector()->resetCurrentCollector();
|
||||||
|
|
||||||
pair.second->deletionLogger()->resetDeletionLogger();
|
pair.second->deletionLogger()->resetDeletionLogger();
|
||||||
}
|
|
||||||
|
|
||||||
leftover_events_time_resolution = beta_decay_events;
|
|
||||||
|
|
||||||
timer_->increaseTimestep(delta_t);
|
|
||||||
timestep++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationTimer::eventStopPoint("Reset");
|
SimulationTimer::eventStopPoint("Reset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,13 +309,8 @@ void Simulation::processEvents(int events) {
|
|||||||
DEBUG_LEVEL_2("Particles in queue: " +
|
DEBUG_LEVEL_2("Particles in queue: " +
|
||||||
std::to_string(queue_.size()));
|
std::to_string(queue_.size()));
|
||||||
#endif
|
#endif
|
||||||
const int particle_number =
|
particle::Particle particle = queue_.back();
|
||||||
particleNumberFromQueue(queue_.size(), random_.get());
|
queue_.pop_back();
|
||||||
|
|
||||||
// extract particle from queue here, so that an extension of the queue does
|
|
||||||
// not mess up the reference
|
|
||||||
particle::Particle particle = queue_.at(particle_number);
|
|
||||||
queue_.erase(queue_.begin() + particle_number);
|
|
||||||
|
|
||||||
processUntilTermination(particle);
|
processUntilTermination(particle);
|
||||||
}
|
}
|
||||||
@@ -587,9 +556,10 @@ void Simulation::collisionTime(particle::Particle& particle, RandomNumbers* rand
|
|||||||
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
||||||
particle.timeUntilCollision(*min_iterator);
|
particle.timeUntilCollision(*min_iterator);
|
||||||
|
|
||||||
#ifdef debug_level3
|
#ifdef debug
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "collision times:\n[ ";
|
out << "collision times ";
|
||||||
|
out << particle.specie()->name() <<":\n[ ";
|
||||||
|
|
||||||
for(auto& element : collision_times) {
|
for(auto& element : collision_times) {
|
||||||
out << element << " ";
|
out << element << " ";
|
||||||
@@ -598,7 +568,7 @@ void Simulation::collisionTime(particle::Particle& particle, RandomNumbers* rand
|
|||||||
out << "\nmin value: " << *min_iterator;
|
out << "\nmin value: " << *min_iterator;
|
||||||
out << "\nindexNextInteraction: " << particle.indexNextInteraction();
|
out << "\nindexNextInteraction: " << particle.indexNextInteraction();
|
||||||
|
|
||||||
DEBUG_LEVEL_3(out.str());
|
DEBUG(out.str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ TrackedSpecie::TrackedSpecie(
|
|||||||
std::shared_ptr<Reflector> reflector,
|
std::shared_ptr<Reflector> reflector,
|
||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity,
|
std::shared_ptr<DriftVelocity> drift_velocity)
|
||||||
std::shared_ptr<DynamicDensityField> density_for_drawing)
|
|
||||||
: Specie(type, name, mass_kg, charge_C),
|
: Specie(type, name, mass_kg, charge_C),
|
||||||
mover_(mover),
|
mover_(mover),
|
||||||
terminator_(terminator),
|
terminator_(terminator),
|
||||||
@@ -53,16 +52,15 @@ TrackedSpecie::TrackedSpecie(
|
|||||||
deletion_logger_(std::shared_ptr<DeletionLogger>(nullptr)),
|
deletion_logger_(std::shared_ptr<DeletionLogger>(nullptr)),
|
||||||
current_collector_(std::shared_ptr<CurrentCollector>(nullptr)),
|
current_collector_(std::shared_ptr<CurrentCollector>(nullptr)),
|
||||||
drift_velocity_(drift_velocity),
|
drift_velocity_(drift_velocity),
|
||||||
density_for_drawing_(density_for_drawing),
|
|
||||||
velocity_distribution_from_density_(
|
velocity_distribution_from_density_(
|
||||||
std::make_shared<VelocityDistributionFromDensityField>(
|
std::make_shared<VelocityDistributionFromDensityField>(
|
||||||
density_for_drawing, mass_kg)) {}
|
density_field, mass_kg)) {}
|
||||||
|
|
||||||
DensityField* TrackedSpecie::densityField() {
|
DensityField* TrackedSpecie::densityField() {
|
||||||
// return the density field storing the previous timestep, since
|
// return the density field storing the previous timestep, since
|
||||||
// that density is the only one that makes sense for the calculation
|
// that density is the only one that makes sense for the calculation
|
||||||
// of e.g. MFP for Tracked-Tracked interactions
|
// of e.g. MFP for Tracked-Tracked interactions
|
||||||
return density_for_drawing_.get();
|
return density_field_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
VelocityDistribution* TrackedSpecie::velocityDistribution() {
|
VelocityDistribution* TrackedSpecie::velocityDistribution() {
|
||||||
@@ -80,10 +78,6 @@ DynamicDensityField* TrackedSpecie::dynamicDensityField() {
|
|||||||
return density_field_.get();
|
return density_field_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicDensityField* TrackedSpecie::densityForDrawing() {
|
|
||||||
return density_for_drawing_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
Mover* TrackedSpecie::mover() {
|
Mover* TrackedSpecie::mover() {
|
||||||
return mover_.get();
|
return mover_.get();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user