21#include <boost/math/constants/constants.hpp>
33 const std::string& element) {
34 std::vector<double> r;
41 r.push_back(0.25 * BSradius);
42 r.push_back(0.5 * BSradius);
43 r.push_back(1.0 * BSradius);
44 r.push_back(4.5 * BSradius);
45 }
else if (RowType == 2) {
46 r.push_back(0.1667 * BSradius);
47 r.push_back(0.5 * BSradius);
48 r.push_back(0.9 * BSradius);
49 r.push_back(3.5 * BSradius);
50 }
else if (RowType == 3) {
51 r.push_back(0.1 * BSradius);
52 r.push_back(0.4 * BSradius);
53 r.push_back(0.8 * BSradius);
54 r.push_back(2.5 * BSradius);
56 throw std::runtime_error(
57 "EulerMaclaurinGrid::CalculatePruningIntervals:Pruning unsupported for "
66 std::map<std::string, min_exp>::iterator it;
67 for (
const QMAtom& atom : atoms) {
68 std::string name = atom.getElement();
74 double range_max = std::numeric_limits<double>::min();
75 double decaymin = std::numeric_limits<double>::max();
76 Index lvalue = std::numeric_limits<Index>::min();
77 const std::vector<const AOShell*> shells =
81 for (
const AOShell* shell : shells) {
83 if (shell->getMinDecay() < decaymin) {
84 decaymin = shell->getMinDecay();
88 if (range > range_max) {
89 this_atom.
alpha = decaymin;
91 this_atom.
range = range;
104 overlap.
Fill(aobasis);
107 std::vector<Index> idxstart;
110 for (
Index size : idxsize) {
111 idxstart.push_back(start);
115 for (
Index i = 0; i < atoms.
size(); ++i) {
116 const QMAtom& atom_a = atoms[i];
117 Index a_start = idxstart[i];
118 Index a_size = idxsize[i];
119 double range_max = std::numeric_limits<double>::min();
123 const Eigen::Vector3d& pos_a = atom_a.
getPos();
125 for (
Index j = 0; j < atoms.
size(); ++j) {
129 const QMAtom& atom_b = atoms[j];
130 Index b_start = idxstart[j];
131 Index b_size = idxsize[j];
132 const Eigen::Vector3d& pos_b = atom_b.
getPos();
134 Eigen::MatrixXd overlapblock =
135 overlap.
Matrix().block(a_start, b_start, a_size, b_size);
137 double s_max = overlapblock.cwiseAbs().maxCoeff();
144 double dist = (pos_b - pos_a).norm();
148 range += (shift_2g + dist);
149 if (range > range_max) {
162 const std::string& gridtype) {
170std::map<std::string, GridContainers::radial_grid>
173 const std::string& type) {
176 std::map<std::string, GridContainers::radial_grid> result;
184 const std::string& type,
const std::pair<std::string, min_exp>& element) {
187 double cutoff = element.second.range;
188 result.
radius = Eigen::VectorXd::Zero(np);
189 result.
weight = Eigen::VectorXd::Zero(np);
192 (log(1.0 - std::pow((1.0 +
double(np)) / (2.0 +
double(np)), 3)));
193 double factor = 3.0 / (1.0 + double(np));
195 for (
Index i = 0; i < np; i++) {
196 double q = double(i + 1) / (double(np) + 1.0);
197 double r = -alpha * std::log(1.0 - std::pow(q, 3));
198 double w = factor * alpha * r * r / (1.0 - std::pow(q, 3)) * std::pow(q, 2);
214 double increment = 0.5;
216 while (increment > 0.01) {
218 if (residual > eps) {
225 increment = 0.5 * increment;
239 const double pi = boost::math::constants::pi<double>();
244 double expo = std::sqrt(alpha) * cutoff;
246 value = 0.5 * std::sqrt(pi / alpha) * std::erfc(expo);
249 double exponent = alpha * cutoff * cutoff;
250 if (exponent > 500.0) {
254 valexp = std::exp(-exponent);
255 value = valexp / 2.0 / alpha;
257 for (
Index i = ilo + 2; i <= l; i += 2) {
258 value = (double(i - 1) * value + std::pow(cutoff, i - 1) * valexp) / 2.0 /
265 const std::string& type) {
266 if (type ==
"medium") {
268 }
else if (type ==
"coarse") {
270 }
else if (type ==
"xcoarse") {
272 }
else if (type ==
"fine") {
274 }
else if (type ==
"xfine") {
277 throw std::runtime_error(
"Grid type " + type +
" is not implemented");
Container to hold Basisfunctions for all atoms.
const std::vector< const AOShell * > getShellsofAtom(Index AtomId) const
const std::vector< Index > & getFuncPerAtom() const
void Fill(const AOBasis &aobasis) final
const Eigen::MatrixXd & Matrix() const
std::vector< double > CalculatePruningIntervals(const std::string &element)
std::map< std::string, GridContainers::radial_grid > CalculateAtomicRadialGrids(const AOBasis &aobasis, const QMMolecule &atoms, const std::string &type)
std::map< std::string, Index > pruning_set_
void FillElementRangeMap(const AOBasis &aobasis, const QMMolecule &atoms, double eps)
Index getGridParameters(const std::string &element, const std::string &type)
std::map< std::string, Index > FineGrid
GridContainers::radial_grid CalculateRadialGridforAtom(const std::string &type, const std::pair< std::string, min_exp > &element)
double DetermineCutoff(double alpha, Index l, double eps)
std::map< std::string, double > Accuracy
std::map< std::string, Index > CoarseGrid
void CalculateRadialCutoffs(const AOBasis &aobasis, const QMMolecule &atoms, const std::string &gridtype)
std::map< std::string, min_exp > element_ranges_
void RefineElementRangeMap(const AOBasis &aobasis, const QMMolecule &atoms, double eps)
double CalcResidual(double alpha, Index l, double cutoff)
std::map< std::string, Index > XcoarseGrid
std::map< std::string, double > BraggSlaterRadii_
double RadialIntegral(double alpha, Index l, double cutoff)
std::map< std::string, Index > MediumGrid
std::map< std::string, Index > XfineGrid
const Eigen::Vector3d & getPos() const
const std::string & getElement() const
base class for all analysis tools