diff --git a/src/madness/mra/operator.h b/src/madness/mra/operator.h index 62a2c84c15e..c1d6a0a381d 100644 --- a/src/madness/mra/operator.h +++ b/src/madness/mra/operator.h @@ -232,7 +232,7 @@ namespace madness { } static inline std::pair,Tensor> - make_coeff_for_operator(World& world, OperatorInfo info, + make_coeff_for_operator(World& world, OperatorInfo& info, const BoundaryConditions& bc=FunctionDefaults::get_bc()) { const Tensor& cell_width = FunctionDefaults<3>::get_cell_width(); @@ -247,8 +247,9 @@ namespace madness { // WARNING! More fine-grained control over the last argument is needed. // This is a hotfix. - if (bc(0,0) == BC_PERIODIC) { + if (info.truncate_lowexp_gaussians.value_or(bc(0,0) == BC_PERIODIC)) { fit.truncate_periodic_expansion(coeff, expnt, cell_width.max(), true); + info.truncate_lowexp_gaussians = true; } return std::make_pair(coeff,expnt); @@ -1013,7 +1014,7 @@ namespace madness { bool doleaves = false) : SeparatedConvolution(world,Tensor(0l),Tensor(0l),info1.lo,info1.thresh,bc,k,doleaves,info1.mu) { info.type=info1.type; - auto [coeff, expnt] =make_coeff_for_operator(world, info1, bc); + auto [coeff, expnt] = make_coeff_for_operator(world, info, bc); rank=coeff.dim(0); ops.resize(rank); initialize(coeff,expnt); diff --git a/src/madness/mra/operatorinfo.h b/src/madness/mra/operatorinfo.h index 80d4d5a65c1..710f63ee74e 100644 --- a/src/madness/mra/operatorinfo.h +++ b/src/madness/mra/operatorinfo.h @@ -57,13 +57,14 @@ std::ostream& operator<<(std::ostream& os, const OpType type) { struct OperatorInfo { OperatorInfo() = default; - OperatorInfo(double mu, double lo, double thresh, OpType type) : mu(mu), lo(lo), thresh(thresh), type(type) { } + OperatorInfo(double mu, double lo, double thresh, OpType type, std::optional truncate = {}) : mu(mu), lo(lo), thresh(thresh), type(type), truncate_lowexp_gaussians(truncate) { } double mu=0.0; ///< some introspection double lo=1.e-5; double thresh=1.e-4; OpType type=OT_UNDEFINED; ///< introspection double hi=-1.0; bool debug=false; + std::optional truncate_lowexp_gaussians; // if given, overrides the default for whether to truncate low-exponent gaussians };