MADNESS  version 0.9
DFcode/molecule.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  $Id$
32 */
33 #ifndef MADNESS_MOLECULE_H
34 #define MADNESS_MOLECULE_H
35 
38 
39 #include <DFcode/corepotential.h>
40 #include <DFcode/atomutil.h>
41 #include <madness/world/array.h>
42 #include <vector>
43 #include <string>
44 #include <iostream>
45 #include <fstream>
46 #include <sstream>
47 #include <algorithm>
48 #include <ctype.h>
49 #include <cmath>
50 #include <madness/tensor/tensor.h>
51 #include <madness/misc/misc.h>
52 
53 
54 class Atom {
55 public:
56  double x, y, z, q;
57  unsigned int atomic_number;
58 
59  explicit Atom(double x, double y, double z, double q, unsigned int atomic_number)
60  : x(x), y(y), z(z), q(q), atomic_number(atomic_number) {}
61 
62  Atom(const Atom& a)
63  : x(a.x), y(a.y), z(a.z), q(a.q), atomic_number(a.atomic_number) {}
64 
66  Atom()
67  : x(0), y(0), z(0), q(0), atomic_number(0) {}
68 
69 
71  return madness::vec(x, y, z);
72  }
73 
74  template <typename Archive>
75  void serialize(Archive& ar) {
76  ar & x & y & z & q & atomic_number;
77  }
78 };
79 
80 std::ostream& operator<<(std::ostream& s, const Atom& atom);
81 
82 class Molecule {
83 private:
84  // If you add more fields don't forget to serialize them
85  std::vector<Atom> atoms;
86  std::vector<double> rcut; // Reciprocal of the smoothing radius
87  double eprec; // Error in energy/atom due to smoothing
88  CorePotentialManager core_pot;
89  madness::Tensor<double> field;
90 
91  void swapaxes(int ix, int iy);
92 
93  template <typename opT>
94  bool test_for_op(double xaxis, double yaxis, double zaxis, opT op) const;
95 
96  bool test_for_c2(double xaxis, double yaxis, double zaxis) const;
97 
98  bool test_for_sigma(double xaxis, double yaxis, double zaxis) const;
99 
100  bool test_for_inverse() const;
101 
102  std::string geometry_name;
103 
104 public:
106  Molecule() : atoms(), rcut(), eprec(1e-4), core_pot(), field(3L) {};
107 
108 // Molecule(const std::string& filename);
109  Molecule(const std::string& filename, const std::string& geomname="");
110 
111  void read_file(const std::string& filename);
112  void read_file(const std::string& filename, const std::string& geomname);
113 
114  void read_core_file(const std::string& filename);
115 
116  std::string guess_file() const { return core_pot.guess_file(); };
117 
118  unsigned int n_core_orb_all() const ;
119 
120  unsigned int n_core_orb(unsigned int atn) const {
121  if (core_pot.is_defined(atn))
122  return core_pot.n_core_orb_base(atn);
123  else
124  return 0;
125  };
126 
127  unsigned int get_core_l(unsigned int atn, unsigned int c) const {
128  return core_pot.get_core_l(atn, c);
129  }
130 
131  double get_core_bc(unsigned int atn, unsigned int c) const {
132  return core_pot.get_core_bc(atn, c);
133  }
134 
135  double core_eval(int atom, unsigned int core, int m, double x, double y, double z) const;
136 
137  double core_derivative(int atom, int axis, unsigned int core, int m, double x, double y, double z) const;
138 
139  bool is_potential_defined(unsigned int atn) const { return core_pot.is_defined(atn); };
140 
141  bool is_potential_defined_atom(int i) const { return core_pot.is_defined(atoms[i].atomic_number); };
142 
143  void add_atom(double x, double y, double z, double q, int atn);
144 
145  int natom() const {
146  return atoms.size();
147  };
148 
149  void set_atom_coords(unsigned int i, double x, double y, double z);
150 
151  madness::Tensor<double> get_all_coords() const;
152 
153  std::vector< madness::Vector<double,3> > get_all_coords_vec() const;
154 
155  void set_all_coords(const madness::Tensor<double>& newcoords);
156 
157  void set_eprec(double value);
158 
159  void set_rcut(double value);
160 
161  void set_core_eprec(double value) {
162  core_pot.set_eprec(value);
163  }
164 
165  void set_core_rcut(double value) {
166  core_pot.set_rcut(value);
167  }
168 
169  double get_eprec() const {
170  return eprec;
171  }
172 
173  double bounding_cube() const;
174 
175  const Atom& get_atom(unsigned int i) const;
176 
177  void print() const;
178 
179  double inter_atomic_distance(unsigned int i,unsigned int j) const;
180 
181  double nuclear_repulsion_energy() const;
182 
183  double nuclear_repulsion_derivative(int i, int j) const;
184 
185  double nuclear_dipole(int axis) const;
186 
187  double nuclear_charge_density(double x, double y, double z) const;
188 
189  double smallest_length_scale() const;
190 
191  void identify_point_group();
192 
193  void center();
194 
195  void orient();
196 
197  double total_nuclear_charge() const;
198 
199  double nuclear_attraction_potential(double x, double y, double z) const;
200 
201  double molecular_core_potential(double x, double y, double z) const;
202 
203  double core_potential_derivative(int atom, int axis, double x, double y, double z) const;
204 
205  double nuclear_attraction_potential_derivative(int atom, int axis, double x, double y, double z) const;
206 
207  template <typename Archive>
208  void serialize(Archive& ar) {
209  ar & atoms & rcut & eprec & core_pot;
210  }
211 };
212 
213 
214 #endif
double inter_atomic_distance(unsigned int i, unsigned int j) const
Definition: DFcode/molecule.cc:242
double z
Definition: DFcode/molecule.h:56
void set_eprec(double value)
updates rcuts with given eprec
Definition: DFcode/molecule.cc:208
std::ostream & operator<<(std::ostream &s, const Atom &atom)
Definition: DFcode/molecule.cc:64
double molecular_core_potential(double x, double y, double z) const
Definition: DFcode/molecule.cc:639
Header to declare stuff which has not yet found a home.
unsigned int n_core_orb_all() const
Definition: DFcode/molecule.cc:605
double core_derivative(int atom, int axis, unsigned int core, int m, double x, double y, double z) const
Definition: DFcode/molecule.cc:626
std::string guess_file() const
Definition: DFcode/corepotential.h:175
bool is_potential_defined(unsigned int atn) const
Definition: DFcode/molecule.h:139
const double L
Definition: 3dharmonic.cc:123
::std::string string
Definition: gtest-port.h:872
double nuclear_attraction_potential(double x, double y, double z) const
Definition: DFcode/molecule.cc:550
double x
Definition: DFcode/molecule.h:56
double get_core_bc(unsigned int atn, unsigned int c) const
Definition: DFcode/molecule.h:131
Definition: DFcode/corepotential.h:146
void add_atom(double x, double y, double z, double q, int atn)
Definition: DFcode/molecule.cc:161
Atom(double x, double y, double z, double q, unsigned int atomic_number)
Definition: DFcode/molecule.h:59
int natom() const
Definition: DFcode/molecule.h:145
double total_nuclear_charge() const
Definition: DFcode/molecule.cc:542
void set_eprec(double value)
double smallest_length_scale() const
Definition: DFcode/molecule.cc:300
Definition: DFcode/molecule.h:82
std::vector< madness::Vector< double, 3 > > get_all_coords_vec() const
Definition: DFcode/molecule.cc:187
unsigned int n_core_orb(unsigned int atn) const
Definition: DFcode/molecule.h:120
void identify_point_group()
Definition: DFcode/molecule.cc:402
double core_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition: DFcode/molecule.cc:654
Atom()
Default construct makes a zero charge ghost atom at origin.
Definition: DFcode/molecule.h:66
Defines and implements most of Tensor.
void read_core_file(const std::string &filename)
Definition: DFcode/molecule.cc:669
void set_rcut(double value)
Definition: DFcode/molecule.cc:216
double q
Coordinates and charge in atomic units.
Definition: DFcode/molecule.h:56
Vector< T, 1 > vec(T x)
Your friendly neighborhood factory function.
Definition: array.h:456
double nuclear_dipole(int axis) const
Definition: DFcode/molecule.cc:263
FLOAT a(int j, FLOAT z)
Definition: y1.cc:86
Atom(const Atom &a)
Definition: DFcode/molecule.h:62
double get_eprec() const
Definition: DFcode/molecule.h:169
void print() const
Definition: DFcode/molecule.cc:227
std::string guess_file() const
Definition: DFcode/molecule.h:116
void set_core_rcut(double value)
Definition: DFcode/molecule.h:165
void set_all_coords(const madness::Tensor< double > &newcoords)
Definition: DFcode/molecule.cc:198
Molecule()
Makes a molecule with zero atoms.
Definition: DFcode/molecule.h:106
Abstract Atom class.
Definition: DFcode/molecule.h:54
void set_rcut(double value)
double bounding_cube() const
Returns the half width of the bounding cube.
Definition: DFcode/molecule.cc:532
void read_file(const std::string &filename)
Definition: DFcode/molecule.cc:92
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 core_eval(int atom, unsigned int core, int m, double x, double y, double z) const
Definition: DFcode/molecule.cc:617
bool is_potential_defined_atom(int i) const
Definition: DFcode/molecule.h:141
double get_core_bc(unsigned int atn, unsigned int core) const
Definition: DFcode/corepotential.h:189
double y
Definition: DFcode/molecule.h:56
const Atom & get_atom(unsigned int i) const
Definition: DFcode/molecule.cc:222
void orient()
Centers and orients the molecule in a standard manner.
Definition: DFcode/molecule.cc:473
unsigned int n_core_orb_base(const unsigned int atn) const
Definition: DFcode/corepotential.h:171
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
unsigned int get_core_l(unsigned int atn, unsigned int c) const
Definition: DFcode/molecule.h:127
double nuclear_attraction_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition: DFcode/molecule.cc:571
bool is_defined(const unsigned int atn) const
Definition: DFcode/corepotential.h:163
void serialize(Archive &ar)
Definition: DFcode/molecule.h:208
void set_atom_coords(unsigned int i, double x, double y, double z)
Definition: DFcode/molecule.cc:168
double nuclear_repulsion_energy() const
Definition: DFcode/molecule.cc:249
void center()
Moves the center of nuclear charge to the origin.
Definition: DFcode/molecule.cc:310
const double c
Definition: gfit.cc:200
unsigned int atomic_number
Atomic number.
Definition: DFcode/molecule.h:57
madness::Vector< double, 3 > get_coords() const
Definition: DFcode/molecule.h:70
void serialize(Archive &ar)
Definition: DFcode/molecule.h:75
double nuclear_repulsion_derivative(int i, int j) const
Definition: DFcode/molecule.cc:281
double nuclear_charge_density(double x, double y, double z) const
Definition: DFcode/molecule.cc:591
madness::Tensor< double > get_all_coords() const
Definition: DFcode/molecule.cc:176
void set_core_eprec(double value)
Definition: DFcode/molecule.h:161