MADNESS  version 0.9
DFcode/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_COREPOTENTIAL_H
36 #define MADNESS_COREPOTENTIAL_H
37 
40 
41 #include <madness/madness_config.h>
42 #include <madness/constants.h>
43 #include <moldft/atomutil.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>
52 using std::cout;
53 using std::endl;
54 using std::vector;
55 
57 
64 struct CorePotential {
65  std::vector<int> l;
66  std::vector<int> n;
67  std::vector<double> A;
68  std::vector<double> alpha;
69  double eprec, rcut0, rcut;
70 
71  CorePotential() : l(), n(), A(), alpha() {};
72  CorePotential(const std::vector<int>& l,
73  const std::vector<int>& n,
74  const std::vector<double>& A,
75  const std::vector<double>& alpha)
76  : l(l), n(n), A(A), alpha(alpha), eprec(1e-4), rcut0(1.0), rcut(1.0) {};
77 
78  double eval(double r) const;
79 
80  double eval_derivative(double xi, double r) const;
81 
82  std::string to_string () const;
83 
84  template <typename Archive>
85  void serialize(Archive& ar) {
86  ar & l & n & A & alpha & eprec & rcut0 & rcut;
87  }
88 };
89 
90 struct CoreOrbital {
91  double Bc;
92  int type;
93  vector<double> coeff, expnt;
94  double rsqmax;
95 
96  CoreOrbital() : Bc(0), type(0), coeff(), expnt(), rsqmax(0.0) {}
97  CoreOrbital(int type,
98  const std::vector<double>& coeff,
99  const std::vector<double>& expnt,
100  double Bc)
101  : Bc(Bc), type(type), coeff(coeff), expnt(expnt)
102  {
103  double minexpnt = expnt[0];
104  for (unsigned int i=1; i<expnt.size(); ++i)
105  minexpnt = std::min(minexpnt,expnt[i]);
106  rsqmax = 18.4/minexpnt;
107  };
108 
109  double eval_radial(double rsq) const;
110 
111  double eval_radial_derivative(double rsq, double xi) const;
112 
113  double eval_spherical_harmonics(int m, double x, double y, double z, double& dp, int axis) const;
114 
115  double eval(int m, double rsq, double x, double y, double z) const;
116 
117  double eval_derivative(int m, int axis, double xi, double rsq, double x, double y, double z) const;
118 
119  template <typename Archive>
120  void serialize(Archive& ar) {
121  ar & Bc & type & rsqmax;
122  ar & coeff & expnt;
123  }
124 };
125 
126 struct AtomCore {
127  unsigned int atomic_number;
128  unsigned int ncore;
129  std::vector<CoreOrbital> orbital;
131 
132  AtomCore() : atomic_number(0), ncore(0), orbital(), potential() {};
133 
134  inline unsigned int n_orbital() const { return ncore; };
135 
136  template <typename Archive>
137  void serialize(Archive& ar) {
138  ar & atomic_number & ncore;
139  ar & potential;
140  for (std::vector<CoreOrbital>::iterator it=orbital.begin(); it != orbital.end(); ++it) {
141  ar & (*it);
142  }
143  }
144 };
145 
147  static const double fc;
148  std::string core_type;
149  std::string guess_filename;
150  std::map<unsigned int,AtomCore> atom_core;
152 
153 public:
155  core_type(""),
156  guess_filename(""),
157  atom_core() {}
158 
159  CorePotentialManager(std::string filename, double eprec) : core_type(filename) {
160  read_file(filename, std::set<unsigned int>(), eprec);
161  }
162 
163  inline bool is_defined(const unsigned int atn) const {
164  return (atom_core.find(atn) != atom_core.end());
165  }
166 
167  inline unsigned int n_core_orb(const unsigned int atn) const {
168  return (*(atom_core.find(atn))).second.n_orbital();
169  }
170 
171  inline unsigned int n_core_orb_base(const unsigned int atn) const {
172  return (*(atom_core.find(atn))).second.orbital.size();
173  }
174 
175  inline std::string guess_file() const { return guess_filename; }
176 
177  AtomCore get_atom_core(unsigned int atn) const {
178  return atom_core.find(atn)->second;
179  }
180 
181  CorePotential get_potential(unsigned int atn) const {
182  return atom_core.find(atn)->second.potential;
183  }
184 
185  inline unsigned int get_core_l(unsigned int atn, unsigned int core) const {
186  return get_atom_core(atn).orbital[core].type;
187  }
188 
189  inline double get_core_bc(unsigned int atn, unsigned int core) const {
190  return get_atom_core(atn).orbital[core].Bc*fc/2;
191  }
192 
193  inline double core_eval(unsigned int atn, unsigned int core, int m, double rsq, double x, double y, double z) const {
194  return get_atom_core(atn).orbital[core].eval(m, rsq, x, y, z);
195  }
196 
197  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 {
198  return get_atom_core(atn).orbital[core].eval_derivative(m, axis, xi, rsq, x, y, z);
199  }
200 
201  double potential(unsigned int atn, double r) const {
202  AtomCore ac = (*(atom_core.find(atn))).second;
203  return ac.potential.eval(r);
204  }
205 
206  double potential_derivative(unsigned int atn, double xi, double r) const {
207  AtomCore ac = (*(atom_core.find(atn))).second;
208  return ac.potential.eval_derivative(xi, r);
209  }
210 
211  void read_file(std::string filename, std::set<unsigned int> atomset, double eprec);
212 
213  void set_eprec(double value);
214 
215  void set_rcut(double value);
216 
217  template <typename Archive>
218  void serialize(Archive& ar) {
219  ar & core_type;
220  ar & guess_filename;
221  for (std::map<unsigned int, AtomCore>::iterator it=atom_core.begin(); it != atom_core.end(); ++it) {
222  ar & it->first & it->second;
223  }
224  }
225 };
226 
227 
228 #endif
double rcut
Definition: DFcode/corepotential.h:69
void read_file(std::string filename, std::set< unsigned int > atomset, double eprec)
std::vector< int > n
Definition: DFcode/corepotential.h:66
CorePotential(const std::vector< int > &l, const std::vector< int > &n, const std::vector< double > &A, const std::vector< double > &alpha)
Definition: DFcode/corepotential.h:72
double eval_radial(double rsq) const
double rcut0
Definition: DFcode/corepotential.h:69
std::string to_string() const
void serialize(Archive &ar)
Definition: DFcode/corepotential.h:137
std::string guess_file() const
Definition: DFcode/corepotential.h:175
double eprec
Definition: DFcode/corepotential.h:69
CorePotential get_potential(unsigned int atn) const
Definition: DFcode/corepotential.h:181
vector< double > expnt
Definition: DFcode/corepotential.h:93
::std::string string
Definition: gtest-port.h:872
Defines common mathematical and physical constants.
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: DFcode/corepotential.h:197
Definition: DFcode/corepotential.h:146
void set_eprec(double value)
double eval(int m, double rsq, double x, double y, double z) const
void serialize(Archive &ar)
Definition: DFcode/corepotential.h:85
AtomCore()
Definition: DFcode/corepotential.h:132
double rsqmax
Definition: DFcode/corepotential.h:94
double core_eval(unsigned int atn, unsigned int core, int m, double rsq, double x, double y, double z) const
Definition: DFcode/corepotential.h:193
CoreOrbital()
Definition: DFcode/corepotential.h:96
Definition: DFcode/corepotential.h:126
double eval_derivative(double xi, double r) const
AtomCore get_atom_core(unsigned int atn) const
Definition: DFcode/corepotential.h:177
std::vector< CoreOrbital > orbital
Definition: DFcode/corepotential.h:129
const mpreal min(const mpreal &x, const mpreal &y)
Definition: mpreal.h:2675
double eval_derivative(int m, int axis, double xi, double rsq, double x, double y, double z) const
double potential_derivative(unsigned int atn, double xi, double r) const
Definition: DFcode/corepotential.h:206
unsigned int atomic_number
Definition: DFcode/corepotential.h:127
CorePotentialManager()
Definition: DFcode/corepotential.h:154
unsigned int n_orbital() const
Definition: DFcode/corepotential.h:134
int type
Definition: DFcode/corepotential.h:92
CorePotential potential
Definition: DFcode/corepotential.h:130
vector< double > coeff
Definition: DFcode/corepotential.h:93
Represents a core potential.
Definition: DFcode/corepotential.h:64
void set_rcut(double value)
double potential(unsigned int atn, double r) const
Definition: DFcode/corepotential.h:201
const double m
Definition: gfit.cc:199
unsigned int get_core_l(unsigned int atn, unsigned int core) const
Definition: DFcode/corepotential.h:185
double eval_spherical_harmonics(int m, double x, double y, double z, double &dp, int axis) const
CorePotential()
Definition: DFcode/corepotential.h:71
unsigned int ncore
Definition: DFcode/corepotential.h:128
double get_core_bc(unsigned int atn, unsigned int core) const
Definition: DFcode/corepotential.h:189
std::vector< double > alpha
Definition: DFcode/corepotential.h:68
double Bc
Definition: DFcode/corepotential.h:91
void serialize(Archive &ar)
Definition: DFcode/corepotential.h:120
CoreOrbital(int type, const std::vector< double > &coeff, const std::vector< double > &expnt, double Bc)
Definition: DFcode/corepotential.h:97
void serialize(Archive &ar)
Definition: DFcode/corepotential.h:218
double eval(double r) const
unsigned int n_core_orb_base(const unsigned int atn) const
Definition: DFcode/corepotential.h:171
std::vector< int > l
Angular momentum = 0, 1, 2, ...
Definition: DFcode/corepotential.h:65
Definition: DFcode/corepotential.h:90
bool is_defined(const unsigned int atn) const
Definition: DFcode/corepotential.h:163
std::vector< double > A
Definition: DFcode/corepotential.h:67
unsigned int n_core_orb(const unsigned int atn) const
Definition: DFcode/corepotential.h:167
CorePotentialManager(std::string filename, double eprec)
Definition: DFcode/corepotential.h:159
double eval_radial_derivative(double rsq, double xi) const