MADNESS 0.10.1
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
32#ifndef MADNESS_CHEM_MOLECULE_H__INCLUDED
33#define MADNESS_CHEM_MOLECULE_H__INCLUDED
34
35/// \file moldft/molecule.h
36/// \brief Declaration of molecule related classes and functions
37
38#include <ctype.h>
41#include <madness/misc/misc.h>
44
45#include <algorithm>
46#include <cmath>
47#include <fstream>
48#include <iostream>
49#include <sstream>
50#include <string>
51#include <vector>
52
55
56namespace madness {
57
58class World;
59
60class Atom {
61 public:
62 double x, y, z, q; ///< Coordinates and charge in atomic units
63 unsigned int atomic_number; ///< Atomic number
64 double mass; ///< Mass
65 bool pseudo_atom; ///< Indicates if this atom uses a pseudopotential
66
67 explicit Atom(double x, double y, double z, double q, unsigned int atomic_number, bool pseudo_atom)
70
71 if (mass == -1.0) MADNESS_EXCEPTION("faulty element in Atom", 1);
72
73 // unstable elements are indicated by negative masses, the mass
74 // is taken from the longest-living element
75 if (mass < 0.0) mass *= -1.0;
76 }
77
78 explicit Atom(double x, double y, double z, double q, unsigned int atomic_number) : x(x), y(y), z(z), q(q), atomic_number(atomic_number) {
80
81 if (mass == -1.0) MADNESS_EXCEPTION("faulty element in Atom", 1);
82
83 // unstable elements are indicated by negative masses, the mass
84 // is taken from the longest-living element
85 if (mass < 0.0) mass *= -1.0;
86
87 pseudo_atom = false;
88 }
89
91
92 /// Default construct makes a zero charge ghost atom at origin
93 Atom() : x(0), y(0), z(0), q(0), atomic_number(0), mass(0.0), pseudo_atom(false) {}
94
95 bool operator==(const Atom &other) const {
96 double thresh=1.e-10;
97 auto displacement=Vector<double, 3>({x, y, z})-(Vector<double, 3>({other.x, other.y, other.z}));
98 double err = displacement.normf();
99 return ((err<thresh) && q == other.q &&
100 atomic_number == other.atomic_number && mass == other.mass &&
101 pseudo_atom == other.pseudo_atom);
102 }
103
104 int get_atomic_number() const { return atomic_number; }
105
107
108 /// return the mass in atomic units (electron mass = 1 a.u.)
110
111 template <typename Archive>
112 void serialize(Archive &ar) {
113 ar & x & y & z & q & atomic_number & mass & pseudo_atom;
114 }
115 hashT hash() const {
116 hashT h = hash_value(x);
117 hash_combine(h, y);
118 hash_combine(h, z);
119 hash_combine(h, q);
123 return h;
124 }
125};
126
127std::ostream &operator<<(std::ostream &s, const Atom &atom);
128
129class Molecule {
130 public:
131 // Needed for ParameterManager
132 static constexpr char const *tag = "molecule";
133 [[nodiscard]] json to_json_if_precedence(std::string const &precedence) const {
135 mol_schema["parameters"] = parameters.to_json_if_precedence(precedence);
137 return mol_schema;
138 }
139
140
142 GeometryParameters(const GeometryParameters &other) = default;
143
145 try {
147 // The deck has to carry a geometry group -- unless the geometry already
148 // came in through `--geometry=`/`--molecule=`, in which case there is
149 // nothing to read and a missing group is not an error. This used to be
150 // unconditionally fatal and was papered over by
151 // read_input_and_commandline_options swallowing the exception.
153 // read the data group the input file actually uses, then apply
154 // `--geometry=...`/`--molecule=...` overrides for the other spelling
155 // as well (a no-op if that key is absent)
156 const std::string tag = input_tag(parser);
158 read_commandline_options(world, parser, tag == "geometry" ? "molecule" : "geometry");
159 set_derived_values(parser);
160
161 } catch (std::exception &e) {
162 print(tag, "end");
163 throw;
164 // MADNESS_EXCEPTION("faulty geometry input",1);
165 }
166 }
167
169 ignore_unknown_keys = true;
172
173 // initialize<std::vector<std::string>>("source",{"inputfile"},"where
174 // to get the coordinates from: ({inputfile}, {library,xxx},
175 // {xyz,xxx.xyz})");
176 initialize<std::string>("source_type", "inputfile", "where to get the coordinates from", {"inputfile", "xyz", "library"});
177 initialize<std::string>("source_name", "TBD", "name of the geometry from the library or the input file");
178 initialize<double>("eprec", 1.e-4, "smoothing for the nuclear potential");
179 initialize<std::string>("units", "atomic", "coordinate units", {"atomic", "angstrom", "bohr", "au"});
180 initialize<std::vector<double>>("field", {0.0, 0.0, 0.0}, "external electric field");
181 initialize<bool>("no_orient", false,
182 "if true the coordinates will not be reoriented and/or symmetrized");
183 initialize<double>("symtol", -1.e-2,
184 "distance threshold");
185
186 initialize<std::string>("core_type", "none", "core potential type", {"none", "mcp"});
187 initialize<bool>("psp_calc", false, "pseudopotential calculation for all atoms");
188 initialize<bool>("pure_ae", true, "pure all electron calculation with no pseudo-atoms");
189 }
190
191 std::string get_tag() const override {
192 return std::string("molecule");
193 }
194
195 /// source_name is a path (xyz file / input file) -- never case-fold it
196 std::set<std::string> case_sensitive_keys() const override {
197 return {"source_name"};
198 }
199
201 // `--geometry=<name>` is the documented spelling (see the help text of
202 // moldft/nemo/cc2/madqc); `--molecule=<name>` is accepted as an alias.
203 // value_raw, not value: this may be a path, and paths are case-sensitive.
204 for (const char *key : {"geometry", "molecule"}) {
205 if (parser.key_exists(key)) {
206 set_user_defined_value("source_name", parser.value_raw(key));
207 }
208 }
209 }
210
211 /// name of the data group carrying the geometry in the input file
212
213 /// The group is spelled `geometry` (canonical -- the moldft/nemo/cc2 decks)
214 /// or `molecule` (alias -- the madqc decks and the structure library).
215 /// Returns whichever the input file contains, preferring the canonical name
216 /// and falling back to it when the file has neither (or does not exist), so
217 /// that the missing-data-group diagnostic names the documented spelling.
218 static std::string input_tag(const commandlineparser &parser);
219
221 // check if we use an xyz file, the structure library or the input file
222 set_derived_value("source_name",
223 parser.value("input")); // will not override user input
224 std::string src_type = derive_source_type_from_name(source_name(), parser);
225 set_derived_value("source_type", src_type);
226 if (parser.key_exists("no_orient") and parser.value("no_orient") == "true") set_derived_value("no_orient", true);
227
228 // check for ambiguities in the derived source type
229 if (not is_user_defined("source_type")) {
230 std::ifstream f(source_name().c_str());
231 bool found_geometry_file = f.good();
232 // bool
233 // found_geometry_file=std::filesystem::exists(source_name());
234
235 bool geometry_found_in_library = true;
236 try { // check for existence of file and structure in the library
237 std::ifstream f;
239 } catch (...) {
241 }
242
244 madness::print("\n\n");
246 "geometry specification ambiguous: found geometry in "
247 "the structure library and in a file\n");
251 "\nPlease specify the location of your geometry input "
252 "by one of the two lines:\n");
253 madness::print(" source_type xyz");
254 madness::print(" source_type library\n\n");
255 MADNESS_EXCEPTION("faulty input\n\n", 1);
256 }
257 }
258
259 // std::vector<std::string> src=source();
260 //
261 // // some convenience for the user
262 //
263 // // if source is the input file provide the name of the input
264 // file if (src.size()==1 and src[0]=="inputfile")
265 // set_derived_value("source",std::vector<std::string>({src[0],parser.value("input")}));
266 // // if source is not "inputfile" or "library" assume an xyz
267 // file if (src.size()==1 and src[0]!="inputfile") {
268 // std::size_t found=src[0].find("xyz");
269 // if (found==src[0].size()-3) { // check input file ends
270 // with xyz
271 // set_user_defined_value("source",
272 // std::vector<std::string>({"xyz", src[0]}));
273 // } else {
274 // throw std::runtime_error("error in deriving geometry
275 // parameters");
276 // }
277 // }
278
279 // Resolve a relative xyz path to an absolute one *now*, while the process
280 // is still in the directory the user invoked it from: madqc chdir's into a
281 // per-task run directory before the task re-reads its geometry, and it
282 // propagates source_name through the deck it writes there, so a relative
283 // path would then resolve against the task directory and not be found.
284 // Only "xyz" is rewritten -- for "inputfile" the name must keep comparing
285 // equal to parser.value("input") in derive_source_type_from_name(), and
286 // "library" names are not paths.
287 if (source_type() == "xyz") {
288 const std::string abs = absolute_path(source_name());
289 if (abs != source_name()) set_user_defined_value("source_name", abs);
290 }
291
292 if (source_type() == "xyz") set_derived_value("units", std::string("angstrom"));
293 if (units() == "bohr" or units() == "au") set_derived_value("units", std::string("atomic"));
294 }
295
296 /// make a relative path absolute, relative to the current working directory
297
298 /// Returns \p path unchanged if it is already absolute or cannot be resolved
299 /// here -- the reader then reports the name as given, which is the more
300 /// useful diagnostic.
301 static std::string absolute_path(const std::string &path);
302
303 std::string source_type() const { return get<std::string>("source_type"); }
304 std::string source_name() const { return get<std::string>("source_name"); }
305 std::vector<double> field() const { return get<std::vector<double>>("field"); }
306 double eprec() const { return get<double>("eprec"); }
307 std::string units() const { return get<std::string>("units"); }
308 std::string core_type() const { return get<std::string>("core_type"); }
309 bool psp_calc() const { return get<bool>("psp_calc"); }
310 bool pure_ae() const { return get<bool>("pure_ae"); }
311 bool no_orient() const { return get<bool>("no_orient"); }
312 double symtol() const { return get<double>("symtol"); }
313
314 static std::string derive_source_type_from_name(const std::string name, const commandlineparser &parser) {
315 if (name == parser.value("input")) return "inputfile";
316 std::size_t pos = name.find(".xyz");
317 if (pos != std::string::npos) return "xyz";
318 return "library";
319 }
320 };
321
322 private:
323 // If you add more fields don't forget to serialize them
324 std::vector<Atom> atoms;
325 std::vector<double> rcut; // Reciprocal of the smoothing radius
328
329 /// The molecular point group is automatically assigned in the
330 /// identify_pointgroup function
331 std::string pointgroup_ = "c1";
332
333 public:
335
336 static void print_parameters();
337
338 std::string get_pointgroup() const { return pointgroup_; }
339
340 private:
341 void swapaxes(int ix, int iy);
342
343 template <typename opT>
344 bool test_for_op(opT op, const double symtol) const;
345
346 template <typename opT>
347 void symmetrize_for_op(opT op, const double symtol);
348
349 template <typename opT>
350 int find_symmetry_equivalent_atom(int iatom, opT op, const double symtol) const;
351
352 bool test_for_c2(double xaxis, double yaxis, double zaxis, const double symtol) const;
353
354 bool test_for_sigma(double xaxis, double yaxis, double zaxis, const double symtol) const;
355
356 bool test_for_inverse(const double symtol) const;
357
358 /// Apply to (x,y,z) a C2 rotation about an axis thru the origin and
359 /// (xaxis,yaxis,zaxis)
360 struct apply_c2 {
361 double xaxis, yaxis, zaxis;
362 apply_c2(double xaxis, double yaxis, double zaxis) : xaxis(xaxis), yaxis(yaxis), zaxis(zaxis) {}
363 void operator()(double &x, double &y, double &z) const {
364 double raxissq = xaxis * xaxis + yaxis * yaxis + zaxis * zaxis;
365 double dx = x * xaxis * xaxis / raxissq;
366 double dy = y * yaxis * yaxis / raxissq;
367 double dz = z * zaxis * zaxis / raxissq;
368 x = 2.0 * dx - x;
369 y = 2.0 * dy - y;
370 z = 2.0 * dz - z;
371 }
372 };
373
374 /// Apply to (x,y,z) a reflection through a plane containing the origin with
375 /// normal (xaxis,yaxis,zaxis)
376 struct apply_sigma {
377 double xaxis, yaxis, zaxis;
378 apply_sigma(double xaxis, double yaxis, double zaxis) : xaxis(xaxis), yaxis(yaxis), zaxis(zaxis) {}
379 void operator()(double &x, double &y, double &z) const {
380 double raxissq = xaxis * xaxis + yaxis * yaxis + zaxis * zaxis;
381 double dx = x * xaxis * xaxis / raxissq;
382 double dy = y * yaxis * yaxis / raxissq;
383 double dz = z * zaxis * zaxis / raxissq;
384
385 x = x - 2.0 * dx;
386 y = y - 2.0 * dy;
387 z = z - 2.0 * dz;
388 }
389 };
390
392 double xaxis, yaxis, zaxis;
393 apply_inverse(double xaxis, double yaxis, double zaxis) : xaxis(xaxis), yaxis(yaxis), zaxis(zaxis) {}
394 void operator()(double &x, double &y, double &z) const {
395 x = -x;
396 y = -y;
397 z = -z;
398 }
399 };
400
401 public:
402 /// Makes a molecule with zero atoms
403 Molecule() : atoms(), rcut(), core_pot(), field(3L){};
404
405 /// makes a molecule from a list of atoms
407
408 /// makes a molecule using contents of \p parser
409 Molecule(World &world, const commandlineparser &parser);
410
411 void get_structure();
412
413 void read_structure_from_library(const std::string &name);
414
415 static std::istream &position_stream_in_library(std::ifstream &f, const std::string &name);
416
417 static std::string get_structure_library_path();
418
419 /// print out a Gaussian cubefile header
420
421 /// @param[in] offset the offset to be subtracted from the coordinates
422 std::vector<std::string> cubefile_header(const Vector<double, 3> offset = Vector<double, 3>(0.0)) const;
423
424 // initializes Molecule using the contents of file \c filename
425 void read_file(const std::string &filename);
426
427 // initializes Molecule using the contents of stream \c f
428 void read(std::istream &f);
429
430 // initializes Molecule using the contents of file \c filenam assuming an xyz
431 // file
432 void read_xyz(const std::string filename);
433
434 void read_core_file(const std::string &filename);
435
436 std::string guess_file() const { return core_pot.guess_file(); };
437
438 unsigned int n_core_orb_all() const;
439
440 unsigned int n_core_orb(unsigned int atn) const {
441 if (core_pot.is_defined(atn))
442 return core_pot.n_core_orb_base(atn);
443 else
444 return 0;
445 };
446
447 unsigned int get_core_l(unsigned int atn, unsigned int c) const { return core_pot.get_core_l(atn, c); }
448
449 double get_core_bc(unsigned int atn, unsigned int c) const { return core_pot.get_core_bc(atn, c); }
450
451 double core_eval(int atom, unsigned int core, int m, double x, double y, double z) const;
452
453 double core_derivative(int atom, int axis, unsigned int core, int m, double x, double y, double z) const;
454
455 bool is_potential_defined(unsigned int atn) const { return core_pot.is_defined(atn); };
456
457 bool is_potential_defined_atom(int i) const { return core_pot.is_defined(atoms[i].atomic_number); };
458
459 void add_atom(double x, double y, double z, double q, int atn);
460
461 void add_atom(double x, double y, double z, double q, int atn, bool psat);
462
463 size_t natom() const { return atoms.size(); };
464
465 void set_atom_charge(unsigned int i, double zeff);
466
467 unsigned int get_atom_charge(unsigned int i) const;
468
469 unsigned int get_atomic_number(unsigned int i) const;
470
471 void set_pseudo_atom(unsigned int i, bool psat);
472
473 bool get_pseudo_atom(unsigned int i) const;
474
475 void set_atom_coords(unsigned int i, double x, double y, double z);
476
478
479 std::vector<madness::Vector<double, 3>> get_all_coords_vec() const;
480
481 std::vector<double> atomic_radii;
482
484
485 void update_rcut_with_eprec(double value);
486
487 void set_rcut(double value);
488
489 std::vector<double> get_rcut() const { return rcut; }
490
491 void set_core_eprec(double value) { core_pot.set_eprec(value); }
492
493 void set_core_rcut(double value) { core_pot.set_rcut(value); }
494
495 double get_eprec() const { return parameters.eprec(); }
496
497 double bounding_cube() const;
498
499 const Atom &get_atom(unsigned int i) const;
500
501 const std::vector<Atom> &get_atoms() const { return atoms; }
502
503 /// print all parameters and the molecular geometry
504 void print(std::ostream& os=std::cout, const bool defined_only=false) const;
505
506 /// print user-defined parameters and the molecular geometry
507 void print_defined_only(std::ostream& os=std::cout) const {
508 this->print(os,true);
509 };
510
511 double inter_atomic_distance(unsigned int i, unsigned int j) const;
512
513 double nuclear_repulsion_energy() const;
514
515 double nuclear_repulsion_derivative(size_t iatom, int axis) const;
516
517 /// compute the nuclear-nuclear contribution to the second derivatives
518
519 /// @param[in] iatom the i-th atom (row of the hessian)
520 /// @param[in] jatom the j-th atom (column of the hessian)
521 /// @param[in] iaxis the xyz axis of the i-th atom
522 /// @param[in] jaxis the xyz axis of the j-th atom
523 /// return the (3*iatom + iaxis, 3*jatom + jaxis) matix element of the hessian
524 double nuclear_repulsion_second_derivative(int iatom, int jatom, int iaxis, int jaxis) const;
525
526 /// return the hessian matrix of the second derivatives d^2/dxdy V
527
528 /// no factor 0.5 included
530
531 /// compute the dipole moment of the nuclei
532
533 /// @param[in] axis the axis (x, y, z)
534 double nuclear_dipole(int axis) const;
535
536 /// compute the derivative of the nuclear dipole wrt a nuclear displacement
537
538 /// @param[in] atom the atom which will be displaced
539 /// @param[in] axis the axis where the atom will be displaced
540 /// @return a vector which all 3 components of the dipole derivative
541 Tensor<double> nuclear_dipole_derivative(const int atom, const int axis) const;
542
543 /// evaluate the nuclear charge density at point `{x,y,z}` using the default
544 /// MADNESS nuclear model. See smoothed_density() for the description
545 /// of the default nuclear model.
546 /// \param x,y,z the point at which the nuclear charge density is evaluated
547 /// \param rscale setting `rscale>1` will make a nucleus larger by a factor of
548 /// \p rscale (in other words, `rcut` is multiplied by the inverse of by this)
549 /// \return the nuclear charge density at point `{x,y,z}`
550 /// \sa smoothed_density()
551 double nuclear_charge_density(double x, double y, double z, double rscale = 1.) const;
552
553 double smallest_length_scale() const;
554
555 std::string symmetrize_and_identify_point_group(const double symtol);
556
557 /// Moves the center of nuclear charge to the origin
558 void center();
559
560 /// rotates the molecule and the external field
561
562 void fix_phase();
563
564 /// @param[in] D the rotation matrix
565 void rotate(const Tensor<double> &D);
566
567 /// translate the molecule
568 void translate(const Tensor<double> &translation);
569
571
572 /// compute the mass-weighting matrix for the hessian
573
574 /// use as
575 /// mass_weighted_hessian=inner(massweights,inner(hessian,massweights));
577 Tensor<double> M(3 * natom(), 3 * natom());
578 for (size_t i = 0; i < natom(); i++) {
579 const double sqrtmass = 1.0 / sqrt(get_atom(i).get_mass_in_au());
580 M(3 * i, 3 * i) = sqrtmass;
581 M(3 * i + 1, 3 * i + 1) = sqrtmass;
582 M(3 * i + 2, 3 * i + 2) = sqrtmass;
583 }
584 return M;
585 }
586
588
589 void orient(bool verbose = false);
590
591 double total_nuclear_charge() const;
592
593 /// nuclear attraction potential for the whole molecule
594 double nuclear_attraction_potential(double x, double y, double z) const;
595
596 /// nuclear attraction potential for a specific atom in the molecule
597 double atomic_attraction_potential(int iatom, double x, double y, double z) const;
598
599 double molecular_core_potential(double x, double y, double z) const;
600
601 double core_potential_derivative(int atom, int axis, double x, double y, double z) const;
602
603 double nuclear_attraction_potential_derivative(int atom, int axis, double x, double y, double z) const;
604
605 double nuclear_attraction_potential_second_derivative(int atom, int iaxis, int jaxis, double x, double y, double z) const;
606
607 bool operator==(const Molecule& other) const {
608 if (atoms.size() != other.atoms.size() || rcut.size() != other.rcut.size() || pointgroup_ != other.pointgroup_) return false;
609 for (size_t i = 0; i < atoms.size(); ++i) {
610 if (not (atoms[i] == other.atoms[i])) return false;
611 }
612 for (size_t i = 0; i < rcut.size(); ++i) {
613 if (rcut[i] != other.rcut[i]) return false;
614 }
615
616 return (field-other.field).normf()<1.e-13 && parameters == other.parameters;
617 }
618
619 template <typename Archive>
620 void serialize(Archive &ar) {
622 }
623
624 hashT hash() const {
625 hashT h = hash_range(atoms.begin(), atoms.end());
626 hash_combine(h, hash_range(rcut.begin(), rcut.end()));
628 return h;
629 }
630 [[nodiscard]] json to_json() const;
632 void from_json(const json &mol_json);
633};
634
635} // namespace madness
636
637#endif
double q(double t)
Definition DKops.h:18
std::filesystem::path path
Definition InputWriter.cpp:3
Declaration of utility class and functions for atom.
Definition mentity.h:71
Definition molecule.h:60
Atom(double x, double y, double z, double q, unsigned int atomic_number)
Definition molecule.h:78
double y
Definition molecule.h:62
unsigned int atomic_number
Atomic number.
Definition molecule.h:63
int get_atomic_number() const
Definition molecule.h:104
Atom(double x, double y, double z, double q, unsigned int atomic_number, bool pseudo_atom)
Definition molecule.h:67
double x
Definition molecule.h:62
double z
Definition molecule.h:62
Atom(const Atom &a)
Definition molecule.h:90
bool operator==(const Atom &other) const
Definition molecule.h:95
madness::Vector< double, 3 > get_coords() const
Definition molecule.h:106
Atom()
Default construct makes a zero charge ghost atom at origin.
Definition molecule.h:93
double mass
Mass.
Definition molecule.h:64
double q
Coordinates and charge in atomic units.
Definition molecule.h:62
void serialize(Archive &ar)
Definition molecule.h:112
double get_mass_in_au() const
return the mass in atomic units (electron mass = 1 a.u.)
Definition molecule.h:109
hashT hash() const
Definition molecule.h:115
bool pseudo_atom
Indicates if this atom uses a pseudopotential.
Definition molecule.h:65
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
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 set_eprec(double value)
Definition corepotential.cc:369
void set_rcut(double value)
Definition corepotential.cc:379
double get_core_bc(unsigned int atn, unsigned int core) const
Definition corepotential.h:191
Definition molecule.h:129
void read_structure_from_library(const std::string &name)
Definition molecule.cc:251
std::vector< madness::Vector< double, 3 > > get_all_coords_vec() const
Definition molecule.cc:463
static std::string get_structure_library_path()
Definition molecule.cc:224
std::vector< double > get_rcut() const
Definition molecule.h:489
void read_core_file(const std::string &filename)
Definition molecule.cc:1265
double bounding_cube() const
Returns the half width of the bounding cube.
Definition molecule.cc:1070
std::vector< double > atomic_radii
Definition molecule.h:481
void symmetrize_for_op(opT op, const double symtol)
Definition molecule.cc:810
void update_rcut_with_eprec(double value)
updates rcuts with given eprec
Definition molecule.cc:484
Tensor< double > nuclear_dipole_derivative(const int atom, const int axis) const
compute the derivative of the nuclear dipole wrt a nuclear displacement
Definition molecule.cc:650
void set_all_coords(const madness::Tensor< double > &newcoords)
Definition molecule.cc:474
std::string guess_file() const
Definition molecule.h:436
double smallest_length_scale() const
Definition molecule.cc:750
double get_core_bc(unsigned int atn, unsigned int c) const
Definition molecule.h:449
double atomic_attraction_potential(int iatom, double x, double y, double z) const
nuclear attraction potential for a specific atom in the molecule
Definition molecule.cc:1112
double total_nuclear_charge() const
Definition molecule.cc:1080
double nuclear_dipole(int axis) const
compute the dipole moment of the nuclei
Definition molecule.cc:620
const std::vector< Atom > & get_atoms() const
Definition molecule.h:501
std::vector< Atom > atoms
Definition molecule.h:324
void translate(const Tensor< double > &translation)
translate the molecule
Definition molecule.cc:779
void center()
Moves the center of nuclear charge to the origin.
Definition molecule.cc:760
const Atom & get_atom(unsigned int i) const
Definition molecule.cc:502
bool operator==(const Molecule &other) const
Definition molecule.h:607
madness::Tensor< double > get_all_coords() const
Definition molecule.cc:452
void orient(bool verbose=false)
Centers and orients the molecule in a standard manner.
Definition molecule.cc:978
unsigned int get_atom_charge(unsigned int i) const
Definition molecule.cc:425
double core_derivative(int atom, int axis, unsigned int core, int m, double x, double y, double z) const
Definition molecule.cc:1222
int find_symmetry_equivalent_atom(int iatom, opT op, const double symtol) const
Definition molecule.cc:799
double molecular_core_potential(double x, double y, double z) const
Definition molecule.cc:1235
void print_defined_only(std::ostream &os=std::cout) const
print user-defined parameters and the molecular geometry
Definition molecule.h:507
std::vector< std::string > cubefile_header(const Vector< double, 3 > offset=Vector< double, 3 >(0.0)) const
print out a Gaussian cubefile header
Definition molecule.cc:264
std::string get_pointgroup() const
Definition molecule.h:338
bool get_pseudo_atom(unsigned int i) const
Definition molecule.cc:440
double nuclear_attraction_potential(double x, double y, double z) const
nuclear attraction potential for the whole molecule
Definition molecule.cc:1088
std::string symmetrize_and_identify_point_group(const double symtol)
Definition molecule.cc:866
void read_file(const std::string &filename)
Definition molecule.cc:279
Tensor< double > center_of_mass() const
compute the center of mass
Definition molecule.cc:948
std::string pointgroup_
Definition molecule.h:331
hashT hash() const
Definition molecule.h:624
void fix_phase()
rotates the molecule and the external field
Definition molecule.cc:1024
static std::istream & position_stream_in_library(std::ifstream &f, const std::string &name)
Definition molecule.cc:230
void set_atom_coords(unsigned int i, double x, double y, double z)
Definition molecule.cc:445
json to_json_if_precedence(std::string const &precedence) const
Definition molecule.h:133
double inter_atomic_distance(unsigned int i, unsigned int j) const
Definition molecule.cc:588
bool test_for_inverse(const double symtol) const
Definition molecule.cc:849
size_t natom() const
Definition molecule.h:463
double core_eval(int atom, unsigned int core, int m, double x, double y, double z) const
Definition molecule.cc:1213
double nuclear_repulsion_derivative(size_t iatom, int axis) const
Definition molecule.cc:657
std::vector< double > rcut
Definition molecule.h:325
void set_rcut(double value)
Definition molecule.cc:496
void set_core_rcut(double value)
Definition molecule.h:493
void set_core_eprec(double value)
Definition molecule.h:491
bool is_potential_defined(unsigned int atn) const
Definition molecule.h:455
double nuclear_attraction_potential_second_derivative(int atom, int iaxis, int jaxis, double x, double y, double z) const
the second derivative of the (smoothed) nuclear potential Z/r
Definition molecule.cc:1156
void serialize(Archive &ar)
Definition molecule.h:620
double nuclear_repulsion_energy() const
Definition molecule.cc:595
unsigned int get_atomic_number(unsigned int i) const
Definition molecule.cc:430
void swapaxes(int ix, int iy)
Definition molecule.cc:853
static constexpr char const * tag
Definition molecule.h:132
static void print_parameters()
Definition molecule.cc:120
json to_json() const
Definition molecule.cc:512
unsigned int get_core_l(unsigned int atn, unsigned int c) const
Definition molecule.h:447
Tensor< double > nuclear_repulsion_hessian() const
return the hessian matrix of the second derivatives d^2/dxdy V
Definition molecule.cc:677
void add_atom(double x, double y, double z, double q, int atn)
Definition molecule.cc:401
Tensor< double > moment_of_inertia() const
Definition molecule.cc:964
Molecule()
Makes a molecule with zero atoms.
Definition molecule.h:403
double nuclear_charge_density(double x, double y, double z, double rscale=1.) const
Definition molecule.cc:1184
void set_atom_charge(unsigned int i, double zeff)
Definition molecule.cc:420
double get_eprec() const
Definition molecule.h:495
double nuclear_repulsion_second_derivative(int iatom, int jatom, int iaxis, int jaxis) const
compute the nuclear-nuclear contribution to the second derivatives
Definition molecule.cc:701
GeometryParameters parameters
Definition molecule.h:334
void from_json(const json &mol_json)
Definition molecule.cc:537
void print(std::ostream &os=std::cout, const bool defined_only=false) const
print all parameters and the molecular geometry
Definition molecule.cc:568
unsigned int n_core_orb(unsigned int atn) const
Definition molecule.h:440
madness::Tensor< double > field
Definition molecule.h:327
unsigned int n_core_orb_all() const
Definition molecule.cc:1201
void set_pseudo_atom(unsigned int i, bool psat)
Definition molecule.cc:435
void insert_symbols_and_geometry(json &mol_json) const
Definition molecule.cc:523
CorePotentialManager core_pot
Definition molecule.h:326
Tensor< double > massweights() const
compute the mass-weighting matrix for the hessian
Definition molecule.h:576
void get_structure()
Definition molecule.cc:158
bool test_for_c2(double xaxis, double yaxis, double zaxis, const double symtol) const
Definition molecule.cc:841
double core_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition molecule.cc:1250
void read_xyz(const std::string filename)
Definition molecule.cc:356
bool test_for_op(opT op, const double symtol) const
Definition molecule.cc:789
double nuclear_attraction_potential_derivative(int atom, int axis, double x, double y, double z) const
Definition molecule.cc:1125
bool is_potential_defined_atom(int i) const
Definition molecule.h:457
void read(std::istream &f)
Definition molecule.cc:307
bool test_for_sigma(double xaxis, double yaxis, double zaxis, const double symtol) const
Definition molecule.cc:845
void rotate(const Tensor< double > &D)
Definition molecule.cc:1053
class for holding the parameters for calculation
Definition chem/QCCalculationParametersBase.h:296
void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition chem/QCCalculationParametersBase.h:332
bool throw_if_datagroup_not_found
Definition chem/QCCalculationParametersBase.h:373
void set_user_defined_value(const std::string &key, const T &value)
Definition chem/QCCalculationParametersBase.h:542
void read_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
read the parameters from the command line and broadcast
Definition QCCalculationParametersBase.cc:133
void print(const std::string header="", const std::string footer="") const
print all parameters
Definition QCCalculationParametersBase.cc:32
bool ignore_unknown_keys
Definition chem/QCCalculationParametersBase.h:371
bool ignore_unknown_keys_silently
Definition chem/QCCalculationParametersBase.h:372
bool is_user_defined(std::string key) const
Definition chem/QCCalculationParametersBase.h:315
json to_json_if_precedence(const std::string &precedence) const
convert all parameters to a json object, but only those with a given precedence
Definition chem/QCCalculationParametersBase.h:530
void set_derived_value(const std::string &key, const T &value)
Definition chem/QCCalculationParametersBase.h:429
A tensor is a multidimensional array.
Definition tensor.h:318
A simple, fixed dimension vector.
Definition vector.h:64
A parallel world class.
Definition world.h:134
Declaration of core potential related class.
static const double eprec
Definition hatom_sf_dirac.cc:18
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
Header to declare stuff which has not yet found a home.
constexpr double atomic_mass_in_au
Atomic mass in atomic units.
Definition constants.h:269
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
std::ostream & operator<<(std::ostream &os, const particle< PDIM > &p)
Definition lowrankfunction.h:401
void hash_range(hashT &seed, It first, It last)
Definition worldhash.h:280
static const char * filename
Definition legendre.cc:96
double abs(double x)
Definition complexfun.h:48
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
Key< NDIM > displacement(const Key< NDIM > &source, const Key< NDIM > &target)
given a source and a target, return the displacement in translation
Definition key.h:533
const AtomicData & get_atomic_data(unsigned int atomic_number)
Definition atomutil.cc:167
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
nlohmann::json json
Definition chem/QCCalculationParametersBase.h:30
NDIM & f
Definition mra.h:2620
std::size_t hashT
The hash value type.
Definition worldhash.h:145
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
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
static const double a
Definition nonlinschro.cc:118
static const double c
Definition relops.cc:10
static const double m
Definition relops.cc:9
static const double thresh
Definition rk.cc:45
Definition test_ar.cc:204
const double mass
the atomic mass
Definition atomutil.h:64
Definition molecule.h:141
bool psp_calc() const
Definition molecule.h:309
std::string source_name() const
Definition molecule.h:304
std::string core_type() const
Definition molecule.h:308
void set_global_convenience_options(const commandlineparser &parser)
Definition molecule.h:200
std::set< std::string > case_sensitive_keys() const override
source_name is a path (xyz file / input file) – never case-fold it
Definition molecule.h:196
double symtol() const
Definition molecule.h:312
bool no_orient() const
Definition molecule.h:311
static std::string derive_source_type_from_name(const std::string name, const commandlineparser &parser)
Definition molecule.h:314
static std::string input_tag(const commandlineparser &parser)
name of the data group carrying the geometry in the input file
Definition molecule.cc:145
bool pure_ae() const
Definition molecule.h:310
GeometryParameters(const GeometryParameters &other)=default
std::string get_tag() const override
Definition molecule.h:191
GeometryParameters()
Definition molecule.h:168
static std::string absolute_path(const std::string &path)
make a relative path absolute, relative to the current working directory
Definition molecule.cc:138
GeometryParameters(World &world, const commandlineparser &parser)
Definition molecule.h:144
std::string units() const
Definition molecule.h:307
std::vector< double > field() const
Definition molecule.h:305
double eprec() const
Definition molecule.h:306
std::string source_type() const
Definition molecule.h:303
void set_derived_values(const commandlineparser &parser)
Definition molecule.h:220
Definition molecule.h:360
double yaxis
Definition molecule.h:361
void operator()(double &x, double &y, double &z) const
Definition molecule.h:363
double xaxis
Definition molecule.h:361
apply_c2(double xaxis, double yaxis, double zaxis)
Definition molecule.h:362
double zaxis
Definition molecule.h:361
Definition molecule.h:391
double yaxis
Definition molecule.h:392
void operator()(double &x, double &y, double &z) const
Definition molecule.h:394
double zaxis
Definition molecule.h:392
apply_inverse(double xaxis, double yaxis, double zaxis)
Definition molecule.h:393
double xaxis
Definition molecule.h:392
Definition molecule.h:376
void operator()(double &x, double &y, double &z) const
Definition molecule.h:379
apply_sigma(double xaxis, double yaxis, double zaxis)
Definition molecule.h:378
double xaxis
Definition molecule.h:377
double yaxis
Definition molecule.h:377
double zaxis
Definition molecule.h:377
very simple command line parser
Definition commandlineparser.h:28
std::string value(const std::string key) const
Definition commandlineparser.h:84
bool key_exists(std::string key) const
Definition commandlineparser.h:80
std::string value_raw(const std::string key) const
Definition commandlineparser.h:93
Defines and implements most of Tensor.
void e()
Definition test_sig.cc:75
const double offset
Definition testfuns.cc:143
double h(const coord_1d &r)
Definition testgconv.cc:175
std::size_t axis
Definition testpdiff.cc:59
Implement the madness:Vector class, an extension of std::array that supports some mathematical operat...