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

PBC fix bundle #563

Draft
wants to merge 77 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
42319c1
Preliminary changes to support periodic MRA-SCF
JonathonMisiewicz Jan 11, 2024
15b87dc
Fix issues in potential.
JonathonMisiewicz Jan 24, 2024
70ab9df
Change periodic handling in NuclearDensityFunctor
JonathonMisiewicz Jan 24, 2024
c48e4a7
removed unused Molecule::mol_nuclear_charge_density()
evaleev Feb 8, 2024
18d9ccf
Molecule::nuclear_charge_density() can (uniformly) adjust size of the…
evaleev Feb 8, 2024
7fbd9e3
document "default" nuclear model that produces smoothed coulomb poten…
evaleev Feb 8, 2024
f2f0b6d
introduce BoundaryConditions::is_periodic_any
evaleev Feb 8, 2024
b115e80
dox++
evaleev Feb 8, 2024
122a3b4
clean up NuclearDensityFunctor
evaleev Feb 8, 2024
5d162a4
Hotfixes
JonathonMisiewicz Oct 9, 2024
52e28cd
testfilter
JonathonMisiewicz Oct 14, 2024
47d59ba
fixed erfcr example
evaleev Oct 18, 2024
afa1122
testfilter: can only filter out moments in compressed representation
evaleev Oct 18, 2024
084edc6
Truncation of Gaussian expansion of integral kernel in SeparatedConvo…
evaleev Nov 7, 2024
b4c1c54
bump actions/{ccache,checkout} to v4
evaleev Nov 14, 2024
7084146
one more ctor for XCOperator to be able to construct outside SCF/Nemo
evaleev Nov 21, 2024
5d487c4
typos
evaleev Nov 28, 2024
bf94970
factored out BoundaryConditions from funcdefaults.h
evaleev Nov 28, 2024
c5811cb
introduced Key::distsq_{bc,periodic} to compute |l|^2 for periodic an…
evaleev Nov 28, 2024
aba1178
Displacements ctor uses Key::distsq_periodic for PBC
evaleev Nov 28, 2024
602f4d3
FunctionImpl::do_apply : shell-based screening in PBC case computes d…
evaleev Nov 28, 2024
4ae06b0
FunctionImpl::{do_apply,do_apply_directed_screening} : no need to con…
evaleev Nov 29, 2024
9db4790
[stubmpi] implement Gather, Gatherv, and Type_get_extent
evaleev Dec 3, 2024
6ecab21
typos
evaleev Dec 4, 2024
24db345
SeparatedConvolution can deal with mixed boundary conditions (periodi…
evaleev Dec 4, 2024
992195a
introduced array_of_bools, an ergonomic sequence of bools
evaleev Dec 4, 2024
0502f6e
Displacements: periodic displacements are generated according to the …
evaleev Dec 5, 2024
e7c5c1f
introduced array_of_bools::{and,or}_{front,back}
evaleev Dec 5, 2024
e4ce92a
enforce_bc: handle multiple displacements
evaleev Dec 5, 2024
f2bae3e
boundary condition handling switched to array_of_bools
evaleev Dec 5, 2024
5db605c
enforce_in_volume(n,l) takes l by const ref
evaleev Dec 6, 2024
25dea91
FunctionDefaults: boundary conditions set before set_defaults or star…
evaleev Dec 6, 2024
23ec4de
Displacements: generate periodic displacements on the first call, eve…
evaleev Dec 6, 2024
4d1174b
BoundaryConditions: array ctors
evaleev Dec 6, 2024
c89faf4
typo
evaleev Dec 10, 2024
52535a5
Convolution1D: arg really stands for wavenumber
evaleev Dec 10, 2024
fbbceb3
copied Kahan accumulator from MPQC
evaleev Dec 12, 2024
ccbb1e8
GaussianConvolution1D supports range restriction on kernel
evaleev Dec 12, 2024
488a603
testing rang-restricted rnlp (aka trnlp) + cleanup of test_rnlp
evaleev Dec 12, 2024
4967add
typo
evaleev Dec 12, 2024
18c7e19
caching GaussianConvolution1D takes into account bloch-k and D
evaleev Dec 12, 2024
befc1f8
can construct range-restricted versions of integral operators
evaleev Dec 12, 2024
9e92446
fixed Convolution1D::get_issmall for range-restricted case
evaleev Dec 13, 2024
c149748
can construct range-limited operators with range limits specified for…
evaleev Dec 13, 2024
341ccfc
minor cleanup for issmall
evaleev Dec 16, 2024
d0f0227
small test for range-limited rnlij
evaleev Dec 16, 2024
96f3563
bigger test for range-limited rnlij
evaleev Dec 16, 2024
8bd0652
yet bigger test for range-limited rnlij
evaleev Dec 17, 2024
2dfa2f4
typo
evaleev Dec 18, 2024
3f33d06
introduced madness:is_trivially_copyable trait (can be specialized to…
evaleev Dec 18, 2024
2d8e16e
typo
evaleev Dec 21, 2024
d27d486
introduced SeparatedConvolution::get_{k,rank}
evaleev Dec 27, 2024
a69e9b3
Merge branch 'refs/heads/master' into jm/cleanup/nuclear-density-functor
evaleev Dec 27, 2024
d8ae908
typo
evaleev Dec 30, 2024
e1686f4
kernel range restriction of a convolution is encoded by a std::option…
evaleev Dec 31, 2024
862a556
Q: why Convolution1D::nonstandard differs from MRAQC paper appendix?
evaleev Dec 31, 2024
0892d88
missing #includes and fwd decls
evaleev Dec 31, 2024
475fad8
typos
evaleev Jan 1, 2025
9e3e08e
introduced ConvolutionND::lattice_summed() and SeparatedConvolution:…
evaleev Jan 3, 2025
88602d9
Convolution1D: support lattice summation for range-restricted kernels
evaleev Jan 3, 2025
db30822
cleanup FunctionImpl::do_apply to make processing multiple sets of di…
evaleev Jan 3, 2025
42999a1
Displacements minor renames before adding range-related stuff
evaleev Jan 3, 2025
0f1e502
introduced KernelRange
evaleev Jan 5, 2025
d27b3b8
replaced kernel range specification throughout by KernelRange
evaleev Jan 5, 2025
b014f88
test rnlp for erf-restricted Gaussian kernel
evaleev Jan 5, 2025
73b121f
introduced Key::operator[] to access translation's components
evaleev Jan 7, 2025
a1c4a35
typo
evaleev Jan 7, 2025
dc791f1
Key::neighbor variant that accepts Vector of Translations
evaleev Jan 7, 2025
fc281e8
SeparatedConvolution::get_range accessor returns reference to range, …
evaleev Jan 7, 2025
77ecb84
FunctionImpl::do_apply: max distsq returned as std::optional<uint64> …
evaleev Jan 7, 2025
12a6dd1
introduce draft BoxSurfaceDisplacementRange that iterates over finite…
evaleev Jan 7, 2025
7caa96b
FunctionImpl::do_apply: for range restricted kernels include range bo…
evaleev Jan 7, 2025
ae47693
KernelRange: conversion to bool is explicit + introduced equality com…
evaleev Jan 8, 2025
e613c4b
BoundaryConditions::make_{range,range_vector} cleanup
evaleev Jan 8, 2025
963a371
BoxSurfaceDisplacementRange: initial support for NDIM>1, not yes tested
evaleev Jan 8, 2025
07d6a3f
FunctionImpl::do_apply supports NDIM>1 for range-restricted kernels; …
evaleev Jan 8, 2025
2236bd5
BoxSurfaceDisplacementRange filter uses not only displacement and des…
evaleev Jan 8, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
-DMADNESS_BUILD_LIBRARIES_ONLY=${{ matrix.build_type != 'Debug' }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
message("::set-output name=timestamp::${current_date}")

- name: Setup ccache cache files
uses: actions/cache@v1.1.0
uses: actions/cache@v4
with:
path: ${{github.workspace}}/build/.ccache
key: ${{ matrix.config.name }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindLibxc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include(FindPackageHandleStandardArgs)

if(NOT LIBXC_FOUND)

# Set default sarch paths for libxc
# Set default search paths for libxc
if(LIBXC_ROOT_DIR)
set(LIBXC_INCLUDE_DIR ${LIBXC_ROOT_DIR}/include CACHE PATH "The include directory for libxc")
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down
3 changes: 1 addition & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

Welcome to MADNESS
==================
Multiresolution Adaptive Numerical Environment for Scientific Simulation

MADNESS provides a high-level environment for the solution of integral and differential equations in many dimensions using adaptive, fast methods with guaranteed precision based on multi-resolution analysis and novel separated representations. There are three main components to MADNESS. At the lowest level is a new petascale parallel programming environment that increases programmer productivity and code performance/scalability while maintaining backward compatibility with current programming tools such as MPI and Global Arrays. The numerical capabilities built upon the parallel tools provide a high-level environment for composing and solving numerical problems in many (1-6+) dimensions. Finally, built upon the numerical tools are new applications with initial focus upon chemistry, atomic and molecular physics, material science, and nuclear structure.
MADNESS (**M**\ ultiresolution **AD**\ aptive **N**\ umerical **E**\ nvironment for **S**\ cientific **S**\ imulation) provides a high-level environment for the solution of integral and differential equations in many dimensions using adaptive, fast methods with guaranteed precision based on multi-resolution analysis and novel separated representations. There are three main components to MADNESS. At the lowest level is a new petascale parallel programming environment that increases programmer productivity and code performance/scalability while maintaining backward compatibility with current programming tools such as MPI and Global Arrays. The numerical capabilities built upon the parallel tools provide a high-level environment for composing and solving numerical problems in many (1-6+) dimensions. Finally, built upon the numerical tools are new applications with initial focus upon chemistry, atomic and molecular physics, material science, and nuclear structure.



Expand Down
21 changes: 0 additions & 21 deletions src/apps/moldft/preal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,6 @@ class AtomicBasisFunctor : public FunctionFunctorInterface<Q,3> {
}
};

// Functor for the nuclear charge density
class NuclearDensityFunctor : public FunctionFunctorInterface<double,3> {
Molecule molecule;
std::vector<coord_3d> specialpts;
public:
NuclearDensityFunctor(const Molecule& molecule) :
molecule(molecule), specialpts(molecule.get_all_coords_vec()) {}

double operator()(const Vector<double,3>& r) const {
return molecule.mol_nuclear_charge_density(r[0], r[1], r[2]);
}

std::vector<coord_3d> special_points() const{
return specialpts;
}

Level special_level() {
return 15;
}
};

// Functor for the nuclear potential
class MolecularPotentialFunctor : public FunctionFunctorInterface<double,3> {
private:
Expand Down
43 changes: 2 additions & 41 deletions src/apps/moldft/testperiodicdft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <madness/tensor/solvers.h>
#include<madness/chem/molecule.h>
#include<madness/chem/molecularbasis.h>
#include<madness/chem/potentialmanager.h>
#include<madness/chem/xcfunctional.h>

using namespace madness;
Expand Down Expand Up @@ -178,46 +179,6 @@ class AtomicOrbitalFunctor: public FunctionFunctorInterface<double,3> {
std::vector<coord_3d> special_points() const {return specialpt;}
};

class NuclearDensityFunctor : public FunctionFunctorInterface<double,3> {
private:
const Molecule& molecule;
const double R;
std::vector<coord_3d> specialpt;
const int maxR = 1;
public:
NuclearDensityFunctor(const Molecule& molecule, double R)
: molecule(molecule), R(R), specialpt(molecule.get_all_coords_vec())
{}

double operator()(const coord_3d& x) const {
double big = 2*R + 6.0*molecule.smallest_length_scale();
double sum = 0.0;
for (int i=-maxR; i<=+maxR; i++) {
double xx = x[0]+i*R;
if (xx < big && xx > -big) {
for (int j=-maxR; j<=+maxR; j++) {
double yy = x[1]+j*R;
if (yy < big && yy > -big) {
for (int k=-maxR; k<=+maxR; k++) {
double zz = x[2]+k*R;
if (zz < big && zz > -big)
sum += molecule.nuclear_charge_density(x[0]+i*R, x[1]+j*R, x[2]+k*R);
}
}
}
}
}
return sum;
}

std::vector<coord_3d> special_points() const {return specialpt;}

Level special_level() {
return 10;
}

};

class KPeriodicBSHOperator {
private:
double kx, ky, kz;
Expand Down Expand Up @@ -979,7 +940,7 @@ int main(int argc, char** argv) {
aobasis.read_file("sto-3g");

// Nuclear potential
real_function_3d vnuc = real_factory_3d(world).functor(real_functor_3d(new NuclearDensityFunctor(molecule, L))).truncate_mode(0).truncate_on_project();
real_function_3d vnuc = real_factory_3d(world).functor(real_functor_3d(new NuclearDensityFunctor(molecule))).truncate_mode(0).truncate_on_project();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually ρnuc... This variable should probably be renamed. If we really need the memory savings, make it a smart ptr and explicitly clear the memory once we've formed the actual vnuc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually ρnuc... This variable should probably be renamed. If we really need the memory savings, make it a smart ptr and explicitly clear the memory once we've formed the actual vnuc.

double nuclear_charge=vnuc.trace();
if (world.rank() == 0) print("total nuclear charge", nuclear_charge);
vnuc = -1.0*make_coulomb_potential(world, vnuc);
Expand Down
2 changes: 1 addition & 1 deletion src/apps/plot/plot2cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int argc, char** argv) {
std::cout << std::setw(25) << std::left << "\tsilent<bool> " << "silence output - default=false\n";
std::cout << "--------------------------\n";
std::cout << "necessary files:\n";
std::cout << "\tinputfile" << std::setw(25) << "the inputfile for madnesss that should hold the molecular geometry\n";
std::cout << "\tinputfile" << std::setw(25) << "the inputfile for madness that should hold the molecular geometry\n";
std::cout << "\tname.00000" << std::setw(25) << "the madness function file - filename given by plot2cube file=name\n";
std::cout << "--------------------------\n";
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/plot/plot2plane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char** argv) {
std::cout << std::setw(25) << std::left << "\tsilent<bool> " << "silence output - default=false\n";
std::cout << "--------------------------\n";
std::cout << "necessary files:\n";
std::cout << std::setw(25) << std::left << "\tinputfile" << "the inputfile for madnesss that should hold plot parameters.\nE\t\texample:\n";
std::cout << std::setw(25) << std::left << "\tinputfile" << "the inputfile for madness that should hold plot parameters.\nE\t\texample:\n";
std::cout << "\n";
std::cout << "\t\tplot\n";
std::cout << "\t\tplane=x1,x2\n";
Expand Down
4 changes: 3 additions & 1 deletion src/examples/periodic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# src/examples/periodic

set(EXAMPLE_SOURCES
testpercoul)
testpercoul
erfcr
testfilter)

# Create executables for example applications
foreach(example ${EXAMPLE_SOURCES})
Expand Down
2 changes: 1 addition & 1 deletion src/examples/periodic/erfcr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <vector>
#include <cmath>

#include "/home/rjh/Devel/madtran/madness/src/madness/misc/gnuplot.h"
#include <madness/misc/gnuplot.h>

// Gaussian expansion of erfc(a*r)/r accurate to epsilon over [rlo,inf]
// Returns pair [coeffs,expnts]
Expand Down
126 changes: 126 additions & 0 deletions src/examples/periodic/testfilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#include <madness/mra/mra.h>
#include <madness/mra/operator.h>

const double L = 10;

static double gaussian_3d(const madness::coord_3d& r, const double expnt) {
const double x=r[0], y=r[1], z=r[2];
const double coeff = pow(expnt/M_PI, 1.5);
return coeff * exp(-expnt * (x*x + y*y + z*z));
}

static double rho_electronic_3d(const madness::coord_3d& r) { return gaussian_3d(r, 1); }
static double rho_nuclear_3d(const madness::coord_3d& r) { return -gaussian_3d(r, 10000); }

static double rho_gaussian_func_3d(const madness::coord_3d& r) {
return rho_electronic_3d(r) + rho_nuclear_3d(r);
}

// filter out leading order moments up to order k by zeroing out the corresponding coefficients in compressed representation
template<typename T, std::size_t NDIM>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MPQC duplicates this function... Maybe this function can be moved into the core MADNESS namespace? It's a good general-purpose function, and it'd be more maintainable if the thing we test and the thing we use were identical.

void filter_moments_inplace(madness::Function<T,NDIM>& f, const int k, const bool fence=true) {

// can only filter in compressed representation
if (!f.is_compressed()) {
f.compress(fence);
}

auto filter_op = [&](madness::Tensor<T> &coeff) {
if constexpr (NDIM == 3) {
if (k >= 0) {
coeff(0, 0, 0) = 0.;
}
if (k >= 1) {
coeff(1, 0, 0) = 0.;
coeff(0, 1, 0) = 0.;
coeff(0, 0, 1) = 0.;
}
if (k >= 2) {
coeff(2, 0, 0) = 0.;
coeff(0, 2, 0) = 0.;
coeff(0, 0, 2) = 0.;
coeff(1, 1, 0) = 0.;
coeff(1, 0, 1) = 0.;
coeff(0, 1, 1) = 0.;
}
if (k >= 3)
abort();// TODO implement support for higher moments
} else
static_assert("filter_moments_inplace at the moment is implemented for NDIM=3");
};

// on [-L,L] normalized scaling function k is Sqrt[(2 k + 1)/(2 L)] LegendreP[k, x/L]
// the coefficient of x^k in LegendreP[k, x] is 2^(-k) Binomial[2 k, k], hence
// coefficient of x^k in scaling function k is Sqrt[(2 k + 1)/(2 L)] Binomial[2 k, k]/(2 L)^k
// thus if all moments of up to k-1 vanish, k-th moment (=expectation value of x^k) of
// scaling function k is its coefficient times Sqrt[(2 L)/ (2 k + 1)] (2 L)^k / Binomial[2 k, k]
f.unaryop_coeff([&](const madness::Key<NDIM> &key, madness::Tensor<T> &coeff) {
MADNESS_ASSERT(f.is_compressed());
// for compressed form only need 1 node, but public interface does not allow mutable access to the data
if (key == f.get_impl()->key0()) {
filter_op(coeff);
}
},
fence);
}

int main(int argc, char**argv) {
using namespace madness;
{
auto &world = initialize(argc, argv);
startup(world, argc, argv, true);

// Function defaults
int k = 11;
double thresh = 1e-9;
double eps = 1e-9;
FunctionDefaults<3>::set_k(k);
FunctionDefaults<3>::set_cubic_cell(-L / 2, L / 2);
FunctionDefaults<3>::set_thresh(thresh);
FunctionDefaults<3>::set_refine(true);
FunctionDefaults<3>::set_initial_level(2);
FunctionDefaults<3>::set_truncate_mode(1);

Function<double, 3> rho, rhoE, rhoN, V_periodic, V_periodicE, V_periodicN;

{
// moments to filter out (0 = charge, 1 = dipoles, 2 = quadrupoles, >=3 not supported yet)
constexpr int filter_level = 0;
printf("building gaussian diff charge distribution ...\n\n");
std::vector<coord_3d> special_pt{coord_3d(std::array<double,3>{0.0, 0.0, 0.0})};
rho = FunctionFactory<double, 3>(world).special_points(special_pt).initial_level(4).f(rho_gaussian_func_3d);
// rho[E+N] is neutral, so no need to filter out the leading moment, but does not hurt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// rho[E+N] is neutral, so no need to filter out the leading moment, but does not hurt
// rho[E+N] is neutral, so leading moment should already be zero, but does not hurt

filter_moments_inplace(rho, filter_level);
rho.truncate();
rhoE = FunctionFactory<double, 3>(world).special_points(special_pt).initial_level(4).f(rho_electronic_3d);
filter_moments_inplace(rhoE, filter_level);
rhoE.truncate();
rhoN = FunctionFactory<double, 3>(world).special_points(special_pt).initial_level(4).f(rho_nuclear_3d);
filter_moments_inplace(rhoN, filter_level);
rhoN.truncate();

BoundaryConditions<3> bc_periodic(BC_PERIODIC);
SeparatedConvolution<double, 3> pop = CoulombOperator(world, 1e-4, eps, bc_periodic.is_periodic());
printf("applying periodic operator ...\n\n");
V_periodic = apply(pop, rho);
V_periodic.truncate();
V_periodicE = apply(pop, rhoE);
V_periodicE.truncate();
V_periodicN = apply(pop, rhoN);
V_periodicN.truncate();

V_periodic.reconstruct();
V_periodicE.reconstruct();
V_periodicN.reconstruct();
}

double bstep = L / 1000.0;
printf(" z\t\tV_(E+N)[z]\tV_E[z]\t\tV_N[z]\t\tV_E[z]+V_n[z]\trho\t\terror\n");
for (int i = 0; i < 1001; i++) {
double x = -L / 2 + i * bstep;
coord_3d p(std::array<double, 3>{0,0,x});
printf("%.3f\t\t%.8f\t%.8f\t%.8f\t%.8f\t%.8f\t%.8f\n", p[2], V_periodic(p), V_periodicE(p), V_periodicN(p), V_periodicE(p) + V_periodicN(p), rho(p), V_periodic(p) - V_periodicN(p) - V_periodicE(p));
}
}
madness::finalize();
}
2 changes: 1 addition & 1 deletion src/examples/periodic/testpercoul.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char**argv) {
rho.truncate();

BoundaryConditions<3> bc_periodic(BC_PERIODIC);
SeparatedConvolution<double, 3> pop = CoulombOperator(world, 1e-4, eps, bc_periodic);
SeparatedConvolution<double, 3> pop = CoulombOperator(world, 1e-4, eps, bc_periodic.is_periodic());
printf("applying periodic operator ...\n\n");
V_periodic = apply(pop, rho);
V_periodic.truncate();
Expand Down
1 change: 1 addition & 0 deletions src/madness/chem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ set(MADCHEM_SOURCES
oep.cc
pcm.cc
pointgroupsymmetry.cc
potentialmanager.cc
polynomial.cc
SCF.cc
SCFOperators.cc
Expand Down
13 changes: 13 additions & 0 deletions src/madness/chem/SCFOperators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,19 @@ XCOperator<T, NDIM>::XCOperator(World &world, std::string xc_data, const bool sp
xc_args = prep_xc_args(arho, brho);
}

/// custom ctor with the XC functional
template<typename T, std::size_t NDIM>
XCOperator<T, NDIM>::XCOperator(World& world, std::shared_ptr<XCfunctional> xc,
const bool spin_polarized,
const int ispin,
const int nbeta,
const real_function_3d& arho, const real_function_3d& brho,
std::string deriv)
: world(world), dft_deriv(deriv), xc(xc), nbeta(nbeta), ispin(ispin),
extra_truncation(FunctionDefaults<3>::get_thresh() * 0.01) {
xc_args = prep_xc_args(arho, brho);
}

template<typename T, std::size_t NDIM>
XCOperator<T, NDIM>::XCOperator(World &world, const SCF *calc, int ispin, std::string deriv)
: world(world), dft_deriv(deriv), ispin(ispin), extra_truncation(FunctionDefaults<3>::get_thresh() * 0.01) {
Expand Down
8 changes: 8 additions & 0 deletions src/madness/chem/SCFOperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,14 @@ class XCOperator : public SCFOperatorBase<T,NDIM> {
const real_function_3d& arho, const real_function_3d& brho,
std::string deriv="abgv");

/// custom ctor with the XC functional
XCOperator(World& world, std::shared_ptr<XCfunctional> xc,
const bool spin_polarized,
int ispin,
int nbeta,
const real_function_3d& arho, const real_function_3d& brho,
std::string deriv="abgv");

/// ctor with an SCF calculation, will initialize the necessary intermediates
XCOperator(World& world, const SCF* scf, int ispin=0, std::string deriv="abgv");

Expand Down
16 changes: 11 additions & 5 deletions src/madness/chem/atomutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,20 @@ double d2smoothed_potential(double r) {
}


/// Charge density corresponding to smoothed 1/r potential
/// Charge density corresponding to smoothed `1/r` potential

/// Invoke as \c rho(r/c)/c^3 where \c c is the radius of the
/// To obtain the desired density as a function of `r`,
///// \f$
///// \frac{\exp(-\frac{r^2}{c^2}) \left(\frac{5}{2}-\frac{r^2}{c^2}\right)}{\pi ^{3/2} c^3}
///// \f$,
/// invoke as \c smoothed_density(r/c)/c^3 where \c c is the radius of the
/// smoothed volume.
double smoothed_density(double r) {
/// \param rs effective distance, \f$ r_s \equiv r/c \f$ , from the origin of the density
/// \return \f$ \frac{\exp(-r_s^2) \left(\frac{5}{2}- r_s^2 \right)}{\pi^{3/2}} \f$
double smoothed_density(double rs) {
static const double rpithreehalf = std::pow(madness::constants::pi, -1.5);
double rsq = r*r;
return exp(-rsq)*(2.5 - rsq) * rpithreehalf;
double rs2 = rs*rs;
return exp(-rs2)*(2.5 - rs2) * rpithreehalf;
}


Expand Down
Loading
Loading