Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93a51acbda |
@@ -56,10 +56,11 @@ class PoissonSolver {
|
|||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
int solver_intervall,
|
int solver_intervall,
|
||||||
int solver_offset);
|
int solver_offset,
|
||||||
|
bool reset_after_solving);
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 3> charge_density,
|
void solvePotential(const blitz::Array<double, 3> charge_density,
|
||||||
int cpu_sync);
|
int cpu_sync, bool& reset);
|
||||||
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();
|
||||||
@@ -75,6 +76,7 @@ class PoissonSolver {
|
|||||||
const int num_cycles_;
|
const int num_cycles_;
|
||||||
const int solver_intervall_;
|
const int solver_intervall_;
|
||||||
const int solver_offset_;
|
const int solver_offset_;
|
||||||
|
const bool reset_after_solving_;
|
||||||
|
|
||||||
// density binning defined on the cell centers, potential defined
|
// density binning defined on the cell centers, potential defined
|
||||||
// such that it exists on the cell edges so that the azimuthal
|
// such that it exists on the cell edges so that the azimuthal
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class CurrentCollector {
|
|||||||
|
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
|
void resetCurrentCollector();
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class DynamicDensityField : public DensityField {
|
|||||||
double density(const Coordinate& position);
|
double density(const Coordinate& position);
|
||||||
double density(const Coordinate& position, double energy_eV);
|
double density(const Coordinate& position, double energy_eV);
|
||||||
|
|
||||||
|
void resetDynamicDensityField();
|
||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 3> densityArray();
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 4> spectrumArray();
|
||||||
blitz::Array<double, 4> timeInBinArray() const;
|
blitz::Array<double, 4> timeInBinArray() const;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class DeletionLogger {
|
|||||||
void numDeletions(long int new_value, DeletionType type);
|
void numDeletions(long int new_value, DeletionType type);
|
||||||
long int numDeletions(DeletionType type) const;
|
long int numDeletions(DeletionType type) const;
|
||||||
|
|
||||||
|
void resetDeletionLogger();
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class Timer {
|
|||||||
double time() const;
|
double time() const;
|
||||||
void increaseTimestep(double time_s);
|
void increaseTimestep(double time_s);
|
||||||
void setTime(double time_s);
|
void setTime(double time_s);
|
||||||
|
void resetTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double current_time_s_;
|
double current_time_s_;
|
||||||
|
|||||||
@@ -52,9 +52,13 @@ namespace generator {
|
|||||||
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
||||||
{"NumCycles"}));
|
{"NumCycles"}));
|
||||||
|
|
||||||
|
bool reset_after_solving = parameter.boolValue(
|
||||||
|
json_path_append({"PoissonSolver"}, {"ResetAfterSolving"}), false);
|
||||||
|
|
||||||
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
||||||
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
||||||
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset));
|
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset,
|
||||||
|
reset_after_solving));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
int solver_intervall,
|
int solver_intervall,
|
||||||
int solver_offset)
|
int solver_offset,
|
||||||
|
bool reset_after_solving)
|
||||||
: bottom_boundary_(bottom_boundary),
|
: bottom_boundary_(bottom_boundary),
|
||||||
top_boundary_(top_boundary),
|
top_boundary_(top_boundary),
|
||||||
hull_boundary_(hull_boundary),
|
hull_boundary_(hull_boundary),
|
||||||
@@ -34,7 +35,8 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
target_accuracy_(target_accuracy),
|
target_accuracy_(target_accuracy),
|
||||||
num_cycles_(num_cycles),
|
num_cycles_(num_cycles),
|
||||||
solver_intervall_(solver_intervall),
|
solver_intervall_(solver_intervall),
|
||||||
solver_offset_(solver_offset) {
|
solver_offset_(solver_offset),
|
||||||
|
reset_after_solving_(reset_after_solving) {
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
@@ -79,13 +81,16 @@ 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, 0);
|
bool reset;
|
||||||
|
solvePotential(zero_chargedensity, 0, reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 3> charge_density, int cpu_sync) {
|
const blitz::Array<double, 3> charge_density, int cpu_sync,
|
||||||
|
bool& reset) {
|
||||||
if ((cpu_sync % solver_intervall_ != 0) || ((cpu_sync <= solver_offset_)
|
if ((cpu_sync % solver_intervall_ != 0) || ((cpu_sync <= solver_offset_)
|
||||||
&& (cpu_sync > 0))) {
|
&& (cpu_sync > 0))) {
|
||||||
|
reset = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||||
@@ -102,6 +107,7 @@ void PoissonSolver::solvePotential(
|
|||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
} while (it < num_cycles_);
|
} while (it < num_cycles_);
|
||||||
|
reset = reset_after_solving_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solverIteration(
|
void PoissonSolver::solverIteration(
|
||||||
@@ -243,7 +249,7 @@ bool PoissonSolver::converged(
|
|||||||
double normalized_maximum =
|
double normalized_maximum =
|
||||||
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Maximum Differenece normalized by order of magnitude: "
|
message << "Maximum Difference normalized by order of magnitude: "
|
||||||
<< normalized_difference;
|
<< normalized_difference;
|
||||||
DEBUG_LEVEL_0(message.str());
|
DEBUG_LEVEL_0(message.str());
|
||||||
return normalized_difference < target_accuracy_;
|
return normalized_difference < target_accuracy_;
|
||||||
|
|||||||
@@ -240,3 +240,14 @@ blitz::Array<double, 3> CurrentCollector::currentInR() const {
|
|||||||
double CurrentCollector::physicalTime() const {
|
double CurrentCollector::physicalTime() const {
|
||||||
return timer_->time();
|
return timer_->time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CurrentCollector::resetCurrentCollector() {
|
||||||
|
z_negative_crossings = 0.;
|
||||||
|
z_positive_crossings = 0.;
|
||||||
|
|
||||||
|
phi_negative_crossings = 0.;
|
||||||
|
phi_positive_crossings = 0.;
|
||||||
|
|
||||||
|
r_negative_crossings = 0.;
|
||||||
|
r_positive_crossings = 0.;
|
||||||
|
}
|
||||||
@@ -205,6 +205,13 @@ double DynamicDensityField::physicalTime() const {
|
|||||||
return timer_->time();
|
return timer_->time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
|
timer_->resetTime(); // reductive since shared between species
|
||||||
|
time_in_bin_s_ = 0.;
|
||||||
|
deleted_particles_ = 0.;
|
||||||
|
density_per_m3_ = 0.;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -30,3 +30,9 @@ long int DeletionLogger::numDeletions(DeletionType type) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeletionLogger::resetDeletionLogger() {
|
||||||
|
for(auto& pair : num_deletions) {
|
||||||
|
pair.second = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ void Simulation::start() {
|
|||||||
int leftover_events = events_this_cpu;
|
int leftover_events = events_this_cpu;
|
||||||
|
|
||||||
int num_cpu_syncs = 0;
|
int num_cpu_syncs = 0;
|
||||||
|
bool reset = false;
|
||||||
while (leftover_events > 0) {
|
while (leftover_events > 0) {
|
||||||
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events);
|
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events);
|
||||||
SIM_INFO("Leftover events on first cpu: " +
|
SIM_INFO("Leftover events on first cpu: " +
|
||||||
@@ -123,7 +124,7 @@ void Simulation::start() {
|
|||||||
|
|
||||||
SIM_INFO("Poisson step.");
|
SIM_INFO("Poisson step.");
|
||||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||||
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs);
|
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs, reset);
|
||||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||||
|
|
||||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||||
@@ -132,6 +133,20 @@ void Simulation::start() {
|
|||||||
SimulationTimer::eventStartPoint(std::string("Output"));
|
SimulationTimer::eventStartPoint(std::string("Output"));
|
||||||
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
|
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
|
||||||
SimulationTimer::eventStopPoint(std::string("Output"));
|
SimulationTimer::eventStopPoint(std::string("Output"));
|
||||||
|
|
||||||
|
if(reset) {
|
||||||
|
SIM_INFO("Reset density, current fields and deletions.");
|
||||||
|
for(auto& pair : tracked_species_) {
|
||||||
|
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
||||||
|
pair.second->lastSyncDensityField()->resetDynamicDensityField();
|
||||||
|
|
||||||
|
pair.second->currentCollector()->resetCurrentCollector();
|
||||||
|
pair.second->lastSyncCurrentCollector()->resetCurrentCollector();
|
||||||
|
|
||||||
|
pair.second->deletionLogger()->resetDeletionLogger();
|
||||||
|
pair.second->lastSyncDeletionLogger()->resetDeletionLogger();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,3 +13,7 @@ void Timer::increaseTimestep(double time_s) {
|
|||||||
void Timer::setTime(double time_s) {
|
void Timer::setTime(double time_s) {
|
||||||
current_time_s_ = time_s;
|
current_time_s_ = time_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timer::resetTime() {
|
||||||
|
setTime(0.);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user