MADNESS 0.10.1
corepotential.h
Go to the documentation of this file.
1/*
2 This file is part of MADNESS.
3
4 Copyright (C) 2007,2010 Oak Ridge National Laboratory
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 For more information please contact:
21
22 Robert J. Harrison
23 Oak Ridge National Laboratory
24 One Bethel Valley Road
25 P.O. Box 2008, MS-6367
26
27 email: harrisonrj@ornl.gov
28 tel: 865-241-3937
29 fax: 865-572-0680
30
31
32 $Id$
33*/
34
35#ifndef MADNESS_CHEM_COREPOTENTIAL_H__INCLUDED
36#define MADNESS_CHEM_COREPOTENTIAL_H__INCLUDED
37
38/// \file corepotential.h
39/// \brief Declaration of core potential related class
40
42#include <madness/constants.h>
44#include <madness/world/print.h>
45#include <map>
46#include <set>
47#include <vector>
48#include <string>
49#include <cmath>
50#include <iostream>
51#include <sstream>
52using std::cout;
53using std::endl;
54using std::vector;
55
56namespace madness {
57
58/// Represents a core potential
59
60/// General Core Potential is able to write down as following form:
61/// \f$ U(r) = \sum_k A_k r^(n_k-2) exp(-alpha_k r^2) \sum_m |Y_lm \rangle \langle Y_lm| \f$
62/// CorePotential holds these parameters (l,n,A,alpha)
63///
64/// Note: CorePotential::eval() currently ignores `l'.
65/// (It means `\f$\sum_m |Y_lm \rangle \langle Y_lm|\f$' is always `1'.)
67 std::vector<int> l; ///< Angular momentum = 0, 1, 2, ...
68 std::vector<int> n;
69 std::vector<double> A;
70 std::vector<double> alpha;
71 double eprec, rcut0, rcut;
72
73 CorePotential() : l(), n(), A(), alpha() {};
74 CorePotential(const std::vector<int>& l,
75 const std::vector<int>& n,
76 const std::vector<double>& A,
77 const std::vector<double>& alpha)
78 : l(l), n(n), A(A), alpha(alpha), eprec(1e-4), rcut0(1.0), rcut(1.0) {};
79
80 double eval(double r) const;
81
82 double eval_derivative(double xi, double r) const;
83
84 std::string to_string () const;
85
86 template <typename Archive>
87 void serialize(Archive& ar) {
88 ar & l & n & A & alpha & eprec & rcut0 & rcut;
89 }
90};
91
93 double Bc;
94 int type;
95 vector<double> coeff, expnt;
96 double rsqmax;
97
98 CoreOrbital() : Bc(0), type(0), coeff(), expnt(), rsqmax(0.0) {}
100 const std::vector<double>& coeff,
101 const std::vector<double>& expnt,
102 double Bc)
104 {
105 double minexpnt = expnt[0];
106 for (unsigned int i=1; i<expnt.size(); ++i)
107 minexpnt = std::min(minexpnt,expnt[i]);
108 rsqmax = 18.4/minexpnt;
109 };
110
111 double eval_radial(double rsq) const;
112
113 double eval_radial_derivative(double rsq, double xi) const;
114
115 double eval_spherical_harmonics(int m, double x, double y, double z, double& dp, int axis) const;
116
117 double eval(int m, double rsq, double x, double y, double z) const;
118
119 double eval_derivative(int m, int axis, double xi, double rsq, double x, double y, double z) const;
120
121 template <typename Archive>
122 void serialize(Archive& ar) {
123 ar & Bc & type & rsqmax;
124 ar & coeff & expnt;
125 }
126};
127
128struct AtomCore {
129 unsigned int atomic_number;
130 unsigned int ncore;
131 std::vector<CoreOrbital> orbital;
133
135
136 inline unsigned int n_orbital() const { return ncore; };
137
138 template <typename Archive>
139 void serialize(Archive& ar) {
140 ar & atomic_number & ncore;
141 ar & potential;
142 for (std::vector<CoreOrbital>::iterator it=orbital.begin(); it != orbital.end(); ++it) {
143 ar & (*it);
144 }
145 }
146};
147
149 static const double fc;
150 std::string core_type; ///< core potential type (eg. mcp)
151 std::string guess_filename; ///< filename of initial guess density data
152 std::map<unsigned int,AtomCore> atom_core;
153 ///< core potential data mapped atn to potential
154
155public:
160
162 read_file(filename, std::set<unsigned int>(), eprec);
163 }
164
165 inline bool is_defined(const unsigned int atn) const {
166 return (atom_core.find(atn) != atom_core.end());
167 }
168
169 inline unsigned int n_core_orb(const unsigned int atn) const {
170 return (*(atom_core.find(atn))).second.n_orbital();
171 }
172
173 inline unsigned int n_core_orb_base(const unsigned int atn) const {
174 return (*(atom_core.find(atn))).second.orbital.size();
175 }
176
177 inline std::string guess_file() const { return guess_filename; }
178
179 AtomCore get_atom_core(unsigned int atn) const {
180 return atom_core.find(atn)->second;
181 }
182
183 CorePotential get_potential(unsigned int atn) const {
184 return atom_core.find(atn)->second.potential;
185 }
186
187 inline unsigned int get_core_l(unsigned int atn, unsigned int core) const {
188 return get_atom_core(atn).orbital[core].type;
189 }
190
191 inline double get_core_bc(unsigned int atn, unsigned int core) const {
192 return get_atom_core(atn).orbital[core].Bc*fc/2;
193 }
194
195 inline double core_eval(unsigned int atn, unsigned int core, int m, double rsq, double x, double y, double z) const {
196 return get_atom_core(atn).orbital[core].eval(m, rsq, x, y, z);
197 }
198
199 inline double core_derivative(unsigned int atn, unsigned int core, int m, int axis, double xi, double rsq, double x, double y, double z) const {
200 return get_atom_core(atn).orbital[core].eval_derivative(m, axis, xi, rsq, x, y, z);
201 }
202
203 double potential(unsigned int atn, double r) const {
204 AtomCore ac = (*(atom_core.find(atn))).second;
205 return ac.potential.eval(r);
206 }
207
208 double potential_derivative(unsigned int atn, double xi, double r) const {
209 AtomCore ac = (*(atom_core.find(atn))).second;
210 return ac.potential.eval_derivative(xi, r);
211 }
212
213 void read_file(std::string filename, std::set<unsigned int> atomset, double eprec);
214
215 void set_eprec(double value);
216
217 void set_rcut(double value);
218
219 template <typename Archive>
220 void serialize(Archive& ar) {
221 ar & core_type;
222 ar & guess_filename;
223 for (std::map<unsigned int, AtomCore>::iterator it=atom_core.begin(); it != atom_core.end(); ++it) {
224 ar & it->first & it->second;
225 }
226 }
227};
228}
229
230#endif
Declaration of utility class and functions for atom.
Definition test_ar.cc:118
Definition corepotential.h:148
unsigned int n_core_orb_base(const unsigned int atn) const
Definition corepotential.h:173
std::string guess_file() const
Definition corepotential.h:177
std::map< unsigned int, AtomCore > atom_core
core potential data mapped atn to potential
Definition corepotential.h:152
std::string guess_filename
filename of initial guess density data
Definition corepotential.h:151
unsigned int n_core_orb(const unsigned int atn) const
Definition corepotential.h:169
std::string core_type
core potential type (eg. mcp)
Definition corepotential.h:150
CorePotentialManager()
Definition corepotential.h:156
CorePotentialManager(std::string filename, double eprec)
Definition corepotential.h:161
double potential_derivative(unsigned int atn, double xi, double r) const
Definition corepotential.h:208
double core_derivative(unsigned int atn, unsigned int core, int m, int axis, double xi, double rsq, double x, double y, double z) const
Definition corepotential.h:199
bool is_defined(const unsigned int atn) const
Definition corepotential.h:165
unsigned int get_core_l(unsigned int atn, unsigned int core) const
Definition corepotential.h:187
void read_file(std::string filename, std::set< unsigned int > atomset, double eprec)
Definition corepotential.cc:329
double core_eval(unsigned int atn, unsigned int core, int m, double rsq, double x, double y, double z) const
Definition corepotential.h:195
void serialize(Archive &ar)
Definition corepotential.h:220
void set_eprec(double value)
Definition corepotential.cc:369
CorePotential get_potential(unsigned int atn) const
Definition corepotential.h:183
void set_rcut(double value)
Definition corepotential.cc:379
double potential(unsigned int atn, double r) const
Definition corepotential.h:203
AtomCore get_atom_core(unsigned int atn) const
Definition corepotential.h:179
static const double fc
Definition corepotential.h:149
double get_core_bc(unsigned int atn, unsigned int core) const
Definition corepotential.h:191
Defines common mathematical and physical constants.
static const double eprec
Definition hatom_sf_dirac.cc:18
Macros and tools pertaining to the configuration of MADNESS.
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
static const char * filename
Definition legendre.cc:96
Defines simple templates for printing to std::cout "a la Python".
static const double m
Definition relops.cc:9
const double xi
Exponent for delta function approx.
Definition siam_example.cc:60
Definition corepotential.h:128
CorePotential potential
Definition corepotential.h:132
AtomCore()
Definition corepotential.h:134
unsigned int atomic_number
Definition corepotential.h:129
void serialize(Archive &ar)
Definition corepotential.h:139
std::vector< CoreOrbital > orbital
Definition corepotential.h:131
unsigned int n_orbital() const
Definition corepotential.h:136
unsigned int ncore
Definition corepotential.h:130
Definition corepotential.h:92
CoreOrbital(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, double Bc)
Definition corepotential.h:99
double eval_derivative(int m, int axis, double xi, double rsq, double x, double y, double z) const
Definition corepotential.cc:237
vector< double > coeff
Definition corepotential.h:95
double rsqmax
Definition corepotential.h:96
double eval(int m, double rsq, double x, double y, double z) const
Definition corepotential.cc:226
void serialize(Archive &ar)
Definition corepotential.h:122
double eval_spherical_harmonics(int m, double x, double y, double z, double &dp, int axis) const
Definition corepotential.cc:139
double eval_radial(double rsq) const
Definition corepotential.cc:123
int type
Definition corepotential.h:94
double Bc
Definition corepotential.h:93
vector< double > expnt
Definition corepotential.h:95
CoreOrbital()
Definition corepotential.h:98
double eval_radial_derivative(double rsq, double xi) const
Definition corepotential.cc:131
Represents a core potential.
Definition corepotential.h:66
double rcut
Definition corepotential.h:71
CorePotential()
Definition corepotential.h:73
CorePotential(const std::vector< int > &l, const std::vector< int > &n, const std::vector< double > &A, const std::vector< double > &alpha)
Definition corepotential.h:74
std::vector< double > A
Definition corepotential.h:69
double eval_derivative(double xi, double r) const
Definition corepotential.cc:85
double eprec
Definition corepotential.h:71
void serialize(Archive &ar)
Definition corepotential.h:87
double eval(double r) const
Definition corepotential.cc:62
std::vector< double > alpha
Definition corepotential.h:70
std::vector< int > l
Angular momentum = 0, 1, 2, ...
Definition corepotential.h:67
std::string to_string() const
Definition corepotential.cc:112
std::vector< int > n
Definition corepotential.h:68
double rcut0
Definition corepotential.h:71
void e()
Definition test_sig.cc:75
std::size_t axis
Definition testpdiff.cc:59