MADNESS 0.10.1
nemo.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 \file examples/nemo.h
34 \brief solve the HF equations using numerical exponential MOs
35
36 The source is
37 <a href=http://code.google.com/p/m-a-d-n-e-s-s/source/browse/local
38 /trunk/src/apps/examples/nemo.h>here</a>.
39
40 */
41
42#ifndef NEMO_H_
43#define NEMO_H_
44
45#include <madness/mra/mra.h>
48#include <madness/mra/lbdeux.h>
49#include<madness/chem/SCF.h>
55#include <madness/mra/vmra.h>
56#include<madness/chem/pcm.h>
57#include<madness/chem/AC.h>
59#include "Results.h"
63
64namespace madness {
65
66class PNO;
67class OEP;
68
69
71
72public:
73
74 explicit NemoBase(World& w) : world(w) {}
75
76 virtual ~NemoBase() {}
77
78 virtual std::shared_ptr<Fock<double,3>> make_fock_operator() const {
79 MADNESS_EXCEPTION("implement make_fock operator for your derived NemoBase class",1);
80 return std::shared_ptr<Fock<double,3>>();
81 }
82
83 /// create an instance of the derived object based on the input parameters
84 std::shared_ptr<NuclearCorrelationFactor> get_ncf_ptr() const {
85 return ncf;
86 }
87
88 /// normalize the nemos
89 template<typename T, std::size_t NDIM>
90 void static normalize(std::vector<Function<T,NDIM> >& nemo,
92
93 if (nemo.size()==0) return;
94 World& world=nemo[0].world();
95 // compute the norm of the reconstructed orbitals, includes the factor; the
96 // metric spans the molecule, the nemos are local: screened like the other
97 // nemo products (SCF::vtol)
98 std::vector<Function<T,NDIM> > mos = (metric.is_initialized())
100 std::vector<double> norms = norm2s(world, mos);
101
102 // scale the nemos, excludes the nuclear correlation factor
103 std::vector<double> invnorm(norms.size());
104 for (std::size_t i = 0; i < norms.size(); ++i)
105 invnorm[i] = 1.0 / norms[i];
106 scale(world, nemo, invnorm);
107 }
108
109 /// reproject a set of nemos onto the current k and thresh
110
111 /// The counterpart of SCF::project (chem/SCF.cc) for regularized orbitals.
112 /// SCF::project must NOT be used here: it normalizes with the plain L2
113 /// metric, while nemos are normalized against R^2. Without this, a protocol
114 /// step that changes k leaves the nemos at the old polynomial order while
115 /// FunctionDefaults, R and the potentials have already moved to the new one.
116 template<typename T, std::size_t NDIM>
118 const Function<double,NDIM>& metric) const {
119
120 if (nemo.size()==0) return;
123 if (nemo.front().k()==k) { // nothing to do but retighten
125 return;
126 }
127
128 if (world.rank()==0) print("reprojecting nemos from k =",nemo.front().k(),"to k =",k);
130 for (std::size_t i=0; i<nemo.size(); ++i)
131 nemo[i]=madness::project(nemo[i],k,thresh,false);
132 world.gop.fence();
134 normalize(nemo,metric);
135 }
136
137 template<typename T>
138 static Tensor<T> Q2(const Tensor<T>& s) {
139 Tensor<T> Q = -0.5*s;
140 for (int i=0; i<s.dim(0); ++i) Q(i,i) += 1.5;
141 return Q;
142 }
143
144 /// orthonormalize the vectors
145 template<typename T, std::size_t NDIM>
148 const double trantol=FunctionDefaults<NDIM>::get_thresh()*0.01) const {
149
150 if (nemo.size()==0) return;
151 normalize(nemo,metric);
152 double maxq;
153 do {
154 std::vector<Function<T,NDIM> > Rnemo = (metric.is_initialized())
156 Tensor<T> Q = Q2(matrix_inner(world, Rnemo, Rnemo));
157 maxq=0.0;
158 for (int i=0; i<Q.dim(0); ++i)
159 for (int j=0; j<i; ++j)
160 maxq = std::max(maxq,std::abs(Q(i,j)));
161
162 Q.screen(trantol); // ???? Is this really needed?
163 nemo = transform(world, nemo, Q, trantol, true);
165// if (world.rank() == 0) print("ORTHOG2: maxq trantol", maxq, trantol);
166
167 } while (maxq>0.01);
168 normalize(nemo,metric);
169 }
170
171 template<typename T, std::size_t NDIM>
173 return sum(world,abssq(world,nemo)).truncate();
174 }
175
176 virtual bool need_recompute_factors_and_potentials(const double thresh) const {
177 bool need=false;
178 const int k=FunctionDefaults<3>::get_k();
179 if ((not R.is_initialized()) or (R.thresh()>thresh)) need=true;
180 if (not ncf) need=true;
181 if ((not R_square.is_initialized()) or (R_square.thresh()>thresh)) need=true;
182 if ((not U1dotU1.is_initialized()) or (U1dotU1.thresh()>thresh)) need=true;
183 // k must be checked independently of thresh: re-entering a protocol at
184 // the same threshold but a different k (a restart, or a user-pinned k)
185 // would otherwise reuse R and R_square at the old k and silently mix
186 // polynomial orders in every product with the nemos.
187 if (R.is_initialized() and R.k()!=k) need=true;
188 if (R_square.is_initialized() and R_square.k()!=k) need=true;
189 if (U1dotU1.is_initialized() and U1dotU1.k()!=k) need=true;
190 return need;
191 };
192
194 R.clear();
195 R_square.clear();
196 U1dotU1.clear();
197 ncf.reset();
198 };
199
201 const std::shared_ptr<PotentialManager>& pm,
202 const std::pair<std::string,double>& ncf_parameter) {
203
204 // construct the nuclear correlation factor:
205 if (not ncf) {
207 }
208
209 // re-project the ncf
211 R = ncf->function();
213 R_square = ncf->square();
215 // from its functor, not from the squared U1 components: their smoothed unit
216 // vector vanishes at the nuclei (see assemble_nemo_ddens in xcfunctional_libxc.cc)
220 }
221
222 /// compute the nuclear gradients
224 const Molecule& molecule) const;
225
226 /// compute kinetic energy as square of the "analytical" expectation value
227
228 /// @param[in] the nemo orbitals F
229 /// @return T = 1/2 \sum_i \int R^2 U1.U1 F^2 + 2 R^2 U1.grad(F) + R^2 grad(F)^2
230 template<typename T, std::size_t NDIM>
231 double compute_kinetic_energy(const std::vector<Function<T,NDIM> >& nemo) const {
232
233 // T = 0.5\sum_i \int R^2 U1.U1 F^2 - 2 R^2 U1.grad(F) F + R^2 grad(F)^2
234 // = 0.5 (<U1.U1 | rho > + <R^2|grad(F)^2> - 2<R^2 | U1.grad(F) >)
235 // note: U1=-grad(R)/R
236 //auto id=nemo.front().world().id();
237 //auto id1=R_square.world().id();
238 //auto worldid=world.id();
239 world.gop.fence();
241 double ke1=inner(dens,U1dotU1); // cached beside R and R_square
242
243 double ke2=0.0;
244 double ke3=0.0;
245 //double ke3_real=0.0;
246 //double ke3_imag=0.0;
247
248 for (size_t axis = 0; axis < NDIM; axis++) {
249 real_derivative_3d D = free_space_derivative<double, NDIM>(world, axis);
250 const std::vector<Function<T,NDIM> > dnemo = apply(world, D, nemo);
251
252 real_function_3d term2=dot(world,dnemo,nemo)*ncf->U1(axis);
253 double tmp=-2.0*inner(R_square,term2);
254// ke3_real -=2.0*std::real(tmp);
255// ke3_imag -=2.0*std::imag(tmp);
256 ke3 +=tmp;
257
258 const real_function_3d term1=dot(world,dnemo,dnemo);
259 world.gop.fence();
260 ke2 += inner(term1,R_square);
261
262 }
263// if (ke3_imag>1.e-8) {
264// print("kinetic energy, imaginary part: ",ke3_imag);
265// MADNESS_EXCEPTION("imaginary kinetic energy",1);
266// }
267// double ke=2.0*(ke1+ke2+ke3_real); // closed shell
268 double ke=2.0*(ke1+ke2+ke3); // closed shell
269 return 0.5*ke;
270 }
271
272 /// compute kinetic energy as square of the "analytical" derivative of the orbitals
273
274 /// @param[in] the nemo orbitals F
275 /// @return T = 1/2 \sum_i || grad(R)*F_i + R*grad(F_i)||^2
276 template<typename T, std::size_t NDIM>
277 double compute_kinetic_energy1(const std::vector<Function<T,NDIM> >& nemo) const {
278 timer timer1(world);
279 double ke=0.0;
280 for (int i=0; i<nemo.size(); ++i) {
281 double fnorm2=norm2(world,-1.0*R*ncf->U1vec()*nemo[i] + R*grad(nemo[i]));
282 ke+=2.0*fnorm2*fnorm2;
283 }
284 timer1.end("compute_kinetic_energy1");
285 return 0.5*ke;
286 }
287
288
289 /// compute kinetic energy as square of the "analytical" derivative of the orbitals
290
291 /// @param[in] the nemo orbitals F
292 /// @return T = 1/2 \sum_i || grad(R)*F_i + R*grad(F_i)||^2
293 template<typename T, std::size_t NDIM>
294 double compute_kinetic_energy1a(const std::vector<Function<T,NDIM> >& nemo) const {
295 timer timer1(world);
296 double ke=0.0;
297 for (int i=0; i<NDIM; ++i) {
298 std::vector< std::shared_ptr< Derivative<T,NDIM> > > grad=
299 gradient_operator<T,NDIM>(world);
300 double fnorm2=norm2(world,R*(-1.0*ncf->U1(i)*nemo + apply(world,*(grad[i]),nemo)));
301 ke+=2.0*fnorm2*fnorm2;
302 }
303 timer1.end("compute_kinetic_energy1a");
304 return 0.5*ke;
305 }
306
307 /// compute kinetic energy as direct derivative of the orbitals (probably imprecise)
308
309 /// @param[in] the nemo orbitals F
310 /// @return T = 1/2 \sum_i || grad(R*F_i)||^2
311 template<typename T, std::size_t NDIM>
312 double compute_kinetic_energy2(const std::vector<Function<T,NDIM> >& nemo) const {
313
314 // it's ok to use phi here, no regularization necessary for this eigenvalue
315 double E_kin = 0.0;
316 for (int axis = 0; axis < 3; axis++) {
317 real_derivative_3d D = free_space_derivative<double, 3>(world, axis);
318 const vecfuncT dphi = apply(world, D,R*nemo);
319 E_kin += 0.5 * (inner(world, dphi, dphi)).sum();
320 // -1/2 sum <Psi|Nabla^2|Psi> = 1/2 sum <NablaPsi|NablaPsi> (integration by parts)
321 }
322 E_kin *= 2.0; // 2 because closed shell
323 return E_kin;
324 }
325
326
327 bool check_convergence(const std::vector<double> energies,
328 const std::vector<double> oldenergies, const double bsh_norm,
329 const double delta_density, const CalculationParameters& param,
330 const double econv, const double dconv) const {
331
332 double maxenergychange=fabs(energies.size()-oldenergies.size()); // >0 if oldenergyvec not initialized
333 for (auto iter1=energies.begin(), iter2=oldenergies.begin();
334 (iter1!=energies.end() and iter2!=oldenergies.end()); iter1++, iter2++) {
335 maxenergychange=std::max(maxenergychange,fabs(*iter1 - *iter2));
336 }
337 double delta_energy=fabs(energies[0]-oldenergies[0]);
338
339 bool bsh_conv=param.converge_bsh_residual() ? bsh_norm<dconv : true;
340 bool total_energy_conv=param.converge_total_energy() ? delta_energy<econv : true;
341 bool each_energy_conv=param.converge_each_energy() ? maxenergychange<econv*3.0 : true;
342 bool density_conv=param.converge_density() ? delta_density<dconv : true;
343
344 if (world.rank()==0 and param.print_level()>2) {
345 std::stringstream line;
346 line << "convergence: bshresidual, energy change, max energy change, density change "
347 << std::scientific << std::setprecision(1)
348 << bsh_norm << " " << delta_energy << " "
349 << maxenergychange << " " << delta_density;
350 print(line.str());
351 }
352
353 return (bsh_conv and density_conv and each_energy_conv and total_energy_conv);
354 }
355
357
358 /// the nuclear correlation factor
359 std::shared_ptr<NuclearCorrelationFactor> ncf;
360
361 /// the nuclear correlation factor
363
364 /// the square of the nuclear correlation factor
366
367 /// U1.U1 = |grad R|^2 / R^2, by which the physical kinetic energy exceeds the regularized one
369
370
371};
372
373
374/// The Nemo class
375class Nemo: public NemoBase, public QCPropertyInterface {
376 typedef std::shared_ptr<real_convolution_3d> poperatorT;
377 friend class PNO;
378 friend class TDHF;
379
380public:
381 /// class holding parameters for a nemo calculation beyond the standard dft parameters from moldft
383 static constexpr char const* tag = "nemo";
384
389
393
394 std::string get_tag() const override {
395 return std::string("dft");
396 }
397
399 // check if parameters are initialized for a nemo calculation already
400 if (parameter_exists("ncf")) return;
401 initialize<std::pair<std::string,double> > ("ncf",{"slater",2.0},"nuclear correlation factor");
402 initialize<bool> ("hessian",false,"compute the hessian matrix");
403 initialize<bool> ("read_cphf",false,"read the converged orbital response for nuclear displacements from file");
404 initialize<bool> ("restart_cphf",false,"read the guess orbital response for nuclear displacements from file");
405 initialize<bool> ("purify_hessian",false,"symmetrize the hessian matrix based on atomic charges");
406 }
407
408 std::pair<std::string,double> ncf() const {return get<std::pair<std::string,double> >("ncf");}
409 bool hessian() const {return get<bool>("hessian");}
410
411 };
412
413
414public:
415 std::filesystem::path work_dir;
416
417 /// ctor
418
419 /// @param[in] world1 the world
420 /// @param[in] calc the SCF
421// Nemo(World& world1, std::shared_ptr<SCF> calc, const std::string inputfile);
422
423 Nemo(World& world, const commandlineparser& parser);
424
425 /// \p pcm_param defaults to the bare `pcm` group; the solvent still arrives from
426 /// param.pcm_data() via PCMParameters::set_derived_values, so a caller that never
427 /// parsed a deck keeps working.
429 const Molecule& molecule, const PCMParameters& pcm_param = PCMParameters());
430
431 std::string name() const {return "nemo";}
432 bool selftest() {return false;}
433
434 static void help() {
435 print_header2("help page for NEMO");
436 print("The nemo code computes Hartree-Fock and DFT energies, gradients and hessians using a nuclear correlation factor");
437 print("that regularizes the singular nuclear potential. SCF orbitals for the basis for post-SCF calculations like");
438 print("excitation energies (cis), correlation energies (cc2), local potentials (oep), etc\n");
439 print("A nemo calculation input is mostly identical to a moldft calculation input, but it uses the additional input");
440 print("parameter ncf (nuclear correlation factor)\n");
441 print("You can print all available calculation parameters by running\n");
442 print("nemo --print_parameters\n");
443 print("You can perform a simple calculation by running\n");
444 print("nemo --geometry=h2o.xyz\n");
445 print("provided you have an xyz file in your directory.\n\n");
446 print("To see what a restart archive holds -- geometry, k, the precision it");
447 print("converged to, whether it is moldft or nemo orbitals -- without starting");
448 print("a calculation:\n");
449 print("nemo --restart_info=<prefix>\n");
450
451 }
452
453 static void print_parameters() {
455 print("default parameters for the nemo program are");
456 param.print("nemo","end");
457 print("\n\nthe molecular geometry must be specified in a separate block:");
459 }
460
461
462 bool check_converged(const Tensor<double>& x) const {
463 double xsq = x.sumsq();
464 return (xsq == coords_sum);
465 }
466
467 virtual double value() {return value(calc->molecule.get_all_coords());}
468
469 virtual double value(const Tensor<double>& x);
470
471 void load_mos(World& w) {
472 calc->load_mos(w);
473 }
474
475 /// compute dipole moment and gradient at the current geometry
476 virtual nlohmann::json analyze() const;
477
478 /// compute the nuclear gradients
480
481 bool provides_gradient() const {return true;}
482
483 /// returns the molecular hessian matrix at structure x
485
486 /// construct the fock operator based on the calculation parameters (K or XC?)
487 virtual std::shared_ptr<Fock<double,3>> make_fock_operator() const;
488
489 /// purify and symmetrize the hessian
490
491 /// The hessian should be symmetric, but it is not, because
492 /// \f[
493 /// \langle i^{Y_B}|H^{X_A}|i\rangle \neq \langle i|H^{X_A}|i^{Y_B}\rangle
494 /// \f]
495 /// does holds analytically, but not numerically. If the two numbers
496 /// differ, pick the more trustworthy, which is the one with a heavy
497 /// atom causing the perturbed density and the light atom being the
498 /// nuclear singularity.
499 /// @param[in] hessian the raw hessian
500 /// @return a symmetrized hessian
502
503
504 /// solve the CPHF equations for the nuclear displacements
505
506 /// this function computes that part of the orbital response that is
507 /// orthogonal to the occupied space. If no NCF's are used this
508 /// corresponds to the normal response. If NCF's are used the part
509 /// parallel to the occupied space must be added!
510 /// \f[
511 /// F^X = F^\perp + F^\parallel
512 /// \f]
513 /// cf parallel_CPHF()
514 /// @param[in] iatom the atom A to be moved
515 /// @param[in] iaxis the coordinate X of iatom to be moved
516 /// @return \ket{i^X} or \ket{F^\perp}
517 vecfuncT solve_cphf(const size_t iatom, const int iaxis, const Tensor<double>& fock,
518 const vecfuncT& guess, const vecfuncT& rhsconst,
519 const Tensor<double>& incomplete_hessian, const vecfuncT& parallel,
520 const SCFProtocol& p, const std::string& xc_data) const;
521
522 /// solve the CPHF equation for all displacements
523
524 /// this function computes the nemo response F^X
525 /// \f[
526 /// F^X = F^\perp + F^\parallel
527 /// \f]
528 /// To reconstruct the unregularized orbital response (not recommended):
529 /// \f[
530 /// i^X = R^X F + R F^X
531 /// \f]
532 /// The orbital response i^X constructed in this way is automatically
533 /// orthogonal to the occupied space because of the parallel term F^\parallel
534 /// @return a vector of the nemo response F^X for all displacements
535 std::vector<vecfuncT> compute_all_cphf();
536
537 /// this function computes that part of the orbital response that is
538 /// parallel to the occupied space.
539 /// \f[
540 /// F^X = F^\perp + F^\parallel
541 /// \f]
542 /// If no NCF's are used F^\parallel vanishes.
543 /// If NCF's are used this term does not vanish because the derivatives of
544 /// the NCF does not vanish, and it is given by
545 /// \f[
546 /// F_i^\parallel = -\frac{1}{2}\sum_k|F_k ><F_k | (R^2)^X | F_i>
547 /// \f]
548 vecfuncT compute_cphf_parallel_term(const size_t iatom, const int iaxis) const;
549
550 /// compute the IR intensities in the double harmonic approximation
551
552 /// use the projected normal modes; units are km/mol
553 /// @param[in] normalmodes the normal modes
554 /// @param[in] dens_pt the perturbed densities for each nuclear displacement
556 const vecfuncT& dens_pt) const;
557
558 std::shared_ptr<SCF> get_calc() const {return calc;}
559
561 const CalculationParameters& get_calc_param() const {return calc->param;}
562
563 PCM get_pcm()const{return pcm;}
564
565 /// compute the Fock matrix from scratch
566 tensorT compute_fock_matrix(const vecfuncT& nemo, const tensorT& occ) const;
567
568 /// return a reference to the molecule
569 Molecule& molecule() {return calc->molecule;}
570
571 /// return a reference to the molecule
573 return calc->molecule;
574 }
575
576 /// make the density (alpha or beta)
578 const vecfuncT& nemo) const;
579
580 /// make the density using different bra and ket vectors
581
582 /// e.g. for computing the perturbed density \sum_i \phi_i \phi_i^X
583 /// or when using nemos: \sum_i R2nemo_i nemo_i
585 const vecfuncT& bra, const vecfuncT& ket, const bool refine=false) const;
586
587 /// make the derivative of the density
588
589 /// \f$ \nabla\rho = 2R^X R \rho_R + R^2\nabla \rho_R \f$
590 /// @param[in] rhonemo the regularized density
591 /// @param[in] axis the component of the nabla operator
592 /// @return the gradient of the *reconstructed* density
594 const int axis) const;
595
596 /// compute the reduced densities sigma (gamma) for GGA functionals
598 const real_function_3d& rho2) const;
599
600
601 /// the Laplacian of the density
602
603
604 /// compute the kinetic energy potential using Eq. (16) of
605 /// R. A. King and N. C. Handy, “Kinetic energy functionals from the Kohn–Sham potential,”
606 /// Phys. Chem. Chem. Phys., vol. 2, no. 22, pp. 5049–5056, 2000.
608
609
610 /// smooth a function by projecting it onto k-1 and then average with k
611
612 /// kept it here for further testing
614 int k=f.get_impl()->get_k();
615 real_function_3d fproj=project(f,k-1);
616 real_function_3d freproj=project(fproj,k);
617 f=0.5*(f+freproj);
618 }
619
620protected:
621
622 std::shared_ptr<SCF> calc;
623
624public:
626
627protected:
629
630public:
631
632 /// return the symmetry_projector
636
637private:
638
639 /// sum of square of coords at last solved geometry
640 mutable double coords_sum;
641
642protected:
643 /// a poisson solver
644 std::shared_ptr<real_convolution_3d> poisson;
645
646 /// asymptotic correction for DFT
648
649// /// apply the AC scheme of Tozer/Handy with the multipole approximation
650// Function<double,3> apply_ac(const Function<double,3>& vxc)const{
651// return ac.apply(vxc);
652// }
653//
654// /// apply the AC scheme of Tozer/Handy using the hartree potential
655// Function<double,3> apply_ac(const Function<double,3>& vxc, const Function<double,3>& vhartree)const{
656// return ac.apply(vxc,vhartree);
657// }
658//
659// /// apply the AC scheme of Tozer/Handy
660// Function<double,3> apply_ac_excited(Function<double,3>& vxc, const Function<double,3>& vhartree)const{
661// return ac.apply_potential(vxc,vhartree);
662// }
663
664private:
665 /// polarizable continuum model
667// AC<3> ac;
668
669protected:
670 /// adapt the thresholds consistently to a common value
671 void set_protocol(const double thresh) {
672
673 // sets FunctionDefaults, including k -- which SCF::set_protocol derives
674 // from thresh unless the user pinned it
675 calc->set_protocol<3>(world,thresh);
676
678 timer timer1(world,get_calc_param().print_level()>2);
679 get_calc()->make_nuclear_potential(world);
680 construct_nuclear_correlation_factor(calc->molecule, calc->potentialmanager, get_nemo_param().ncf());
681 timer1.end("reproject ncf");
682 }
683
684 // (re) construct the Poisson solver
685 poisson = std::shared_ptr<real_convolution_3d>(
687
688 // Bring the MOs to the new k and thresh. This must come AFTER the ncf
689 // has been rebuilt, because the normalization inside reproject_mos uses
690 // R as the metric and would otherwise mix polynomial orders itself.
691 reproject_mos(calc->amo,R);
692 reproject_mos(calc->bmo,R);
693
694 // The AO basis has to follow k as well. moldft reprojects it inside its
695 // protocol loop (SCF.h, MolecularEnergy::value); nemo projected it once
696 // outside the ladder, so a k change left it behind -- and Nemo::localize
697 // hands it to the Localizer next to the freshly reprojected nemos.
698 const int k=FunctionDefaults<3>::get_k();
699 if (calc->ao.size()>0 and calc->ao.front().k()!=k) {
700 if (world.rank()==0 and get_calc_param().print_level()>2)
701 print("reprojecting the AO basis from k =",calc->ao.front().k(),"to k =",k);
702 calc->ao.clear();
703 world.gop.fence();
704 calc->ao=calc->project_ao_basis(world,calc->aobasis);
705 }
706
707 }
708
709 /// solve the HF equations
710 double solve(const SCFProtocol& proto);
711
712 /// given nemos, compute the HF energy using the regularized expressions for T and V
713
714 /// @param[in] R2nemo R^2 * nemo, the bra of every expectation value
715 /// @param[in] kinetic <R^2 F_i | -1/2 nabla^2 | F_j>, the kinetic block of the Fock matrix;
716 /// the regularized kinetic energy is twice its trace
717 std::vector<double> compute_energy_regularized(const vecfuncT& nemo, const vecfuncT& R2nemo,
718 const vecfuncT& Jnemo, const vecfuncT& Knemo, const vecfuncT& Unemo,
719 const Tensor<double>& kinetic) const;
720
721 /// compute the reconstructed orbitals, and all potentials applied on nemo
722
723 /// to use these potentials in the fock matrix computation they must
724 /// be multiplied by the nuclear correlation factor
725 /// @param[in] nemo the nemo orbitals
726 /// @param[in] R2nemo R^2 * nemo, the bra of the exchange operator
727 /// @param[out] Jnemo Coulomb operator applied on the nemos
728 /// @param[out] Knemo exchange operator applied on the nemos
729 /// @param[out] pcmnemo PCM (solvent) potential applied on the nemos
730 /// @param[out] Unemo regularized nuclear potential applied on the nemos
731 /// @param[out] xcflux the vector field Y_i that the orbital update pushes
732 /// through the Green's function, see
733 /// XCOperator::weak_xc_terms. Assigned in the weak form
734 /// only and left EMPTY otherwise, which is how the caller
735 /// tells the two forms apart.
736 /// @param[out] fock_xc the xc block of the Fock matrix. In the weak form it
737 /// cannot be recovered from xcnemo any more, because what
738 /// is missing from xcnemo is exactly the term that has no
739 /// multiplicative representation. Assigned in the weak
740 /// form only and left untouched otherwise.
741 void compute_nemo_potentials(const vecfuncT& nemo, const vecfuncT& R2nemo,
742 vecfuncT& Jnemo, vecfuncT& Knemo, vecfuncT& xcnemo, vecfuncT& pcmnemo,
743 vecfuncT& Unemo, std::vector<vecfuncT>& xcflux, tensorT& fock_xc) const {
744 compute_nemo_potentials_impl(nemo, R2nemo, Jnemo, Knemo, xcnemo, pcmnemo, Unemo,
745 xcflux, fock_xc, true);
746 }
747
748 /// compute all potentials applied on nemo, without the weak-form split
749
750 /// The pre-weak-form signature, kept for callers that have no use for the
751 /// flux. It never opts in to the weak form, whatever `xc_weak_gga` says, so
752 /// xcnemo always carries the complete multiplicative xc potential and the
753 /// xc block of the Fock matrix can be read off it as before. Silently
754 /// discarding xcflux instead would drop the semilocal term.
755 void compute_nemo_potentials(const vecfuncT& nemo, const vecfuncT& R2nemo,
756 vecfuncT& Jnemo, vecfuncT& Knemo, vecfuncT& xcnemo, vecfuncT& pcmnemo,
757 vecfuncT& Unemo) const {
758 std::vector<vecfuncT> xcflux;
759 tensorT fock_xc;
760 compute_nemo_potentials_impl(nemo, R2nemo, Jnemo, Knemo, xcnemo, pcmnemo, Unemo,
761 xcflux, fock_xc, false);
762 }
763
764 /// implementation of both compute_nemo_potentials forms
765
766 /// @param[in] allow_weak opt in to the weak form; it is then used iff
767 /// the `xc_weak_gga` parameter asks for it
768 void compute_nemo_potentials_impl(const vecfuncT& nemo, const vecfuncT& R2nemo,
769 vecfuncT& Jnemo, vecfuncT& Knemo, vecfuncT& xcnemo, vecfuncT& pcmnemo,
770 vecfuncT& Unemo, std::vector<vecfuncT>& xcflux, tensorT& fock_xc,
771 const bool allow_weak) const;
772
773 /// return the Coulomb potential
775
776 /// compute the incomplete hessian
777
778 /// incomplete hessian is the nuclear-nuclear contribution, and the
779 /// contribution from the second derivative of the nuclear potential,
780 /// and also the derivative of the nuclear correlation factor.
781 /// i.e. all contributions that *do not* contain the regularized perturbed
782 /// density, but it will contain parts of the perturbed density
784
785 /// compute the complementary incomplete hessian
786
787 /// @param[in] xi the response functions including the parallel part
789 const std::vector<vecfuncT>& xi) const;
790
791 /// compute the constant term for the CPHF equations
792
793 /// mainly all terms with the nuclear correlation factor's derivatives
794 vecfuncT make_cphf_constant_term(const size_t iatom, const int iaxis,
795 const vecfuncT& R2nemo, const real_function_3d& rhonemo) const;
796
797public:
798
799 bool is_dft() const {return calc->xc.is_dft();}
800
801 bool do_pcm() const {return get_calc_param().pcm_data() != "none";}
802
803 /// the asymptotic correction is defunct: its `ac_data` parameter was removed,
804 /// and the code paths guarded by do_ac() are kept but never taken. It was
805 /// never reconciled with the weak xc form, whose Fock block is built from the
806 /// uncorrected potential.
807 bool do_ac() const {return false;}
808
809 AC<3> get_ac() const {return ac;}
810
811 bool do_symmetry() const {return (symmetry_projector.get_pointgroup()!="C1");}
812
813protected:
814
815 /// localize the nemo orbitals
816 vecfuncT localize(const vecfuncT& nemo, const double dconv, const bool randomize) const;
817protected:
818 /// return the threshold for vanishing elements in orbital rotations
819 double trantol() const {
820 return calc->vtol / std::min(30.0, double(get_calc()->amo.size()));
821 }
822
823 void make_plots(const real_function_3d &f,const std::string &name="function")const{
824 double width = FunctionDefaults<3>::get_cell_min_width()/2.0 - 1.e-3;
826 coord_3d start(0.0); start[0]=-width;
827 coord_3d end(0.0); end[0]=width;
828 plot_line(("line_"+name).c_str(),1000,start,end,f);
829 }
830
831 /// save a function
832 template<typename T, size_t NDIM>
833 void save_function(const std::vector<Function<T,NDIM> >& f, const std::string name) const;
834
835 /// load a function
836 template<typename T, size_t NDIM>
837 void load_function(std::vector<Function<T,NDIM> >& f, const std::string name) const;
838
839};
840
841/// save a function
842template<typename T, size_t NDIM>
843void Nemo::save_function(const std::vector<Function<T,NDIM> >& f, const std::string name) const {
844 if (world.rank()==0) print("saving vector of functions",name);
846 ar & f.size();
847 for (const Function<T,NDIM>& ff:f) ar & ff;
848}
849
850/// load a function
851template<typename T, size_t NDIM>
852void Nemo::load_function(std::vector<Function<T,NDIM> >& f, const std::string name) const {
853 if (world.rank()==0) print("loading vector of functions",name);
855 std::size_t fsize=0;
856 ar & fsize;
857 f.resize(fsize);
858 for (std::size_t i=0; i<fsize; ++i) ar & f[i];
859}
860
861}
862
863#endif /* NEMO_H_ */
864
double w(double t, double eps)
Definition DKops.h:22
solution protocol for SCF calculations
Definition AC.h:431
FunctionDefaults holds default paramaters as static class members.
Definition funcdefaults.h:101
static int get_k()
Returns the default wavelet order.
Definition funcdefaults.h:170
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
static double get_cell_min_width()
Returns the minimum width of any user cell dimension.
Definition funcdefaults.h:405
A multiresolution adaptive numerical function.
Definition mra.h:140
int k() const
Returns the number of multiwavelets (k). No communication.
Definition mra.h:692
double thresh() const
Returns value of truncation threshold. No communication.
Definition mra.h:673
void set_thresh(double value, bool fence=true)
Sets the value of the truncation threshold. Optional global fence.
Definition mra.h:683
void clear(bool fence=true)
Clears the function as if constructed uninitialized. Optional fence.
Definition mra.h:1016
bool is_initialized() const
Returns true if the function is initialized.
Definition mra.h:168
Definition molecule.h:129
static void print_parameters()
Definition molecule.cc:120
Definition nemo.h:70
std::shared_ptr< NuclearCorrelationFactor > ncf
the nuclear correlation factor
Definition nemo.h:359
double compute_kinetic_energy1a(const std::vector< Function< T, NDIM > > &nemo) const
compute kinetic energy as square of the "analytical" derivative of the orbitals
Definition nemo.h:294
double compute_kinetic_energy1(const std::vector< Function< T, NDIM > > &nemo) const
compute kinetic energy as square of the "analytical" derivative of the orbitals
Definition nemo.h:277
std::shared_ptr< NuclearCorrelationFactor > get_ncf_ptr() const
create an instance of the derived object based on the input parameters
Definition nemo.h:84
virtual void invalidate_factors_and_potentials()
Definition nemo.h:193
static void normalize(std::vector< Function< T, NDIM > > &nemo, const Function< double, NDIM > metric=Function< double, NDIM >())
normalize the nemos
Definition nemo.h:90
void reproject_mos(std::vector< Function< T, NDIM > > &nemo, const Function< double, NDIM > &metric) const
reproject a set of nemos onto the current k and thresh
Definition nemo.h:117
NemoBase(World &w)
Definition nemo.h:74
real_function_3d R
the nuclear correlation factor
Definition nemo.h:362
Function< typename Tensor< T >::scalar_type, NDIM > compute_density(const std::vector< Function< T, NDIM > > nemo) const
Definition nemo.h:172
virtual std::shared_ptr< Fock< double, 3 > > make_fock_operator() const
Definition nemo.h:78
virtual bool need_recompute_factors_and_potentials(const double thresh) const
Definition nemo.h:176
real_function_3d R_square
the square of the nuclear correlation factor
Definition nemo.h:365
Tensor< double > compute_gradient(const real_function_3d &rhonemo, const Molecule &molecule) const
compute the nuclear gradients
Definition madness/chem/nemo.cc:106
double compute_kinetic_energy(const std::vector< Function< T, NDIM > > &nemo) const
compute kinetic energy as square of the "analytical" expectation value
Definition nemo.h:231
static Tensor< T > Q2(const Tensor< T > &s)
Definition nemo.h:138
void construct_nuclear_correlation_factor(const Molecule &molecule, const std::shared_ptr< PotentialManager > &pm, const std::pair< std::string, double > &ncf_parameter)
Definition nemo.h:200
double compute_kinetic_energy2(const std::vector< Function< T, NDIM > > &nemo) const
compute kinetic energy as direct derivative of the orbitals (probably imprecise)
Definition nemo.h:312
World & world
Definition nemo.h:356
void orthonormalize(std::vector< Function< T, NDIM > > &nemo, const Function< double, NDIM > metric=Function< double, NDIM >(), const double trantol=FunctionDefaults< NDIM >::get_thresh() *0.01) const
orthonormalize the vectors
Definition nemo.h:146
virtual ~NemoBase()
Definition nemo.h:76
bool check_convergence(const std::vector< double > energies, const std::vector< double > oldenergies, const double bsh_norm, const double delta_density, const CalculationParameters &param, const double econv, const double dconv) const
Definition nemo.h:327
real_function_3d U1dotU1
U1.U1 = |grad R|^2 / R^2, by which the physical kinetic energy exceeds the regularized one.
Definition nemo.h:368
The Nemo class.
Definition nemo.h:375
void set_protocol(const double thresh)
adapt the thresholds consistently to a common value
Definition nemo.h:671
bool do_symmetry() const
Definition nemo.h:811
virtual double value()
Definition nemo.h:467
projector_irrep get_symmetry_projector() const
return the symmetry_projector
Definition nemo.h:633
tensorT compute_fock_matrix(const vecfuncT &nemo, const tensorT &occ) const
compute the Fock matrix from scratch
Definition madness/chem/nemo.cc:449
double trantol() const
return the threshold for vanishing elements in orbital rotations
Definition nemo.h:819
const NemoCalculationParameters & get_nemo_param() const
Definition nemo.h:560
std::filesystem::path work_dir
Definition nemo.h:415
Molecule & molecule() const
return a reference to the molecule
Definition nemo.h:572
vecfuncT compute_cphf_parallel_term(const size_t iatom, const int iaxis) const
Definition madness/chem/nemo.cc:1876
void load_function(std::vector< Function< T, NDIM > > &f, const std::string name) const
load a function
Definition nemo.h:852
std::shared_ptr< SCF > get_calc() const
Definition nemo.h:558
Tensor< double > purify_hessian(const Tensor< double > &hessian) const
purify and symmetrize the hessian
Definition madness/chem/nemo.cc:1343
std::shared_ptr< real_convolution_3d > poperatorT
Definition nemo.h:376
real_function_3d get_coulomb_potential(const vecfuncT &psi) const
return the Coulomb potential
Definition madness/chem/nemo.cc:968
Tensor< double > gradient(const Tensor< double > &x)
compute the nuclear gradients
Definition madness/chem/nemo.cc:1118
virtual nlohmann::json analyze() const
compute dipole moment and gradient at the current geometry
Definition madness/chem/nemo.cc:340
const CalculationParameters & get_calc_param() const
Definition nemo.h:561
void compute_nemo_potentials_impl(const vecfuncT &nemo, const vecfuncT &R2nemo, vecfuncT &Jnemo, vecfuncT &Knemo, vecfuncT &xcnemo, vecfuncT &pcmnemo, vecfuncT &Unemo, std::vector< vecfuncT > &xcflux, tensorT &fock_xc, const bool allow_weak) const
implementation of both compute_nemo_potentials forms
Definition madness/chem/nemo.cc:841
double solve(const SCFProtocol &proto)
solve the HF equations
Definition madness/chem/nemo.cc:547
vecfuncT solve_cphf(const size_t iatom, const int iaxis, const Tensor< double > &fock, const vecfuncT &guess, const vecfuncT &rhsconst, const Tensor< double > &incomplete_hessian, const vecfuncT &parallel, const SCFProtocol &p, const std::string &xc_data) const
solve the CPHF equations for the nuclear displacements
Definition madness/chem/nemo.cc:1527
Tensor< double > make_incomplete_hessian() const
compute the incomplete hessian
Definition madness/chem/nemo.cc:1388
std::vector< vecfuncT > compute_all_cphf()
solve the CPHF equation for all displacements
Definition madness/chem/nemo.cc:1696
Tensor< double > make_incomplete_hessian_response_part(const std::vector< vecfuncT > &xi) const
compute the complementary incomplete hessian
Definition madness/chem/nemo.cc:1446
real_function_3d make_density(const Tensor< double > &occ, const vecfuncT &nemo) const
make the density (alpha or beta)
Definition madness/chem/nemo.cc:974
const NemoCalculationParameters nemo_param
Definition nemo.h:625
static void smoothen(real_function_3d &f)
smooth a function by projecting it onto k-1 and then average with k
Definition nemo.h:613
void compute_nemo_potentials(const vecfuncT &nemo, const vecfuncT &R2nemo, vecfuncT &Jnemo, vecfuncT &Knemo, vecfuncT &xcnemo, vecfuncT &pcmnemo, vecfuncT &Unemo, std::vector< vecfuncT > &xcflux, tensorT &fock_xc) const
compute the reconstructed orbitals, and all potentials applied on nemo
Definition nemo.h:741
PCM get_pcm() const
Definition nemo.h:563
Tensor< double > compute_IR_intensities(const Tensor< double > &normalmodes, const vecfuncT &dens_pt) const
compute the IR intensities in the double harmonic approximation
Definition madness/chem/nemo.cc:1895
virtual std::shared_ptr< Fock< double, 3 > > make_fock_operator() const
construct the fock operator based on the calculation parameters (K or XC?)
Definition madness/chem/nemo.cc:384
std::shared_ptr< SCF > calc
Definition nemo.h:622
void load_mos(World &w)
Definition nemo.h:471
static void print_parameters()
Definition nemo.h:453
bool check_converged(const Tensor< double > &x) const
Definition nemo.h:462
bool provides_gradient() const
Override this to return true if the derivative is implemented.
Definition nemo.h:481
real_function_3d kinetic_energy_potential(const vecfuncT &nemo) const
the Laplacian of the density
Definition madness/chem/nemo.cc:1018
PCM pcm
polarizable continuum model
Definition nemo.h:666
VibrationalResults hessian(const Tensor< double > &x)
returns the molecular hessian matrix at structure x
Definition madness/chem/nemo.cc:1148
void save_function(const std::vector< Function< T, NDIM > > &f, const std::string name) const
save a function
Definition nemo.h:843
void make_plots(const real_function_3d &f, const std::string &name="function") const
Definition nemo.h:823
bool do_ac() const
Definition nemo.h:807
projector_irrep symmetry_projector
Definition nemo.h:628
double coords_sum
sum of square of coords at last solved geometry
Definition nemo.h:640
std::shared_ptr< real_convolution_3d > poisson
a poisson solver
Definition nemo.h:644
real_function_3d make_sigma(const real_function_3d &rho1, const real_function_3d &rho2) const
compute the reduced densities sigma (gamma) for GGA functionals
Definition madness/chem/nemo.cc:1091
real_function_3d make_ddensity(const real_function_3d &rhonemo, const int axis) const
make the derivative of the density
Definition madness/chem/nemo.cc:1001
AC< 3 > ac
asymptotic correction for DFT
Definition nemo.h:647
void compute_nemo_potentials(const vecfuncT &nemo, const vecfuncT &R2nemo, vecfuncT &Jnemo, vecfuncT &Knemo, vecfuncT &xcnemo, vecfuncT &pcmnemo, vecfuncT &Unemo) const
compute all potentials applied on nemo, without the weak-form split
Definition nemo.h:755
vecfuncT localize(const vecfuncT &nemo, const double dconv, const bool randomize) const
localize the nemo orbitals
Definition madness/chem/nemo.cc:366
bool do_pcm() const
Definition nemo.h:801
bool selftest()
Definition nemo.h:432
std::vector< double > compute_energy_regularized(const vecfuncT &nemo, const vecfuncT &R2nemo, const vecfuncT &Jnemo, const vecfuncT &Knemo, const vecfuncT &Unemo, const Tensor< double > &kinetic) const
given nemos, compute the HF energy using the regularized expressions for T and V
Definition madness/chem/nemo.cc:754
AC< 3 > get_ac() const
Definition nemo.h:809
vecfuncT make_cphf_constant_term(const size_t iatom, const int iaxis, const vecfuncT &R2nemo, const real_function_3d &rhonemo) const
compute the constant term for the CPHF equations
Definition madness/chem/nemo.cc:1475
Molecule & molecule()
return a reference to the molecule
Definition nemo.h:569
std::string name() const
Definition nemo.h:431
static void help()
Definition nemo.h:434
bool is_dft() const
Definition nemo.h:799
functor for a local U1 dot U1 potential
Definition correlationfactor.h:628
static constexpr int ncf_special_level
projection depth of the factor's functions at the nuclei
Definition correlationfactor.h:110
input parameters for the polarizable continuum model – the pcm data group
Definition pcm.h:69
interface class to the PCMSolver library
Definition pcm.h:132
Definition PNO.h:27
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 parameter_exists(const std::string &key) const
Definition chem/QCCalculationParametersBase.h:591
class implementing properties of QC models
Definition QCPropertyInterface.h:11
struct for running a protocol of subsequently tightening precision
Definition SCFProtocol.h:54
Definition TDHF.h:219
A tensor is a multidimensional array.
Definition tensor.h:318
T sumsq() const
Returns the sum of the squares of the elements.
Definition tensor.h:1670
Definition Results.h:196
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:177
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
WorldGopInterface & gop
Global operations.
Definition world.h:216
An archive for storing local or parallel data, wrapping a BinaryFstreamInputArchive.
Definition parallel_archive.h:366
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition parallel_archive.h:321
Definition pointgroupsymmetry.h:98
std::string get_pointgroup() const
get the point group name
Definition pointgroupsymmetry.h:170
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double lo
Definition dirac-hatom.cc:23
Defines/implements plotting interface for functions.
double psi(const Vector< double, 3 > &r)
Definition hatom_energy.cc:78
Implements (2nd generation) static load/data balancing for functions.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
optimize the geometrical structure of a molecule
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
std::shared_ptr< NuclearCorrelationFactor > create_nuclear_correlation_factor(World &world, const Molecule &molecule, const std::shared_ptr< PotentialManager > potentialmanager, const std::string inputline)
create and return a new nuclear correlation factor
Definition correlationfactor.cc:45
void print_header2(const std::string &s)
medium section heading
Definition print.cc:54
Function< double, NDIM > abssq(const Function< double_complex, NDIM > &z, bool fence=true)
Returns a new function that is the square of the absolute value of the input.
Definition mra.h:2961
std::vector< double > norm2s(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norms of a vector of functions.
Definition vmra.h:927
Function< TENSOR_RESULT_TYPE(T, R), NDIM > dot(World &world, const std::vector< Function< T, NDIM > > &a, const std::vector< Function< R, NDIM > > &b, bool fence=true, bool do_make_redundant=true)
Multiplies and sums two vectors of functions r = \sum_i a[i] * b[i]; see dot_sparse for screening.
Definition vmra.h:1848
std::vector< Function< TENSOR_RESULT_TYPE(T, R), NDIM > > transform(World &world, const std::vector< Function< T, NDIM > > &v, const Tensor< R > &c, bool fence=true)
Transforms a vector of functions according to new[i] = sum[j] old[j]*c[j,i].
Definition vmra.h:758
void truncate(World &world, std::vector< Function< T, NDIM > > &v, double tol=0.0, bool fence=true)
Truncates a vector of functions.
Definition vmra.h:336
const std::vector< Function< T, NDIM > > & reconstruct(const std::vector< Function< T, NDIM > > &v)
reconstruct a vector of functions
Definition vmra.h:163
void set_thresh(World &world, std::vector< Function< T, NDIM > > &v, double thresh, bool fence=true)
Sets the threshold in a vector of functions.
Definition vmra.h:1457
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition vmra.h:961
void plot_plane(World &world, const Function< double, NDIM > &function, const std::string name)
Definition funcplot.h:625
FunctionFactory< double, 3 > real_factory_3d
Definition functypedefs.h:108
void refine(World &world, const std::vector< Function< T, NDIM > > &vf, bool fence=true)
refine the functions according to the autorefine criteria
Definition vmra.h:197
NDIM & f
Definition mra.h:2664
void print(const T &t, Ts &&... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:232
static SeparatedConvolution< double, 3 > * CoulombOperatorPtr(World &world, double lo, double eps, const std::array< LatticeRange, 3 > &lattice_ranges=FunctionDefaults< 3 >::get_bc().lattice_range(), int k=FunctionDefaults< 3 >::get_k())
Factory function generating separated kernel for convolution with 1/r in 3D.
Definition operator.h:1947
vector< functionT > vecfuncT
Definition corepotential.cc:58
CCPairFunction< T, NDIM > apply(const SeparatedConvolution< T, NDIM/2 > &op, const CCPairFunction< T, NDIM > &arg)
apply the operator to the argument
Definition ccpairfunction.h:896
Function< TENSOR_RESULT_TYPE(L, R), NDIM > mul_sparse(const Function< L, NDIM > &left, const Function< R, NDIM > &right, double tol, bool fence=true, bool do_make_redundant=true)
Sparse multiplication; the scalar interface redirects to the vector one in vmra.h.
Definition mra.h:1973
std::vector< Function< T, NDIM > > grad(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
shorthand gradient operator
Definition vmra.h:2316
Function< T, CCPairFunction< T, NDIM >::LDIM > inner(const CCPairFunction< T, NDIM > &c, const Function< T, CCPairFunction< T, NDIM >::LDIM > &f, const std::tuple< int, int, int > v1, const std::tuple< int, int, int > v2)
Definition ccpairfunction.h:993
void scale(World &world, std::vector< Function< T, NDIM > > &v, const std::vector< Q > &factors, bool fence=true)
Scales inplace a vector of functions by distinct values.
Definition vmra.h:874
void plot_line(World &world, const char *filename, int npt, const Vector< double, NDIM > &lo, const Vector< double, NDIM > &hi, const opT &op)
Generates ASCII file tabulating f(r) at npoints along line r=lo,...,hi.
Definition funcplot.h:442
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition mra.h:2647
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
Derivative< double, 3 > real_derivative_3d
Definition functypedefs.h:185
void matrix_inner(DistributedMatrix< T > &A, const std::vector< Function< T, NDIM > > &f, const std::vector< Function< T, NDIM > > &g, bool sym=false)
Definition distpm.cc:46
@ nemo
nemo's regularized orbitals F = psi/R
static long abs(long a)
Definition tensor.h:219
Implementation of Krylov-subspace nonlinear equation solver.
Implements most functionality of separated operators.
double Q(double a)
Definition relops.cc:20
static const double thresh
Definition rk.cc:45
static const long k
Definition rk.cc:44
const double xi
Exponent for delta function approx.
Definition siam_example.cc:60
Definition test_ar.cc:204
Definition CalculationParameters.h:51
std::string pcm_data() const
Definition CalculationParameters.h:237
Definition molecular_optimizer.h:46
virtual Molecule & molecule()
return the molecule of the target
Definition molecular_optimizer.h:49
class holding parameters for a nemo calculation beyond the standard dft parameters from moldft
Definition nemo.h:382
void initialize_nemo_parameters()
Definition nemo.h:398
std::pair< std::string, double > ncf() const
Definition nemo.h:408
bool hessian() const
Definition nemo.h:409
static constexpr char const * tag
Definition nemo.h:383
NemoCalculationParameters(World &world, const commandlineparser &parser)
Definition nemo.h:385
std::string get_tag() const override
Definition nemo.h:394
NemoCalculationParameters()
Definition nemo.h:390
very simple command line parser
Definition commandlineparser.h:28
Definition timing_utilities.h:9
double end(const std::string msg)
Definition timing_utilities.h:56
Definition dirac-hatom.cc:112
InputParameters param
Definition tdse.cc:203
static double guess(const coordT &r)
Definition tdse.confused.cc:345
AtomicInt sum
Definition test_atomicint.cc:46
constexpr std::size_t NDIM
Definition testgconv.cc:54
std::size_t axis
Definition testpdiff.cc:59
Defines operations on vectors of Functions.