Skip to content

Commit d3af378

Browse files
author
Martin D. Weinberg
committed
Add option to zero out k!=0 coefficients for self_consistent=false
1 parent 92666dc commit d3af378

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/SlabSL.H

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
under the time-dependent basis expansion. For a basis fixed in time to
5757
the initial time: set to false.
5858
59+
@param zero_coefs set to true will zero the coefficients at the
60+
start of the simulation for all k!=0 subspaces. This is useful
61+
for testing the basis expansion with a fixed potential.
62+
5963
@param nint integer number of steps between subsample computations
6064
(default: 0, no subsampling)
6165
@@ -102,7 +106,7 @@ private:
102106
int nmaxx, nmaxy, nmaxz;
103107
double zmax, hslab;
104108

105-
bool no_even = false, no_odd = false;
109+
bool no_even = false, no_odd = false, zero_coefs = true;
106110

107111
int imx, imy, imz, jmax, nnmax;
108112
double dfac, last=-std::numeric_limits<double>::max();

src/SlabSL.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ SlabSL::valid_keys = {
2424
"no_odd",
2525
"samplesz",
2626
"self_consistent",
27+
"zero_coefs",
2728
"orthochk",
2829
"cachename"
2930
};
@@ -204,6 +205,11 @@ void SlabSL::initialize()
204205
} else
205206
self_consistent = true;
206207

208+
if (conf["zero_coefs"]) {
209+
zero_coefs = conf["zero_coefs"].as<bool>();
210+
} else
211+
zero_coefs = true;
212+
207213
if (conf["nint"]) {
208214
nint = conf["nint"].as<int>();
209215
if (nint > 0) computeSubsample = true;
@@ -455,7 +461,19 @@ void SlabSL::determine_coefficients(void)
455461
//
456462
if (not self_consistent and firstime_coef) {
457463
if (multistep==0 or mlevel==multistep) {
458-
expcofF = expccof[0];
464+
if (zero_coefs) {
465+
expcofF = expccof[0].generate([this](const Eigen::array<Eigen::Index, 3>& coords) {
466+
// Keep the data at (nmaxx+1, nmaxy+1, z)
467+
if (coords[0] == this->nmaxx+1 && coords[1] == this->nmaxy+1) {
468+
return this->expccof[0](coords);
469+
}
470+
// Zero out everything else
471+
return std::complex<double>(0.0, 0.0);
472+
});
473+
} else {
474+
expcofF = expccof[0];
475+
}
476+
459477
firstime_coef = false;
460478
}
461479
}

0 commit comments

Comments
 (0)