5#ifndef MADNESS_CHEM_GTH_PSEUDOPOTENTIAL_H__INCLUDED
6#define MADNESS_CHEM_GTH_PSEUDOPOTENTIAL_H__INCLUDED
9#include <madness/external/tinyxml/tinyxml.h>
57 const double x = r[0]-
center[0];
const double y = r[1]-
center[1];
const double z = r[2]-
center[2];
58 double rr = std::sqrt(x*x + y*y + z*z);
105 double rsq = x*x + y*y + z*z;
107 if (
rsq > 40.0)
return 0.0;
109 double rr = std::sqrt(
rsq);
114 rval *= std::sqrt(2);
116 else if (
itmp2 == 1) {
119 else if (
itmp2 == 2) {
122 else if (
itmp2 == 3) {
125 else if (
itmp2 == 4) {
128 else if (
itmp2 == 5) {
131 else if (
itmp2 == 6) {
134 else if (
itmp2 == 7) {
139 rval *= (1./2.)*std::sqrt(1./
PI);
142 rval *= std::sqrt(3./4./
PI)*x;
145 rval *= std::sqrt(3./4./
PI)*y;
148 rval *= std::sqrt(3./4./
PI)*z;
155 rval *= (1./4.)*std::sqrt(5./
PI)*(-x*x - y*y + 2*z*z);
158 rval *= (1./2.)*std::sqrt(15./
PI)*(y*z);
161 rval *= (1./2.)*std::sqrt(15./
PI)*(x*z);
164 rval *= (1./2.)*std::sqrt(15./
PI)*(x*y);
167 rval *= (1./4.)*std::sqrt(15./
PI)*(x*x - y*y);
180 double x1 = c1[0];
double y1 = c1[1];
double z1 = c1[2];
181 double x2 = c2[0];
double y2 = c2[1];
double z2 = c2[2];
195 int ii = -1;
int jj = -1;
int kk = -1;
196 for (
int i = 0; i <= 1; i++) {
197 for (
int j = 0; j <= 1; j++) {
198 for (
int k = 0;
k <= 1;
k++) {
199 double x = (i == 0) ? c1[0] : c2[0];
200 double y = (j == 0) ? c1[1] : c2[1];
201 double z = (
k == 0) ? c1[2] : c2[2];
214 if ((
ii < 0) || (
jj < 0) || (
kk < 0))
MADNESS_EXCEPTION(
"GTH_Pseudopotential: failed to find suitable minimum point\n", 0);
215 double x = (
ii == 0) ? c1[0] : c2[0];
216 double y = (
jj == 0) ? c1[1] : c2[1];
217 double z = (
kk == 0) ? c1[2] : c2[2];
226 double* x =
new double[
npts];
227 double* y =
new double[
npts];
228 double* z =
new double[
npts];
229 double*
rsq =
new double[
npts];
230 double*
rr =
new double[
npts];
233 for (
int i = 0; i <
npts; i++) {
237 rsq[i] = x[i]*x[i] + y[i]*y[i] + z[i]*z[i];
238 rr[i] = std::sqrt(
rsq[i]);
246 for (
int i = 0; i <
npts; i++) {
247 fvals[i] *= std::sqrt(2);
250 else if (
itmp2 == 1) {
251 for (
int i = 0; i <
npts; i++) {
252 fvals[i] *=
rr[i]*std::sqrt(2);
255 else if (
itmp2 == 2) {
256 for (
int i = 0; i <
npts; i++) {
260 else if (
itmp2 == 3) {
261 for (
int i = 0; i <
npts; i++) {
265 else if (
itmp2 == 4) {
266 for (
int i = 0; i <
npts; i++) {
270 else if (
itmp2 == 5) {
271 for (
int i = 0; i <
npts; i++) {
275 else if (
itmp2 == 6) {
276 for (
int i = 0; i <
npts; i++) {
280 else if (
itmp2 == 7) {
281 for (
int i = 0; i <
npts; i++) {
287 for (
int i = 0; i <
npts; i++) {
292 for (
int i = 0; i <
npts; i++) {
297 for (
int i = 0; i <
npts; i++) {
302 for (
int i = 0; i <
npts; i++) {
311 for (
int i = 0; i <
npts; i++) {
312 fvals[i] *= (1./4.)*std::sqrt(5./
PI)*(-x[i]*x[i] - y[i]*y[i] + 2*z[i]*z[i])*std::exp(-0.5*(
rsq[i]/
alpha/
alpha));
316 for (
int i = 0; i <
npts; i++) {
321 for (
int i = 0; i <
npts; i++) {
326 for (
int i = 0; i <
npts; i++) {
331 for (
int i = 0; i <
npts; i++) {
332 fvals[i] *= (1./4.)*std::sqrt(15./
PI)*(x[i]*x[i] - y[i]*y[i])*std::exp(-0.5*(
rsq[i]/
alpha/
alpha));
375 f1 =
real_factory_3d(world).functor(functor).truncate_on_project().nofence().truncate_mode(0);
396 std::array<real_tensor,118>
hlij;
397 std::array<real_tensor,118>
klij;
457 if (!
doc.LoadFile()) {
468 if (
strcmp(node->Value(),
"name") == 0) {
469 std::string
name = node->GetText();
470 if (
debug && world.
rank() == 0) std::cout <<
"Loading pseudopotential file " <<
name << std::endl;
472 else if (
strcmp(node->Value(),
"atom") == 0) {
473 const char* symbol = node->Attribute(
"symbol");
477 if (
debug && world.
rank() == 0) std::cout <<
" found atomic pseudopotential " << symbol << std::endl;
479 node->Attribute(
"lmax", &lmax);
480 if (
debug && world.
rank() == 0) std::cout <<
" maximum L is " << lmax << std::endl;
507 t_hlij(0, 0, 1) = -1./2.*std::sqrt(3./5.)*
t_hlij(0, 1, 1);
509 t_hlij(0, 0, 2) = 1./2.*std::sqrt(5./21.)*
t_hlij(0, 2, 2);
511 t_hlij(0, 1, 2) = -1./2.*std::sqrt(100./63.)*
t_hlij(0, 2, 2);
514 t_hlij(1, 0, 1) = -1./2.*std::sqrt(5./7.)*
t_hlij(1, 1, 1);
516 t_hlij(1, 0, 2) = 1./6.*std::sqrt(35./11.)*
t_hlij(1, 2, 2);
518 t_hlij(1, 1, 2) = -1./6.*14./std::sqrt(11.)*
t_hlij(1, 2, 2);
521 t_hlij(2, 0, 1) = -1./2.*std::sqrt(7./9.)*
t_hlij(2, 1, 1);
523 t_hlij(2, 0, 2) = 1./2.*std::sqrt(63./143.)*
t_hlij(2, 2, 2);
525 t_hlij(2, 1, 2) = -1./2.*18./std::sqrt(143.)*
t_hlij(2, 2, 2);
552 unsigned int maxLL = 0;
557 for (
unsigned int iatom = 0; iatom <
natoms; iatom++) {
568 for (
unsigned int iatom = 0; iatom <
natoms; iatom++) {
578 for (
unsigned int j = 1; j <= 3; j++) {
579 for (
unsigned int l = 0; l <=
maxLL; l++) {
580 for (
unsigned int m = 0;
m < 2*
maxLL+1;
m++) {
602 for (
unsigned int iatom = 0; iatom <
natoms; iatom++) {
609 for (
unsigned int i = 1; i <= 3; i++) {
610 for (
int l = 0; l <= maxL; l++) {
611 for (
int m = 0;
m < 2*l+1;
m++) {
613 for (
unsigned int j = 1; j <= 3; j++) {
625 double trantol =
vtol2 / std::min(30.0,
double(
localproj.size()));
630 int nocc = occ.
size();
632 for(
int i = 0;i < nocc;++i){
661 for (
unsigned int iatom = 0; iatom <
natoms; iatom++) {
669 for (
unsigned int l = 0; l <=
maxLL; l++) {
670 for (
unsigned int m = 0;
m < 2*l+1;
m++) {
671 for (
unsigned int i = 1; i <= 3; i++) {
673 for (
unsigned int j = 1; j <= 3; j++) {
double potential(const coord_3d &r)
Definition 3dharmonic.cc:132
unsigned int atomic_number
Atomic number.
Definition molecule.h:63
madness::Vector< double, 3 > get_coords() const
Definition molecule.h:106
bool pseudo_atom
Indicates if this atom uses a pseudopotential.
Definition molecule.h:65
long dim(int i) const
Returns the size of dimension i.
Definition basetensor.h:147
long size() const
Returns the number of elements in the tensor.
Definition basetensor.h:138
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:101
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
Function< T, NDIM > & gaxpy(const T &alpha, const Function< Q, NDIM > &other, const R &beta, bool fence=true)
Inplace, general bi-linear operation in wavelet basis. No communication except for optional fence.
Definition mra.h:1156
const Function< T, NDIM > & compress(bool fence=true) const
Compresses the function, transforming into wavelet basis. Possible non-blocking comm.
Definition mra.h:886
Definition gth_pseudopotential.h:390
std::vector< Function< Q, 3 > > apply_potential(World &world, const real_function_3d &potential, const std::vector< Function< Q, 3 > > &psi, const tensorT &occ, Q &enl)
Definition gth_pseudopotential.h:541
void make_pseudo_potential(World &world)
Definition gth_pseudopotential.h:405
std::array< real_tensor, 118 > klij
Definition gth_pseudopotential.h:397
void reproject(int k, double thresh)
Definition gth_pseudopotential.h:449
real_function_3d vlocalp
Definition gth_pseudopotential.h:398
std::vector< unsigned int > atoms_with_projectors
Definition gth_pseudopotential.h:399
GTHPseudopotential(World &world, Molecule molecule)
Definition gth_pseudopotential.h:403
std::array< real_tensor, 118 > hlij
Definition gth_pseudopotential.h:396
std::array< real_tensor, 118 > localp
Definition gth_pseudopotential.h:394
std::vector< Function< Q, 3 > > apply_potential_simple(World &world, const real_function_3d &potential, const std::vector< Function< Q, 3 > > &psi, const tensorT &occ, Q &enl)
Definition gth_pseudopotential.h:653
void load_pseudo_from_file(World &world, const std::string filename)
Definition gth_pseudopotential.h:453
std::array< real_tensor, 118 > radii
Definition gth_pseudopotential.h:395
real_function_3d vlocalpot()
Definition gth_pseudopotential.h:445
Molecule molecule
Definition gth_pseudopotential.h:393
Definition molecule.h:129
const Atom & get_atom(unsigned int i) const
Definition molecule.cc:502
size_t natom() const
Definition molecule.h:463
Definition gth_pseudopotential.h:73
int itmp
Definition gth_pseudopotential.h:83
static const double gamma_data[17]
Definition gth_pseudopotential.h:92
std::vector< coord_3d > special_points() const final
Override this to return list of special points to be refined more deeply.
Definition gth_pseudopotential.h:350
double t1
Definition gth_pseudopotential.h:84
double alpha
Definition gth_pseudopotential.h:75
std::vector< coord_3d > specialpts
Definition gth_pseudopotential.h:78
ProjRLMFunctor(double alpha, int l, int m, int i, const coord_3d ¢er)
Definition gth_pseudopotential.h:94
double operator()(const coord_3d &r) const final
Definition gth_pseudopotential.h:103
virtual void operator()(const Vector< double *, 3 > &xvals, double *MADNESS_RESTRICT fvals, int npts) const final
Definition gth_pseudopotential.h:224
virtual bool screened(const coord_3d &c1, const coord_3d &c2) const final
Definition gth_pseudopotential.h:177
Level special_level() const final
Override this to change the minimum level of refinement at special points (default is 6)
Definition gth_pseudopotential.h:352
int l
Definition gth_pseudopotential.h:76
double sqrtPI
Definition gth_pseudopotential.h:82
virtual bool supports_vectorized() const final
Does the interface support a vectorized operator()?
Definition gth_pseudopotential.h:90
int m
Definition gth_pseudopotential.h:76
int itmp2
Definition gth_pseudopotential.h:83
coord_3d center
Definition gth_pseudopotential.h:77
Definition gth_pseudopotential.h:357
coord_3d center
Definition gth_pseudopotential.h:361
real_function_3d nlmproj(World &world, int l, int m, int i)
Definition gth_pseudopotential.h:367
ProjRLMStore(const real_tensor &radii, const coord_3d ¢er)
Definition gth_pseudopotential.h:364
real_tensor radii
Definition gth_pseudopotential.h:360
ProjRLMFunctor nlmproj_functor(World &world, int l, int m, int i)
Definition gth_pseudopotential.h:384
int maxL
Definition gth_pseudopotential.h:359
Definition gth_pseudopotential.h:40
double C3
Definition gth_pseudopotential.h:42
double C1
Definition gth_pseudopotential.h:42
double C4
Definition gth_pseudopotential.h:42
double operator()(const coord_3d &r) const final
Definition gth_pseudopotential.h:56
double Zeff
Definition gth_pseudopotential.h:42
double zi
Definition gth_pseudopotential.h:42
double C2
Definition gth_pseudopotential.h:42
coord_3d center
Definition gth_pseudopotential.h:43
Level special_level() const final
Override this to change the minimum level of refinement at special points (default is 6)
Definition gth_pseudopotential.h:68
std::vector< coord_3d > special_points() const final
Override this to return list of special points to be refined more deeply.
Definition gth_pseudopotential.h:66
std::vector< coord_3d > specialpts
Definition gth_pseudopotential.h:44
VLocalFunctor(double Zeff, double zi, double C1, double C2, double C3, double C4, const coord_3d ¢er)
Definition gth_pseudopotential.h:49
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:177
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
WorldGopInterface & gop
Global operations.
Definition world.h:216
double(* f1)(const coord_3d &)
Definition derivatives.cc:55
static bool debug
Definition dirac-hatom.cc:16
double psi(const Vector< double, 3 > &r)
Definition hatom_energy.cc:78
#define final(a, b, c)
Definition lookup3.c:165
#define MADNESS_RESTRICT
Definition mTxmq.h:37
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
Main include file for MADNESS and defines Function interface.
constexpr double pi
Mathematical constant .
Definition constants.h:48
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
static const char * filename
Definition legendre.cc:96
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:758
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions.
Definition vmra.h:336
Tensor< double > tensorT
Definition distpm.cc:21
void compress(World &world, const std::vector< Function< T, NDIM > > &v, bool fence=true)
Compress a vector of functions.
Definition vmra.h:150
std::shared_ptr< FunctionFunctorInterface< double, 3 > > real_functor_3d
Definition functypedefs.h:122
std::vector< real_function_3d > vector_real_function_3d
Definition functypedefs.h:94
unsigned int symbol_to_atomic_number(const std::string &symbol)
Definition atomutil.cc:173
int Level
Definition key.h:59
FunctionFactory< double, 3 > real_factory_3d
Definition functypedefs.h:108
double get_charge_from_file(const std::string filename, unsigned int atype)
Definition gth_pseudopotential.cc:8
Function< TENSOR_RESULT_TYPE(L, R), NDIM > mul_sparse(const Function< L, NDIM > &left, const Function< R, NDIM > &right, double tol, bool fence=true, bool do_make_redundant=true)
Sparse multiplication; the scalar interface redirects to the vector one in vmra.h.
Definition mra.h:1977
Vector< double, 3 > coord_3d
Definition funcplot.h:1042
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition mra.h:2651
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition distpm.cc:46
void gaxpy(const double a, ScalarResult< T > &left, const double b, const T &right, const bool fence=true)
the result type of a macrotask must implement gaxpy
Definition macrotaskq.h:244
static long abs(long a)
Definition tensor.h:219
double Q(double a)
Definition relops.cc:20
static const double PI
Definition relops.cc:12
static const double m
Definition relops.cc:9
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
void e()
Definition test_sig.cc:75
static const int truncate_mode
Definition testcosine.cc:14
const auto npts
Definition testgconv.cc:52