reduced size of potential and electric field grids
This commit is contained in:
@@ -59,6 +59,7 @@ class PoissonSolver {
|
||||
void solvePotential(const blitz::Array<double, 3> charge_density);
|
||||
blitz::Array<double, 3> potential();
|
||||
std::shared_ptr<VectorField> staticElectricField();
|
||||
const CylinderBinning* densityBinning();
|
||||
|
||||
private:
|
||||
GlobalBoundary bottom_boundary_;
|
||||
@@ -66,7 +67,7 @@ class PoissonSolver {
|
||||
GlobalBoundary hull_boundary_;
|
||||
std::shared_ptr<Geometry> geometry_;
|
||||
std::vector<std::shared_ptr<Electrode>> electrodes_;
|
||||
CylinderBinning density_binning_;
|
||||
const CylinderBinning density_binning_;
|
||||
double target_accuracy_;
|
||||
int num_cycles_;
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
||||
density_binning_(density_binning),
|
||||
potential_(blitz::Array<PotentialGridPoint, 3>(
|
||||
blitz::Range(density_binning.binIndexMin()(0),
|
||||
density_binning.binIndexMax()(0)+1),
|
||||
density_binning.binIndexMax()(0)),
|
||||
blitz::Range(density_binning.binIndexMin()(1),
|
||||
density_binning.binIndexMax()(1)), // the azimuthal direction is periodic
|
||||
blitz::Range(density_binning.binIndexMin()(2),
|
||||
density_binning.binIndexMax()(2)+1))),
|
||||
blitz::Range(density_binning.binIndexMin()(2) + 1,
|
||||
density_binning.binIndexMax()(2)))),
|
||||
electrodes_(electrodes),
|
||||
target_accuracy_(target_accuracy),
|
||||
num_cycles_(num_cycles) {
|
||||
@@ -249,22 +249,14 @@ blitz::Array<double, 3> PoissonSolver::potential() {
|
||||
|
||||
blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||
const blitz::Array<double, 3> density) {
|
||||
if((potential_.extent(0) - 1 != density.extent(0)) ||
|
||||
(potential_.extent(1) != density.extent(1)) ||
|
||||
(potential_.extent(2) - 1 != density.extent(2))) {
|
||||
ERROR("Extent of the cylinder binning and the provided chargedensity do not match.");
|
||||
}
|
||||
//probably include a check for the lowerbound of the provided chargedensity
|
||||
//coincides with the one of the potential (and by that extent the cylinder binning)
|
||||
|
||||
// adapted from the external poisson solver (SDS: \\lsdf02.urz.uni-heidelberg.de\SD19H002\karl\src\tools\analysis_jkellerer)
|
||||
blitz::Array<double, 3> interpolatedDensity(potential_.lbound(), potential_.extent());
|
||||
interpolatedDensity = 0.;
|
||||
|
||||
//center values
|
||||
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0)-1; ++i) {
|
||||
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0); ++i) {
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
for(int k = potential_.lbound(2)+1; k <= potential_.ubound(2)-1; ++k) {
|
||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||
interpolatedDensity(i, j, k) = (
|
||||
density(i-1, j , k-1) + density(i, j , k-1) +
|
||||
density(i-1, j , k ) + density(i, j , k ))/4.;
|
||||
@@ -285,31 +277,13 @@ blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||
}
|
||||
|
||||
//might not work that way (if not needs a loop)
|
||||
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /= potential_.extent(1);
|
||||
|
||||
//values for k = k_max (i.e. the open boundary)
|
||||
fixedIndex = potential_.ubound(2);
|
||||
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0)-1; ++i) {
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
interpolatedDensity(i, j, fixedIndex) = (
|
||||
density(i-1, j , fixedIndex-1) +
|
||||
density(i , j , fixedIndex-1) )/4.;
|
||||
}
|
||||
}
|
||||
|
||||
//value where the axis and the open boundary meet
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
interpolatedDensity(potential_.lbound(0), blitz::Range::all(), fixedIndex) +=
|
||||
(density(potential_.lbound(0), j , fixedIndex-1))/(potential_.extent(1));
|
||||
}
|
||||
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /=
|
||||
potential_.extent(1);
|
||||
|
||||
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
||||
std::to_string(blitz::max(interpolatedDensity)));
|
||||
//for r=r_max and k=k_min do not use an interpolation, since there's assumed
|
||||
//to be an absorbing, metallic wall, which leads to those values being 0 always
|
||||
//however(!) right now. it would be possible that the global boundary at those
|
||||
//positions is not a metallic(i.e. dirichlet) boundary --> would need to include
|
||||
//a check for the type of boundary and adjust the interpolation accordingly
|
||||
//for r=r_max, k=k_min and k=k_max do not use an interpolation,
|
||||
//since no boundary cell needs the information about its density value
|
||||
return interpolatedDensity;
|
||||
}
|
||||
|
||||
@@ -322,6 +296,7 @@ std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
||||
blitz::Array<double, 3> Ez(potential_.lbound(), Eextent);
|
||||
|
||||
Ephi = 0.;
|
||||
std::stringstream out;
|
||||
//do calculation of E from the potential and interpolation to
|
||||
//cell center at the same time
|
||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
@@ -358,6 +333,8 @@ std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
||||
}
|
||||
}
|
||||
}
|
||||
out << "Er: \n" << Er << "\n Ez: \n" << Ez;
|
||||
DEBUG(out.str());
|
||||
// whether the VectorField object uses the E-field
|
||||
// at the correct position is not certain
|
||||
return std::shared_ptr<VectorField>(
|
||||
@@ -380,5 +357,8 @@ bool RearWall::isOnElectrode(const Coordinate& position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const CylinderBinning* PoissonSolver::densityBinning() {
|
||||
return &density_binning_;
|
||||
}
|
||||
//PotentialGridPoint::PotentialGridPoint(BoundaryType _type, double _value): type(_type), value(_value) {};
|
||||
|
||||
Reference in New Issue
Block a user