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