Changed initializtion of potential-grid, included
a variable for minimum cycles before first poisson solution
This commit is contained in:
@@ -3,15 +3,23 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
enum class GeometryPositioning {
|
||||||
|
bottom,
|
||||||
|
top,
|
||||||
|
hull,
|
||||||
|
inside
|
||||||
|
};
|
||||||
class Geometry {
|
class Geometry {
|
||||||
public:
|
public:
|
||||||
virtual bool isInside(const Coordinate& position) const = 0;
|
virtual bool isInside(const Coordinate& position) const = 0;
|
||||||
|
virtual GeometryPositioning isWhere(const Coordinate& position) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cylinder : public Geometry {
|
class Cylinder : public Geometry {
|
||||||
public:
|
public:
|
||||||
Cylinder(double radius, double height);
|
Cylinder(double radius, double height);
|
||||||
bool isInside(const Coordinate& position) const;
|
bool isInside(const Coordinate& position) const;
|
||||||
|
GeometryPositioning isWhere(const Coordinate& position) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double radius_;
|
const double radius_;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Azimuthal": {
|
"Azimuthal": {
|
||||||
"NumberOfBins": 1
|
"NumberOfBins": 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -590,7 +590,8 @@
|
|||||||
},
|
},
|
||||||
"Simulation": {
|
"Simulation": {
|
||||||
"SimulatedEvents": 1,
|
"SimulatedEvents": 1,
|
||||||
"EventStride": 1
|
"EventStride": 1,
|
||||||
|
"PoissonOffset": 0
|
||||||
},
|
},
|
||||||
"Output": {
|
"Output": {
|
||||||
"folder": "output",
|
"folder": "output",
|
||||||
|
|||||||
@@ -33,22 +33,29 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
num_cycles_(num_cycles) {
|
num_cycles_(num_cycles) {
|
||||||
// set inner values
|
// set inner values
|
||||||
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) - 1; ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
for (int k = potential_.lbound(2); k <= potential_.ubound(2);
|
||||||
++k) {
|
++k) {
|
||||||
potential_(i,j,k).type = BoundaryType::no_boundary;
|
|
||||||
potential_(i,j,k).value = 0.;
|
|
||||||
|
|
||||||
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
||||||
i * stepsize(0), j * stepsize(1), k * stepsize(2)));
|
i * stepsize(0), j * stepsize(1), k * stepsize(2)));
|
||||||
// does not make sense, either resize the potential array or include
|
|
||||||
// check which boundary it is and use the global boundary condition
|
switch(geometry_->isWhere(position)) {
|
||||||
// or throw an error, because otherwise there should be an error with the density binning
|
case GeometryPositioning::bottom:
|
||||||
if (!geometry_->isInside(position)) {
|
potential_(i,j,k) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
||||||
//DEBUG_LEVEL_0("Binning is larger than the Geometry.");
|
break;
|
||||||
potential_(i,j,k).type = BoundaryType::no_boundary;
|
case GeometryPositioning::top:
|
||||||
potential_(i,j,k).value = 0.;
|
potential_(i,j,k) = {top_boundary_.type, top_boundary_.boundary_value};
|
||||||
|
break;
|
||||||
|
case GeometryPositioning::hull:
|
||||||
|
potential_(i,j,k) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
||||||
|
break;
|
||||||
|
case GeometryPositioning::inside:
|
||||||
|
potential_(i,j,k) = {BoundaryType::no_boundary, 0.};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ERROR("Something went terribly wrong. Position is nowhere.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
for (auto& electrode : electrodes_) {
|
for (auto& electrode : electrodes_) {
|
||||||
if (electrode->isOnElectrode(position)) {
|
if (electrode->isOnElectrode(position)) {
|
||||||
@@ -59,25 +66,6 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//does not yet make sense. Should be the boundaries for the boundary
|
|
||||||
// of the geometry, right now it's the boundary of the potential array
|
|
||||||
// set global boundary
|
|
||||||
PotentialGridPoint tempGridPoint{};
|
|
||||||
tempGridPoint.type = bottom_boundary_.type;
|
|
||||||
tempGridPoint.value = bottom_boundary_.boundary_value;
|
|
||||||
potential_(blitz::Range::all(), blitz::Range::all(), potential_.lbound(2)) =
|
|
||||||
tempGridPoint; //hopefully by value and not by reference...
|
|
||||||
|
|
||||||
tempGridPoint.type = top_boundary_.type;
|
|
||||||
tempGridPoint.value = top_boundary_.boundary_value;
|
|
||||||
potential_(blitz::Range::all(), blitz::Range::all(), potential_.ubound(2)) =
|
|
||||||
tempGridPoint;
|
|
||||||
|
|
||||||
tempGridPoint.type = hull_boundary_.type;
|
|
||||||
tempGridPoint.value = hull_boundary_.boundary_value;
|
|
||||||
potential_(potential_.ubound(0), blitz::Range::all(), blitz::Range::all()) =
|
|
||||||
tempGridPoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solverIteration(
|
void PoissonSolver::solverIteration(
|
||||||
@@ -158,6 +146,9 @@ bool PoissonSolver::converged(
|
|||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
||||||
++k) {
|
++k) {
|
||||||
|
if(potential_(i,j,k).type != BoundaryType::no_boundary) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// special calculation for r=0
|
// special calculation for r=0
|
||||||
//Note: the value \phi_{i,j+Nj/2,k} as the replacement of
|
//Note: the value \phi_{i,j+Nj/2,k} as the replacement of
|
||||||
|
|||||||
@@ -9,3 +9,17 @@ bool Cylinder::isInside(const Coordinate& position) const {
|
|||||||
return (cylinder_position(0) < radius_) && (cylinder_position(2) < height_) &&
|
return (cylinder_position(0) < radius_) && (cylinder_position(2) < height_) &&
|
||||||
(cylinder_position(2) > 0);
|
(cylinder_position(2) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GeometryPositioning Cylinder::isWhere(const Coordinate& position) const {
|
||||||
|
const blitz::TinyVector<double, 3> cylinder_position =
|
||||||
|
position.cylinderEntries();
|
||||||
|
if(cylinder_position(0) >= radius_) {
|
||||||
|
return GeometryPositioning::hull;
|
||||||
|
} else if (cylinder_position(2) <= 0) {
|
||||||
|
return GeometryPositioning::bottom;
|
||||||
|
} else if (cylinder_position(2) >= height_) {
|
||||||
|
return GeometryPositioning::top;
|
||||||
|
} else {
|
||||||
|
return GeometryPositioning::inside;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ void Simulation::start() {
|
|||||||
parameter_.intValue(json_path({"Simulation", "EventStride"}), 1);
|
parameter_.intValue(json_path({"Simulation", "EventStride"}), 1);
|
||||||
const int total_simulated_events =
|
const int total_simulated_events =
|
||||||
parameter_.intValue(json_path({"Simulation", "SimulatedEvents"}), 1);
|
parameter_.intValue(json_path({"Simulation", "SimulatedEvents"}), 1);
|
||||||
|
// Minimum number of cpu syncs before the potential is done the first time
|
||||||
|
// afterwards the potential is recalculated every cpu sync (maybe change to a stride)
|
||||||
|
const int poisson_offset =
|
||||||
|
parameter_.intValue(json_path({"Simulation", "PoissonOffset"}), 0);
|
||||||
SIM_INFO("Total simulated events: " + std::to_string(total_simulated_events));
|
SIM_INFO("Total simulated events: " + std::to_string(total_simulated_events));
|
||||||
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
SIM_INFO("Simulated events before cpu sync: " + std::to_string(event_stride));
|
||||||
const int events_this_cpu = eventsThisCpu(total_simulated_events);
|
const int events_this_cpu = eventsThisCpu(total_simulated_events);
|
||||||
@@ -119,7 +123,9 @@ 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());
|
if(num_cpu_syncs > poisson_offset) {
|
||||||
|
poisson_solver_->solvePotential(chargedensity());
|
||||||
|
}
|
||||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||||
|
|
||||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||||
|
|||||||
Reference in New Issue
Block a user