added call to the poisson solver in main loop
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "simulation/random_numbers.h"
|
||||
#include "simulation/reflector.h"
|
||||
#include "simulation/terminator.h"
|
||||
#include "poisson_solver/poisson_solver.h"
|
||||
|
||||
#include "IO/simulation_output.h"
|
||||
|
||||
@@ -26,6 +27,7 @@
|
||||
#include "generators/random_numbers_generator.h"
|
||||
#include "generators/simulation_output_generator.h"
|
||||
#include "generators/species_generator.h"
|
||||
#include "generators/poisson_solver_generator.h"
|
||||
|
||||
#include "tools/simulation_time.h"
|
||||
|
||||
@@ -51,6 +53,9 @@ void Simulation::init(Parameter& parameter) {
|
||||
DEBUG_LEVEL_0("Init random numbers.");
|
||||
random_ = generator::buildRandomNumbers(parameter);
|
||||
|
||||
DEBUG_LEVEL_0("Init poisson solver.");
|
||||
poisson_solver_ = generator::buildPoissonSolver(parameter);
|
||||
|
||||
DEBUG_LEVEL_0("Init output.");
|
||||
output_ = generator::buildSimulationOutput(
|
||||
parameter.jsonObjectFromBase({"Output"}), tracked_species_);
|
||||
@@ -114,8 +119,11 @@ void Simulation::start() {
|
||||
|
||||
SIM_INFO("Poisson step.");
|
||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||
poisson_solver_->solvePotential(chargedensity());
|
||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||
|
||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||
|
||||
SIM_INFO("Perform output.");
|
||||
SimulationTimer::eventStartPoint(std::string("Output"));
|
||||
output_->writeSimulationData(num_cpu_syncs, tracked_species_);
|
||||
@@ -300,3 +308,19 @@ std::vector<particle::Particle> Simulation::determineInjectedParticles(
|
||||
timer_->increaseTimestep(injector_->timePassed());
|
||||
return injector_->rollNewParticles(random->engine());
|
||||
}
|
||||
|
||||
blitz::Array<double,3> Simulation::chargedensity() {
|
||||
//not great but the size and bounds of the density arrays are needed...
|
||||
blitz::Array<double, 3> chargeden(tracked_species_["electron"]->
|
||||
dynamicDensityField()->densityArray().lbound(),
|
||||
tracked_species_["electron"]->dynamicDensityField()->
|
||||
densityArray().extent());
|
||||
chargeden = 0.;
|
||||
|
||||
for (auto& pair : tracked_species_) {
|
||||
chargeden += pair.second->charge_C() * pair.second->dynamicDensityField()->
|
||||
densityArray();
|
||||
}
|
||||
|
||||
return chargeden;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user