Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add cusp correction based on atomic orbitals #4901

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 123 additions & 9 deletions src/Numerics/GaussianBasisSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,54 @@
}
};

bool hasShortRangeCusp = false;
real_type src_rcut = 0.0;
real_type src_alpha;
real_type src_a;
real_type src_c;
real_type src_cp;
real_type src_bp;
real_type src_d0;
real_type src_d1;
real_type src_d2;
real_type src_d3;
real_type src_d4;
real_type src_d5;
real_type src_delta = 0.0;

// The short-ranged cusp is intended to be used with transform="yes" and
// so it only implements the function value and first derivative at the
// smallest grid endpoint (which is assumed to not be in the interpolation region)

real_type evalShortRangeCusp(real_type r)

Check warning on line 107 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L107

Added line #L107 was not covered by tests
{
//real_type val = src_a * std::exp(-src_alpha * r) + src_c;
real_type val = src_a * std::exp(-src_alpha * r) + src_bp * r + src_cp;

Check warning on line 110 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L110

Added line #L110 was not covered by tests
return val;
}

real_type evalShortRangeInterp(real_type r)

Check warning on line 114 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L114

Added line #L114 was not covered by tests
{
//real_type val = src_a * std::exp(-src_alpha * r) + src_c;
real_type d0 = src_d0;
real_type d1 = src_d1;
real_type d2 = src_d2;
real_type d3 = src_d3;
real_type d4 = src_d4;
real_type d5 = src_d5;
real_type rc = src_rcut;
real_type x = r - rc;
real_type val = d5 * std::pow(x, 5) + d4 * std::pow(x, 4) + d3 * x * x * x + d2 * x * x + d1 * x + d0;
return val;

Check warning on line 126 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L117-L126

Added lines #L117 - L126 were not covered by tests
}

real_type evalShortRangeCusp_df(real_type r)

Check warning on line 129 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L129

Added line #L129 was not covered by tests
{
//real_type dval = -src_alpha * src_a * std::exp(-src_alpha * r);
real_type dval = -src_alpha * src_a * std::exp(-src_alpha * r) + src_bp;

Check warning on line 132 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L132

Added line #L132 was not covered by tests
return dval;
}

///Boolean
bool Normalized;
real_type L;
Expand Down Expand Up @@ -113,10 +161,21 @@
real_type r2 = r * r;
typename std::vector<BasicGaussian>::const_iterator it(gset.begin());
typename std::vector<BasicGaussian>::const_iterator it_end(gset.end());
while (it != it_end)
if (r < src_rcut)
{
res += (*it).f(r2);
++it;
res = evalShortRangeCusp(r);

Check warning on line 166 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L166

Added line #L166 was not covered by tests
}
else if (r < src_rcut + src_delta)
{
res = evalShortRangeInterp(r);

Check warning on line 170 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L170

Added line #L170 was not covered by tests
}
else
{
while (it != it_end)
{
res += (*it).f(r2);
++it;
}
}
return res;
}
Expand All @@ -126,10 +185,17 @@
real_type r2 = r * r;
typename std::vector<BasicGaussian>::const_iterator it(gset.begin());
typename std::vector<BasicGaussian>::const_iterator it_end(gset.end());
while (it != it_end)
if (r < src_rcut)
{
res += (*it).df(r, r2);
++it;
res = evalShortRangeCusp_df(r);

Check warning on line 190 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L190

Added line #L190 was not covered by tests
}
else
{
while (it != it_end)
{
res += (*it).df(r, r2);
++it;
}
}
return res;
}
Expand All @@ -139,10 +205,17 @@
Y = 0.0;
real_type rr = r * r;
typename std::vector<BasicGaussian>::iterator it(gset.begin()), it_end(gset.end());
while (it != it_end)
if (r < src_rcut)
{
Y += (*it).f(rr);
++it;
Y = evalShortRangeCusp(r);
}
else
{
while (it != it_end)
{
Y += (*it).f(rr);
++it;
}
}
return Y;
}
Expand Down Expand Up @@ -274,6 +347,8 @@
if (myComm.rank() == 0)
{
hin.read(NbRadFunc, "NbRadFunc");
hasShortRangeCusp = hin.is_group("shortrangecusp");
app_log() << "Has short range cusp = " << hasShortRangeCusp << std::endl;
hin.push("radfunctions");
}
myComm.bcast(NbRadFunc);
Expand Down Expand Up @@ -308,6 +383,45 @@
if (myComm.rank() == 0)
hin.pop();

if (hasShortRangeCusp)
{
if (myComm.rank() == 0)
{
hin.push("shortrangecusp");
hin.read(src_rcut, "rcut");
hin.read(src_alpha, "alpha");
hin.read(src_a, "a");
//hin.read(src_c, "c");
hin.read(src_bp, "bp");
hin.read(src_cp, "cp");
hin.read(src_d0, "d0");
hin.read(src_d1, "d1");
hin.read(src_d2, "d2");
hin.read(src_d3, "d3");
hin.read(src_d4, "d4");
hin.read(src_d5, "d5");
hin.read(src_delta, "delta");
app_log() << " short range cusp rcut = " << src_rcut << " alpha = " << src_alpha << " a = " << src_a
<< " src_cp = " << src_cp << " delta = " << src_delta << std::endl;
app_log() << " d0 = " << src_d0 << " d1 = " << src_d1 << " d2 = " << src_d2 << " d3 = " << src_d3
<< " d4 = " << src_d4 << " d5 = " << src_d5 << std::endl;
hin.pop();

Check warning on line 408 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L404-L408

Added lines #L404 - L408 were not covered by tests
}
myComm.bcast(hasShortRangeCusp);
myComm.bcast(src_rcut);
myComm.bcast(src_alpha);
myComm.bcast(src_a);
myComm.bcast(src_bp);
myComm.bcast(src_cp);
myComm.bcast(src_d0);
myComm.bcast(src_d1);
myComm.bcast(src_d2);
myComm.bcast(src_d3);
myComm.bcast(src_d4);
myComm.bcast(src_d5);
myComm.bcast(src_delta);

Check warning on line 422 in src/Numerics/GaussianBasisSet.h

View check run for this annotation

Codecov / codecov/patch

src/Numerics/GaussianBasisSet.h#L410-L422

Added lines #L410 - L422 were not covered by tests
}

return true;
}
} // namespace qmcplusplus
Expand Down
Loading
Loading