MADNESS 0.10.1
molecular_optimizer.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
33
34/// \file chem/molecular_optimizer.h
35/// \brief optimize the geometrical structure of a molecule
36#ifndef MADNESS_CHEM_MOLECULAR_OPTIMIZER_H__INCLUDED
37#define MADNESS_CHEM_MOLECULAR_OPTIMIZER_H__INCLUDED
38
42
43namespace madness {
44
45
47
48 /// return the molecule of the target
49 virtual Molecule& molecule() {
50 MADNESS_EXCEPTION("you need to return a molecule",1);
51 return *(new Molecule()); // this is a memory leak silencing warnings
52 }
53};
54
55
57public:
58
59 /// ctor reading out the input file
61 initialize < std::string > ("update", "bfgs", "Quasi-Newton update method",{"bfgs","sr1"});
62 initialize < int > ("maxiter", 20);
63 initialize < double > ("tol", 1.e-4,"geometry convergence threshold for the gradient norm");
64 initialize < double > ("value_precision", 1.e-12);
65 initialize < double > ("gradient_precision", 1.e-12);
66 initialize < bool > ("printtest", false);
67 initialize < std::string > ("cg_method", "polak_ribiere","conjugate gradients update",{"polak_ribiere","fletcher-reeves"});
68 initialize < std::vector<std::string> >
69 ("remove_dof", {"tx", "ty", "tz", "rx", "ry", "rz"}, "degree of freedom projected out: translation/rotation");
70 }
71
74 // read input file
75 read_input_and_commandline_options(world,parser,"geoopt");
77 }
78 std::string get_tag() const override {
79 return std::string("geoopt");
80 }
81
83 }
84
85 std::string update() const {return get<std::string>("update");}
86 std::string cg_method() const {return get<std::string>("cg_method");}
87 int maxiter() const {return get<int>("maxiter");}
88 double tol() const {return get<double>("tol");}
89 double value_precision() const {return get<double>("value_precision");}
90 double gradient_precision() const {return get<double>("gradient_precision");}
91 bool printtest() const {return get<bool>("printtest");}
92 std::vector<std::string> remove_dof() const {return get<std::vector<std::string> >("remove_dof");}
93
94};
95
96
97
98
99/// Molecular optimizer derived from the QuasiNewton optimizer
100
101/// Essentially the QuasiNewton optimizer, but with the additional feature
102/// of projecting out rotational and translational degrees of freedom
104private:
105 /// How to update the hessian: BFGS or SR1
106 std::shared_ptr<MolecularOptimizationTargetInterface> target;
108 double f=1.e10;
109 double gnorm=1.e10;
110
111public:
113
114 /// same ctor as the QuasiNewton optimizer
116 const std::shared_ptr<MolecularOptimizationTargetInterface>& tar)
117 : target(tar), parameters(world, parser) {
118 }
119
120 /// optimize the underlying molecule
121
122 /// @param[in] x the coordinates to compute energy and gradient
124 bool converge;
126// converge=optimize_conjugate_gradients(x);
127 return converge;
128 }
129
130 bool converged() const {
131 return gradient_norm();
132 }
133
135 return (gradient_norm()<parameters.tol() and (displacement.normf()/displacement.size())<parameters.tol());
136 }
137
138 double value() const {return 0.0;}
139
140 double gradient_norm() const {return gnorm;}
141
142 /// set an (initial) hessian
143 void set_hessian(const Tensor<double>& hess) {
144 h=copy(hess);
145 }
146
147
148private:
149
151
152 if(parameters.printtest()) target->test_gradient(x, parameters.value_precision());
153
154 bool h_is_identity = (h.size() == 0);
155 if (h_is_identity) {
156 int n = x.dim(0);
157 h = Tensor<double>(n,n);
158
159 // mass-weight the initial hessian
160 for (size_t i=0; i<target->molecule().natom(); ++i) {
161 h(3*i ,3*i )=1.0/(target->molecule().get_atom(i).mass);
162 h(3*i+1,3*i+1)=1.0/(target->molecule().get_atom(i).mass);
163 h(3*i+2,3*i+2)=1.0/(target->molecule().get_atom(i).mass);
164 }
165 h*=10.0;
166 madness::print("using the identity as initial Hessian");
167 } else {
168 Tensor<double> normalmodes;
170 target->molecule(),h,normalmodes,parameters.remove_dof());
171 madness::print("\ngopt: projected vibrational frequencies (cm-1)\n");
172 printf("frequency in cm-1 ");
173 for (int i=0; i<freq.size(); ++i) {
174 printf("%10.1f",constants::au2invcm*freq(i));
175 }
176
177 }
178
180
181 // the previous gradient
183 // the displacement
185
186 for (int iter=0; iter<parameters.maxiter(); ++iter) {
187 Tensor<double> gradient;
188
189 target->value_and_gradient(x, f, gradient);
190// print("gopt: new energy",f);
191// const double rawgnorm = gradient.normf()/sqrt(gradient.size());
192// print("gopt: raw gradient norm ",rawgnorm);
193
194 // remove external degrees of freedom (translation and rotation)
196 gradient=inner(gradient,project_ext);
197 gnorm = gradient.normf()/sqrt(gradient.size());
198// print("gopt: projected gradient norm ",gnorm);
199// const double gradratio=rawgnorm/gnorm;
200
201
202// if (iter == 1 && h_is_identity) {
203// // Default initial Hessian is scaled identity but
204// // prefer to reuse any existing approximation.
205// h.scale(gradient.trace(gp)/gp.trace(dx));
206// }
207
208 if (iter > 0) {
209 if (parameters.update() == "bfgs") QuasiNewton::hessian_update_bfgs(dx, gradient-gp,h);
210 else QuasiNewton::hessian_update_sr1(dx, gradient-gp,h);
211 }
212
213
216 syev(h, v, e);
217 Tensor<double> normalmodes;
219 target->molecule(),h,normalmodes,parameters.remove_dof());
220 madness::print("\ngopt: projected vibrational frequencies (cm-1)\n");
221 printf("frequency in cm-1 ");
222 for (int i=0; i<freq.size(); ++i) {
223 printf("%10.3f",constants::au2invcm*freq(i));
224 }
225 printf("\n");
226
227 // this will invert the hessian, multiply with the gradient and
228 // return the displacements
229 dx = new_search_direction2(gradient,h);
230
231 // line search only for large displacements > 0.01 bohr = 2pm
232 double step=1.0;
233 double maxdx=dx.absmax();
234 if (h_is_identity and (maxdx>0.01)) step = QuasiNewton::line_search(1.0, f,
235 dx.trace(gradient), x, dx,target, parameters.value_precision());
236
237 dx.scale(step);
238 x += dx;
239 gp = gradient;
240
241 double disp2=dx.normf()/dx.size();
242 printf(" QuasiNewton iteration %2d energy: %16.8f gradient %.2e displacement %.2e \n", iter,f,gnorm, disp2);
243 if (converged(dx)) break;
244 }
245
246 if (parameters.printtest()) {
247 print("final hessian");
248 print(h);
249 }
250 return converged(dx);
251 }
252
254
255// Tensor<double> project_ext=projector_external_dof(target->molecule());
256
257
258 // initial energy and gradient gradient
259 double energy=0.0;
260 Tensor<double> gradient;
261
262 // first step is steepest descent
264 Tensor<double> oldgradient;
265 Tensor<double> old_displacement(x.size());
266 old_displacement.fill(0.0);
267
268 for (int iter=1; iter<parameters.maxiter(); ++iter) {
269
270 // displace coordinates
271 if (iter>1) x+=displacement;
272
273 // compute energy and gradient
274 target->value_and_gradient(x, energy, gradient);
275// print("gopt: new energy",energy);
276 gnorm = gradient.normf()/sqrt(gradient.size());
277// print("gopt: raw gradient norm ",gnorm);
278
279 // remove external degrees of freedom (translation and rotation)
281 gradient=inner(gradient,project_ext);
282 gnorm = gradient.normf()/sqrt(gradient.size());
283// print("gopt: projected gradient norm ",gnorm);
284
285 // compute new displacement
286 if (iter==1) {
287 displacement=-gradient;
288 } else {
289 double beta=0.0;
290 if (parameters.cg_method()=="fletcher_reeves")
291 beta=gradient.normf()/oldgradient.normf();
292 if (parameters.cg_method()=="polak_ribiere")
293 beta=gradient.normf()/(gradient-oldgradient).normf();
294 displacement=-gradient + beta * old_displacement;
295 }
296
297 // save displacement for the next step
298 old_displacement=displacement;
299
300 if (converged(displacement)) break;
301 }
302
303 return converged(displacement);
304 }
305
306 /// effectively invert the hessian and multiply with the gradient
308 const Tensor<double>& hessian) const {
309 Tensor<double> dx, s;
310 double tol = parameters.gradient_precision();
311 double trust = 1.0; // This applied in spectral basis
312
313 // diagonalize the hessian:
314 // VT H V = lambda
315 // H^-1 = V lambda^-1 VT
317 syev(hessian, v, e);
318
319 // Transform gradient into spectral basis
320 // H^-1 g = V lambda^-1 VT g
321 Tensor<double> gv = inner(g,v); // this is VT g == gT V == gv
322
323 // Take step applying restriction
324 int nneg=0, nsmall=0, nrestrict=0;
325 for (int i=0; i<e.size(); ++i) {
326 if (e[i] < -tol) {
327 if (parameters.printtest()) printf(
328 " forcing negative eigenvalue to be positive %d %.1e\n", i, e[i]);
329 nneg++;
330 //e[i] = -2.0*e[i]; // Enforce positive search direction
331 e[i] = -0.1*e[i]; // Enforce positive search direction
332 }
333 else if (e[i] < tol) {
334 if (parameters.printtest()) printf(
335 " forcing small eigenvalue to be zero %d %.1e\n", i, e[i]);
336 nsmall++;
337 e[i] = tol;
338 gv[i]=0.0; // effectively removing this direction
339 }
340
341 // this is the step -lambda^-1 gv
342 gv[i] = -gv[i] / e[i];
343 if (std::abs(gv[i]) > trust) { // Step restriction
344 double gvnew = trust*std::abs(gv(i))/gv[i];
345 if (parameters.printtest()) printf(
346 " restricting step in spectral direction %d %.1e --> %.1e\n",
347 i, gv[i], gvnew);
348 nrestrict++;
349 gv[i] = gvnew;
350 }
351 }
352 if (nneg || nsmall || nrestrict)
353 printf(" nneg=%d nsmall=%d nrestrict=%d\n", nneg, nsmall, nrestrict);
354
355 // Transform back from spectral basis to give the displacements
356 // disp = -V lambda^-1 VT g = V lambda^-1 gv
357 return inner(v,gv);
358 }
359
360public:
361
362 /// compute the projector to remove transl. and rot. degrees of freedom
363
364 /// taken from http://www.gaussian.com/g_whitepap/vib.htm
365 /// I don't really understand the concept behind the projectors, but it
366 /// seems to work, and it is not written down explicitly anywhere.
367 /// NOTE THE ERROR IN THE FORMULAS ON THE WEBPAGE !
368 /// @param[in] do_remove_dof which dof to remove: x,y,z,Rx,Ry,Rz (transl/rot)
370 const std::vector<std::string>& remove_dof) {
371
372 // compute the translation vectors
373 Tensor<double> transx(3*mol.natom());
374 Tensor<double> transy(3*mol.natom());
375 Tensor<double> transz(3*mol.natom());
376 for (size_t i=0; i<mol.natom(); ++i) {
377 transx[3*i ]=sqrt(mol.get_atom(i).get_mass_in_au());
378 transy[3*i+1]=sqrt(mol.get_atom(i).get_mass_in_au());
379 transz[3*i+2]=sqrt(mol.get_atom(i).get_mass_in_au());
380 }
381
382 // compute the rotation vectors
383
384 // move the molecule to its center of mass and compute
385 // the moment of inertia tensor
387 Molecule mol2=mol;
388 mol2.translate(-1.0*com);
391
392 // diagonalize the moment of inertia
394 syev(I, v, e); // v being the "X" tensor on the web site
395 v=transpose(v);
396
397// Tensor<double> B(e.size());
398// for (long i=0; i<e.size(); ++i) B(i)=1.0/(2.0*e(i));
399// print("rotational constants in cm-1");
400// print(constants::au2invcm*B);
401
402 // rotation vectors
403 Tensor<double> rotx(3*mol.natom());
404 Tensor<double> roty(3*mol.natom());
405 Tensor<double> rotz(3*mol.natom());
406
407 for (size_t iatom=0; iatom<mol.natom(); ++iatom) {
408
409 // coordinates wrt the center of mass ("R" on the web site)
410 Tensor<double> coord(3);
411 coord(0l)=mol.get_atom(iatom).x-com(0l);
412 coord(1l)=mol.get_atom(iatom).y-com(1l);
413 coord(2l)=mol.get_atom(iatom).z-com(2l);
414
415 // note the wrong formula on the Gaussian website:
416 // multiply with sqrt(mass), do not divide!
417 coord.scale(sqrt(mol.get_atom(iatom).get_mass_in_au()));
418
419 // p is the dot product of R and X on the web site
420 Tensor<double> p=inner(coord,v);
421
422 // Eq. (5)
423 rotx(3*iatom + 0)=p(1)*v(0,2)-p(2)*v(0,1);
424 rotx(3*iatom + 1)=p(1)*v(1,2)-p(2)*v(1,1);
425 rotx(3*iatom + 2)=p(1)*v(2,2)-p(2)*v(2,1);
426
427 roty(3*iatom + 0)=p(2)*v(0,0)-p(0l)*v(0,2);
428 roty(3*iatom + 1)=p(2)*v(1,0)-p(0l)*v(1,2);
429 roty(3*iatom + 2)=p(2)*v(2,0)-p(0l)*v(2,2);
430
431 rotz(3*iatom + 0)=p(0l)*v(0,1)-p(1)*v(0,0);
432 rotz(3*iatom + 1)=p(0l)*v(1,1)-p(1)*v(1,0);
433 rotz(3*iatom + 2)=p(0l)*v(2,1)-p(1)*v(2,0);
434
435 }
436
437 // move the translational and rotational vectors to a common tensor
438 auto tmp=remove_dof;
439 for (auto& t : tmp) t=commandlineparser::tolower(t);
440 bool remove_Tx=std::find(tmp.begin(), tmp.end(), "tx")!=tmp.end();
441 bool remove_Ty=std::find(tmp.begin(), tmp.end(), "ty")!=tmp.end();
442 bool remove_Tz=std::find(tmp.begin(), tmp.end(), "tz")!=tmp.end();
443 bool remove_Rx=std::find(tmp.begin(), tmp.end(), "rx")!=tmp.end();
444 bool remove_Ry=std::find(tmp.begin(), tmp.end(), "ry")!=tmp.end();
445 bool remove_Rz=std::find(tmp.begin(), tmp.end(), "rz")!=tmp.end();
446 Tensor<double> ext_dof(6,3*mol.natom());
447 if (remove_Tx) ext_dof(0l,_)=transx;
448 if (remove_Ty) ext_dof(1l,_)=transy;
449 if (remove_Tz) ext_dof(2l,_)=transz;
450
451 if (remove_Rx) ext_dof(3l,_)=rotx;
452 if (remove_Ry) ext_dof(4l,_)=roty;
453 if (remove_Rz) ext_dof(5l,_)=rotz;
454 print("removing dof ",remove_Tx, remove_Ty, remove_Tz, remove_Rx, remove_Ry, remove_Rz);
455
456 // normalize
457 for (int i=0; i<6; ++i) {
458 double norm=ext_dof(i,_).normf();
459 if (norm>1.e-14) ext_dof(i,_).scale(1.0/norm);
460 else ext_dof(i,_)=0.0;
461 }
462
463 // compute overlap to orthonormalize the projectors
464 Tensor<double> ovlp=inner(ext_dof,ext_dof,1,1);
465 syev(ovlp,v,e);
466 ext_dof=inner(v,ext_dof,0,0);
467
468 // normalize or remove the dof if necessary (e.g. linear molecules)
469 for (int i=0; i<6; ++i) {
470 if (e(i)<1.e-14) {
471 ext_dof(i,_).scale(0.0); // take out this degree of freedom
472 } else {
473 ext_dof(i,_).scale(1.0/sqrt(e(i))); // normalize
474 }
475 }
476
477 // construct projector on the complement of the rotations
478 Tensor<double> projector(3*mol.natom(),3*mol.natom());
479 for (size_t i=0; i<3*mol.natom(); ++i) projector(i,i)=1.0;
480
481 // compute the outer products of the projectors
482 // 1- \sum_i | t_i >< t_i |
483 projector-=inner(ext_dof,ext_dof,0,0);
484
485 return projector;
486
487 }
488
489 /// remove translational degrees of freedom from the hessian
490
491 /// @param[in] do_remove_dof which dof to remove: x,y,z,Rx,Ry,Rz (transl/rot)
492 static void remove_external_dof(Tensor<double>& hessian, const Molecule& mol,
493 const std::vector<std::string>& remove_dof) {
494
495 // compute the translation of the center of mass
496 Tensor<double> projector_ext=projector_external_dof(mol,remove_dof);
497
498 // this is P^T * H * P
499 hessian=inner(projector_ext,inner(hessian,projector_ext),0,0);
500 }
501
502
503 /// returns the vibrational frequencies
504
505 /// @param[in] hessian the hessian matrix (not mass-weighted)
506 /// @param[out] normalmodes the normal modes
507 /// @param[in] project_tr whether to project out translation and rotation
508 /// @param[in] print_hessian whether to print the hessian matrix
509 /// @return the frequencies in atomic units
511 const Tensor<double>& hessian, Tensor<double>& normalmodes,
512 const std::vector<std::string>& remove_dof={}, const bool print_hessian=false) {
513
514 // compute mass-weighing matrices
515 Tensor<double> M=molecule.massweights();
516 Tensor<double> Minv(3*molecule.natom(),3*molecule.natom());
517 for (size_t i=0; i<3*molecule.natom(); ++i) Minv(i,i)=1.0/M(i,i);
518
519 // mass-weight the hessian
520 Tensor<double> mwhessian=inner(M,inner(hessian,M));
521
522 // remove translation and rotation
523 if (remove_dof.size()>0) MolecularOptimizer::remove_external_dof(mwhessian,molecule,remove_dof);
524
525 if (print_hessian) {
526 if (remove_dof.size()>0) {
527 print("mass-weighted hessian with translation and rotation projected out");
528 } else {
529 print("mass-weighted unprojected hessian");
530 }
531 Tensor<double> mmhessian=inner(Minv,inner(mwhessian,Minv));
532 print(mwhessian);
533 print("mass-weighted unprojected hessian; mass-weighing undone");
534 print(mmhessian);
535 }
536
537 Tensor<double> freq;
538 syev(mwhessian,normalmodes,freq);
539 for (long i=0; i<freq.size(); ++i) {
540 if (freq(i)>0.0) freq(i)=sqrt(freq(i)); // real frequencies
541 else freq(i)=-sqrt(-freq(i)); // imaginary frequencies
542 }
543 return freq;
544 }
545
546
548 const Tensor<double>& normalmodes) {
549
550 Tensor<double> M=molecule.massweights();
552 Tensor<double> L=copy(normalmodes);
554 Tensor<double> MDL=inner(M,DL);
555 Tensor<double> mu(3*molecule.natom());
556
557 for (size_t i=0; i<3*molecule.natom(); ++i) {
558 double mu1=0.0;
559 for (size_t j=0; j<3*molecule.natom(); ++j) mu1+=MDL(j,i)*MDL(j,i);
560 if (mu1>1.e-14) mu(i)=1.0/(mu1*constants::atomic_mass_in_au);
561 }
562 return mu;
563 }
564
565};
566
567}
568
569#endif //MADNESS_CHEM_MOLECULAR_OPTIMIZER_H__INCLUDED
double y
Definition molecule.h:62
double x
Definition molecule.h:62
double z
Definition molecule.h:62
double get_mass_in_au() const
return the mass in atomic units (electron mass = 1 a.u.)
Definition molecule.h:109
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
Definition molecular_optimizer.h:56
std::vector< std::string > remove_dof() const
Definition molecular_optimizer.h:92
MolecularOptimizationParameters(World &world, const commandlineparser &parser)
Definition molecular_optimizer.h:72
MolecularOptimizationParameters()
ctor reading out the input file
Definition molecular_optimizer.h:60
bool printtest() const
Definition molecular_optimizer.h:91
double tol() const
Definition molecular_optimizer.h:88
std::string cg_method() const
Definition molecular_optimizer.h:86
std::string get_tag() const override
Definition molecular_optimizer.h:78
double gradient_precision() const
Definition molecular_optimizer.h:90
double value_precision() const
Definition molecular_optimizer.h:89
std::string update() const
Definition molecular_optimizer.h:85
void set_derived_values()
Definition molecular_optimizer.h:82
int maxiter() const
Definition molecular_optimizer.h:87
Molecular optimizer derived from the QuasiNewton optimizer.
Definition molecular_optimizer.h:103
void set_hessian(const Tensor< double > &hess)
set an (initial) hessian
Definition molecular_optimizer.h:143
bool optimize_quasi_newton(Tensor< double > &x)
Definition molecular_optimizer.h:150
bool optimize(Tensor< double > &x)
optimize the underlying molecule
Definition molecular_optimizer.h:123
Tensor< double > h
Definition molecular_optimizer.h:107
double gradient_norm() const
Definition molecular_optimizer.h:140
MolecularOptimizationParameters parameters
Definition molecular_optimizer.h:112
static Tensor< double > compute_frequencies(const Molecule &molecule, const Tensor< double > &hessian, Tensor< double > &normalmodes, const std::vector< std::string > &remove_dof={}, const bool print_hessian=false)
returns the vibrational frequencies
Definition molecular_optimizer.h:510
bool converged() const
Definition molecular_optimizer.h:130
bool converged(const Tensor< double > &displacement) const
Definition molecular_optimizer.h:134
static Tensor< double > projector_external_dof(const Molecule &mol, const std::vector< std::string > &remove_dof)
compute the projector to remove transl. and rot. degrees of freedom
Definition molecular_optimizer.h:369
static Tensor< double > compute_reduced_mass(const Molecule &molecule, const Tensor< double > &normalmodes)
Definition molecular_optimizer.h:547
double f
Definition molecular_optimizer.h:108
bool optimize_conjugate_gradients(Tensor< double > &x)
Definition molecular_optimizer.h:253
MolecularOptimizer(World &world, const commandlineparser &parser, const std::shared_ptr< MolecularOptimizationTargetInterface > &tar)
same ctor as the QuasiNewton optimizer
Definition molecular_optimizer.h:115
std::shared_ptr< MolecularOptimizationTargetInterface > target
How to update the hessian: BFGS or SR1.
Definition molecular_optimizer.h:106
Tensor< double > new_search_direction2(const Tensor< double > &g, const Tensor< double > &hessian) const
effectively invert the hessian and multiply with the gradient
Definition molecular_optimizer.h:307
static void remove_external_dof(Tensor< double > &hessian, const Molecule &mol, const std::vector< std::string > &remove_dof)
remove translational degrees of freedom from the hessian
Definition molecular_optimizer.h:492
double gnorm
Definition molecular_optimizer.h:109
double value() const
Definition molecular_optimizer.h:138
Definition molecule.h:129
void translate(const Tensor< double > &translation)
translate the molecule
Definition molecule.cc:709
const Atom & get_atom(unsigned int i) const
Definition molecule.cc:452
Tensor< double > center_of_mass() const
compute the center of mass
Definition molecule.cc:878
size_t natom() const
Definition molecule.h:415
Tensor< double > moment_of_inertia() const
Definition molecule.cc:894
class for holding the parameters for calculation
Definition QCCalculationParametersBase.h:294
virtual void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition QCCalculationParametersBase.h:330
static double line_search(double a1, double f0, double dxgrad, const Tensor< double > &x, const Tensor< double > &dx, std::shared_ptr< OptimizationTargetInterface > target, double value_precision)
make this static for other QN classed to have access to it
Definition solvers.cc:113
static void hessian_update_bfgs(const Tensor< double > &dx, const Tensor< double > &dg, Tensor< double > &hessian)
make this static for other QN classed to have access to it
Definition solvers.cc:179
static void hessian_update_sr1(const Tensor< double > &s, const Tensor< double > &y, Tensor< double > &hessian)
make this static for other QN classed to have access to it
Definition solvers.cc:166
A tensor is a multidimensional array.
Definition tensor.h:317
scalar_type absmax(long *ind=0) const
Return the absolute maximum value (and if ind is non-null, its index) in the Tensor.
Definition tensor.h:1754
float_scalar_type normf() const
Returns the Frobenius norm of the tensor.
Definition tensor.h:1726
Tensor< T > & fill(T x)
Inplace fill with a scalar (legacy name)
Definition tensor.h:562
IsSupported< TensorTypeData< Q >, Tensor< T > & >::type scale(Q x)
Inplace multiplication by scalar of supported type (legacy name)
Definition tensor.h:686
A parallel world class.
Definition world.h:132
double(* energy)()
Definition derivatives.cc:58
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
const double beta
Definition gygi_soltion.cc:62
static const double v
Definition hatom_sf_dirac.cc:20
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
constexpr double au2invcm
conversion from atomic units in reciprocal centimeter
Definition constants.h:273
constexpr double atomic_mass_in_au
Atomic mass in atomic units.
Definition constants.h:270
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
response_space transpose(response_space &f)
Definition basic_operators.cc:10
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:451
static const Slice _(0,-1, 1)
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:225
NDIM const Function< R, NDIM > & g
Definition mra.h:2481
double inner(response_space &a, response_space &b)
Definition response_functions.h:640
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2066
void syev(const Tensor< T > &A, Tensor< T > &V, Tensor< typename Tensor< T >::scalar_type > &e)
Real-symmetric or complex-Hermitian eigenproblem.
Definition lapack.cc:969
static long abs(long a)
Definition tensor.h:218
const double mu
Definition navstokes_cosines.cc:95
static const double L
Definition rk.cc:46
Defines interfaces for optimization and non-linear equation solvers.
Definition test_ar.cc:204
Definition molecular_optimizer.h:46
virtual Molecule & molecule()
return the molecule of the target
Definition molecular_optimizer.h:49
The interface to be provided by functions to be optimized.
Definition solvers.h:176
The interface to be provided by optimizers.
Definition solvers.h:206
very simple command line parser
Definition commandlineparser.h:15
static std::string tolower(std::string s)
make lower case
Definition commandlineparser.h:86
static const double_complex I
Definition tdse1d.cc:164
void converge(World &world, functionT &potn, functionT &psi, double &eps)
Definition tdse.cc:441
double norm(const T i1)
Definition test_cloud.cc:72
void e()
Definition test_sig.cc:75
static Molecule molecule
Definition testperiodicdft.cc:39