MADNESS 0.10.1
SCF.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 $Id$
33 */
34
35/// \file moldft.cc
36/// \brief Molecular HF and DFT code
37/// \defgroup moldft The molecular density functional and Hartree-Fock code
38
39
40#ifndef MADNESS_CHEM_SCF_H__INCLUDED
41#define MADNESS_CHEM_SCF_H__INCLUDED
42
43#include <memory>
44
46#include <madness/mra/mra.h>
47
61#include<madness/chem/pcm.h>
64
65#include <madness/tensor/tensor_json.hpp>
66#include <memory>
67
68namespace madness {
69
70typedef std::shared_ptr<WorldDCPmapInterface<Key<3> > > pmapT;
72typedef std::shared_ptr<FunctionFunctorInterface<double, 3> > functorT;
74typedef std::vector<functionT> vecfuncT;
75typedef std::pair<vecfuncT, vecfuncT> pairvecfuncT;
76typedef std::vector<pairvecfuncT> subspaceT;
81typedef std::shared_ptr<operatorT> poperatorT;
83typedef std::vector<complex_functionT> cvecfuncT;
84
85
86template<typename T, int NDIM>
87struct lbcost {
88 double leaf_value;
90
92
93 double operator()(const Key<NDIM>& key, const FunctionNode<T, NDIM>& node) const {
94 if (key.level() < 1) {
95 // Root is a structural catch-all with no work. The old 100x was accumulated once per
96 // function by add_tree, so on balances over many light trees key0 outweighed every real
97 // subtree and the rank holding it was starved of work.
98 return leaf_value + parent_value;
99 } else if (node.is_leaf()) {
100 return leaf_value;
101 } else {
102 return parent_value;
103 }
104 }
105};
106
107
108inline double mask1(double x) {
109 /* Iterated first beta function to switch smoothly
110 from 0->1 in [0,1]. n iterations produce 2*n-1
111 zero derivatives at the end points. Order of polyn
112 is 3^n.
113
114 Currently use one iteration so that first deriv.
115 is zero at interior boundary and is exactly representable
116 by low order multiwavelet without refinement */
117
118 x = (x * x * (3. - 2. * x));
119 return x;
120}
121
122static double mask3(const coordT& ruser) {
123 coordT rsim;
125 double x = rsim[0], y = rsim[1], z = rsim[2];
126 double lo = 0.0625, hi = 1.0 - lo, result = 1.0;
127 double rlo = 1.0 / lo;
128
129 if (x < lo)
130 result *= mask1(x * rlo);
131 else if (x > hi)
132 result *= mask1((1.0 - x) * rlo);
133 if (y < lo)
134 result *= mask1(y * rlo);
135 else if (y > hi)
136 result *= mask1((1.0 - y) * rlo);
137 if (z < lo)
138 result *= mask1(z * rlo);
139 else if (z > hi)
140 result *= mask1((1.0 - z) * rlo);
141
142 return result;
143}
144
145/// A MADNESS functor to compute either x, y, or z
146class DipoleFunctor : public FunctionFunctorInterface<double, 3> {
147private:
148 const int axis;
149public:
151
153
154 double operator()(const coordT& x) const {
155 return x[axis];
156 }
157};
158
159
160/// A MADNESS functor to compute the cartesian moment x^i * y^j * z^k (i, j, k integer and >= 0)
161class MomentFunctor : public FunctionFunctorInterface<double, 3> {
162private:
163 const int i, j, k;
164public:
166
167 MomentFunctor(int i, int j, int k) : i(i), j(j), k(k) {}
168
169 MomentFunctor(const std::vector<int>& x) : i(x[0]), j(x[1]), k(x[2]) {}
170
171 double operator()(const coordT& r) const {
172 double xi = 1.0, yj = 1.0, zk = 1.0;
173 for (int p = 0; p < i; ++p) xi *= r[0];
174 for (int p = 0; p < j; ++p) yj *= r[1];
175 for (int p = 0; p < k; ++p) zk *= r[2];
176 return xi * yj * zk;
177 }
178};
179
180 class scf_data {
181
182 std::map<std::string, std::vector<double>> e_data;
185 int iter;
186 public:
187
188 scf_data();
189
190 void to_json(json &j) const;
191
192 void print_data();
193
194 void add_data(std::map<std::string, double> values);
195
196 void add_gradient(const Tensor<double> &grad);
197 };
198
199
200class SCF {
201public:
202 std::filesystem::path work_dir;
203 std::shared_ptr<PotentialManager> potentialmanager;
204 std::shared_ptr<GTHPseudopotential<double> > gthpseudopotential;
207 /// the `pcm` data group; inert unless param.pcm_data() is set
211
212 /// empirical DFT-D3 dispersion correction; inactive unless `dispersion` is set
213 ///
214 /// Owned by SCF so that nemo and oep, which hold a shared_ptr<SCF>, reach
215 /// the same object through `calc->dispersion`. (Znemo carries a bare
216 /// CalculationParameters instead and uses the static
217 /// DispersionCorrection::reject to refuse a correction it cannot apply.)
221
223
224 /// alpha and beta molecular orbitals
226
227 /// sets of orbitals grouped by their orbital energies (for localization?)
228 /// only orbitals within the same set will be mixed to localize
229 std::vector<int> aset, bset;
230 /// cholesky localization's pivot order from the previous iteration (per spin)
232
233 /// MRA projection of the minimal basis set
235
236 std::vector<int> at_to_bf, at_nbf;
237
238 /// occupation numbers for alpha and beta orbitals
240
241 /// orbital energies for alpha and beta orbitals
244 std::vector<std::shared_ptr<real_derivative_3d> > gradop;
245 double vtol;
247 double converged_for_thresh=1.e10; ///< mos are converged for this threshold
248 double converged_for_dconv=1.e10; ///< mos are converged for this density
249 double converged_for_tconv=1.e10; ///< derivatives of mos are converged for this threshold
250
251 /// what amo/bmo actually hold, recorded in the restartdata header
252 ///
253 /// Representation::mo for moldft's orbitals. Nemo drives an SCF rather than
254 /// deriving from one and stores the regularized F = psi/R in amo, so it sets
255 /// this to Representation::nemo (and restart_ncf) on the SCF it owns.
256 /// Without it both engines
257 /// write the same filename, with the same version tag, holding different
258 /// functions -- and loading one as the other is silently wrong.
260
261 /// nuclear correlation factor behind restart_representation, e.g. "slater:2.0"
262 std::string restart_ncf;
263
264 /// set while an optimizer drives this SCF, to keep the raw derivative table
265 /// out of the log next to MolOpt's projected one -- see SCF::derivatives
266 mutable bool suppress_raw_gradient_print=false;
267
268 /// forwarding constructor
269 SCF(World& world, const commandlineparser& parser)
270 : SCF(world, CalculationParameters(world, parser), Molecule(world, parser),
271 PCMParameters(world, parser)) {
272 work_dir = std::filesystem::current_path();
273 }
274
275 /// collective constructor for SCF uses contents of file \c filename and broadcasts to all nodes
276
277 /// \p pcm_param defaults to the bare `pcm` group; the solvent is still picked up
278 /// from \p param.pcm_data() by PCMParameters::set_derived_values, so a caller that
279 /// does not parse a deck keeps working.
280 SCF(World& world, const CalculationParameters& param, const Molecule& molecule,
282
283 void copy_data(World& world, const SCF& other);
284
285 static void help() {
286 print_header2("help page for MOLDFT ");
287 print("The moldft code computes Hartree-Fock and DFT energies and gradients, It is the fastest code in MADNESS");
288 print("and considered the reference implementation. No nuclear correlation factor can be used");
289 print("SCF orbitals are the basis for post-SCF calculations like");
290 print("excitation energies (cis), correlation energies (cc2), local potentials (oep), etc\n\n");
291 print("You can print all available calculation parameters by running\n");
292 print("moldft --print_parameters\n");
293 print("You can perform a simple calculation by running\n");
294 print("moldft --geometry=h2o.xyz\n");
295 print("provided you have an xyz file in your directory.\n\n");
296 print("To see what a restart archive holds -- geometry, k, the precision it");
297 print("converged to, whether it is moldft or nemo orbitals -- without starting");
298 print("a calculation:\n");
299 print("moldft --restart_info=<prefix>\n");
300
301 }
302
303 static void print_parameters() {
305 print("default parameters for the moldft program are");
306 param.print("dft", "end");
307 print("\n\nthe molecular geometry must be specified in a separate block:");
309 }
310
311 void set_print_timings(const bool value);
312
313 template<std::size_t NDIM>
314 void set_protocol(World& world, double thresh) {
315 int k;
316 // Allow for imprecise conversion of threshold
317 if (thresh >= 0.9e-2)
318 k = 4;
319 else if (thresh >= 0.9e-4)
320 k = 6;
321 else if (thresh >= 0.9e-6)
322 k = 8;
323 else if (thresh >= 0.9e-8)
324 k = 10;
325 else
326 k = 12;
327
328 // k defaults to make sense with thresh, override by providing k in input file
329 if (param.k() == -1) {
331 // param.k=k;
332 } else {
334 }
335 // don't forget to adapt the molecular smoothing parameter!! NO ... it is independent
336 // molecule.set_eprec(std::min(thresh,molecule.get_eprec()));
340 // FunctionDefaults<NDIM>::set_truncate_mode(1);
346 double safety = 0.1;
350
351 // Update coefficients if using a different derivative
352 if (param.deriv() == "bspline") {
353 for (int i = 0; i < 3; ++i) (*gradop[i]).set_bspline1();
354 } else if (param.deriv() == "ble") {
355 for (int i = 0; i < 3; ++i) (*gradop[i]).set_ble1();
356 }
357
358 mask = functionT(factoryT(world).f(mask3).initial_level(4).norefine());
359 if (world.rank() == 0 and param.print_level() > 1) {
360 print("\nSolving NDIM=", NDIM, " with thresh", thresh, " k",
361 FunctionDefaults<NDIM>::get_k(), " conv", std::max(thresh, param.dconv()), "\n");
362 }
363 }
364
365 /// getter for the molecular orbitals, alpha spin
366 const vecfuncT& get_amo() const { return amo; }
367
368 /// getter for the molecular orbitals, beta spin
369 const vecfuncT& get_bmo() const { return bmo; }
370
371 /// getter for the occupation numbers, alpha spin
372 const tensorT& get_aocc() const { return aocc; }
373
374 /// getter for the occupation numbers, alpha spin
375 const tensorT& get_bocc() const { return bocc; }
376
377 bool is_spin_restricted() const { return param.get<bool>("spin_restricted"); }
378
379 void save_mos(World& world);
380
381 /// @param[in] allow_fewer pad the virtuals from the atomic guess when the archive
382 /// holds fewer orbitals than requested; otherwise that throws
383 void load_mos(World& world, const bool allow_fewer = true);
384
385 bool restart_aos(World& world);
386
387 void do_plots(World& world);
388
389 void project(World& world);
390
391 void make_nuclear_potential(World& world);
392
394
396 const Molecule& molecule);
397
398 void reset_aobasis(const std::string& aobasisname) {
399 aobasis = AtomicBasisSet(); // reset
401 }
402
403 /// group orbitals into sets of similar orbital energies for localization
404
405 /// @param[in] eps orbital energies
406 /// @param[in] occ occupation numbers
407 /// @param[in] nmo number of MOs for the given spin
408 /// @return vector of length nmo with the set index for each MO
409 std::vector<int> group_orbital_sets(World& world, const tensorT& eps,
410 const tensorT& occ, const int nmo) const;
411
412 /// overwrite the leading occupation numbers with the explicit aocc/bocc input, if given
414
415 static void analyze_vectors(World& world, const vecfuncT& mo,
416 const vecfuncT& ao, double vtol,
417 const Molecule& molecule, const int print_level,
418 const AtomicBasisSet& aobasis, const tensorT& occ = tensorT(),
419 const tensorT& energy = tensorT(), const std::vector<int>& set = std::vector<int>());
420
421 distmatT kinetic_energy_matrix(World& world, const vecfuncT& v) const;
422
423 /// carry out a restart plan: read the orbitals it names, or make a guess
424
425 /// @param[in,out] plan downgraded to the initial guess if the named source
426 /// turns out not to load
428
429 void initial_guess(World& world);
430
431 /// diagonalize the atomic-guess Fock matrix in the AO basis
432 /// @param[out] c eigenvectors, one column per orbital
433 /// @param[out] e eigenvalues
435
436 /// iterate the virtuals in the fixed mean field of the occupied orbitals
437 ///
438 /// The occupied orbitals are not updated: nuclear and Coulomb potentials are
439 /// built once, the exchange and XC operators take the occupied orbitals from
440 /// this object at every call. Each spin's virtual block is canonicalized,
441 /// BSH-updated with KAIN, and re-orthogonalized against its occupieds.
442 void solve_virtuals(World& world);
443
444 /// KAIN: append (vm, rm) to the subspace and return the mixing coefficients
445 ///
446 /// Rebuilds the subspace matrix Q incrementally; on a singular subspace the
447 /// history is dropped and the step is a plain update.
448 tensorT kain_solve(World& world, const vecfuncT& vm, const vecfuncT& rm,
449 subspaceT& subspace, tensorT& Q) const;
450
451 /// KAIN: the updated orbitals lo..lo+n of the subspace's vectors for coefficients c
452 vecfuncT kain_combine(World& world, const subspaceT& subspace, const tensorT& c,
453 const size_t lo, const size_t n) const;
454
455 /// KAIN: drop the oldest history entry once the subspace holds maxsub of them
456 void kain_trim(subspaceT& subspace, tensorT& Q) const;
457
458 /// fill in the virtuals a restart archive lacks, up to nmo_alpha/nmo_beta, with
459 /// atomic-guess orbitals orthogonalized against the loaded ones
460 /// @return true if anything was added
461 bool pad_virtuals_from_guess(World& world);
462
463 void initial_guess_from_nwchem(World& world);
464
465 void initial_load_bal(World& world);
466
467 functionT make_density(World& world, const tensorT& occ, const vecfuncT& v) const;
468
469 functionT make_density(World& world, const tensorT& occ, const cvecfuncT& v);
470
471 static std::vector<poperatorT> make_bsh_operators(World& world, const tensorT& evals,
473
474 // Used only for initial guess that is always spin-restricted LDA
475 static functionT make_lda_potential(World& world, const functionT& arho);
476
477
478 // functionT make_dft_potential(World & world, const vecfuncT& vf, int ispin, int what)
479 // {
480 // return multiop_values<double, xc_potential, 3>(xc_potential(xc, ispin, what), vf);
481 // }
482
483 double make_dft_energy(World& world, const vecfuncT& vf, int ispin) {
485 return vlda.trace();
486 }
487
488 vecfuncT apply_potential(World& world, const tensorT& occ,
489 const vecfuncT& amo,
490 const functionT& vlocal, double& exc, double& enl, int ispin);
491
492 tensorT derivatives(World& world, const functionT& rho) const;
493
494 /// compute the total dipole moment of the molecule
495
496 /// @param[in] rho the total (alpha + beta) density
497 /// @return the x,y,z components of the el. + nucl. dipole moment
498 tensorT dipole(World& world, const functionT& rho) const;
499
500 void vector_stats(const std::vector<double>& v, double& rms,
501 double& maxabsval) const;
502
503 vecfuncT compute_residual(World& world, tensorT& occ, tensorT& fock,
504 const vecfuncT& psi, vecfuncT& Vpsi, double& err);
505
506 /// BSH-apply executors for compute_residual, selected by the bsh_apply parameter.
507 /// All three consume Vpsi and return the new orbitals (not yet orthonormalized).
509 const CalculationParameters& param, long batch,
510 bool redistribute);
511 vecfuncT apply_bsh_tiled(World& world, vecfuncT& Vpsi, const tensorT& eps,
513 vecfuncT apply_bsh_plain(World& world, vecfuncT& Vpsi, const tensorT& eps,
515
517 const vecfuncT& Vpsi, const tensorT& occ,
518 double& ekinetic) const;
519
520 /// make the Coulomb potential given the total density
522 return apply(*coulop, rho);
523 }
524
525 /// Compute the two-electron integrals over the provided set of orbitals
526
527 /// Returned is a *replicated* tensor of \f$(ij|kl)\f$ with \f$i>=j\f$
528 /// and \f$k>=l\f$. The symmetry \f$(ij|kl)=(kl|ij)\f$ is enforced.
529 Tensor<double> twoint(World& world, const vecfuncT& psi) const;
530
531 /// compute the unitary transformation that diagonalizes the fock matrix
532
533 /// @param[in] world the world
534 /// @param[in] overlap the overlap matrix of the orbitals
535 /// @param[in,out] fock the fock matrix; diagonal upon exit
536 /// @param[out] evals the orbital energies
537 /// @param[in] occ the occupation numbers
538 /// @param[in] thresh_degenerate threshold for orbitals being degenerate
539 /// @return the unitary matrix U: U^T F U = evals
541 tensorT& fock, tensorT& evals, const tensorT& occ,
542 const double thresh_degenerate) const;
543
544
545 /// diagonalize the fock matrix, taking care of degenerate states
546
547 /// Vpsi is passed in to make sure orbitals and Vpsi are in phase
548 /// @param[in] world the world
549 /// @param[in,out] fock the fock matrix (diagonal upon exit)
550 /// @param[in,out] psi the orbitals
551 /// @param[in,out] Vpsi the orbital times the potential
552 /// @param[out] evals the orbital energies
553 /// @param[in] occ occupation numbers
554 /// @param[in] thresh threshold for rotation and truncation
555 /// @return the unitary matrix U: U^T F U = evals
558 const tensorT& occ, const double thresh) const;
559
560 /// canonicalize the virtual orbitals: diagonalize the virtual-virtual Fock
561 /// block and rotate psi, Vpsi and the occupied-virtual coupling in phase.
562 /// Occupied orbitals are untouched. No-op when there are no virtuals or,
563 /// unless forced, when the rotation is near-identity.
564 /// @param[in] nocc number of occupied orbitals; the block [nocc, nmo) is canonicalized
565 /// @param[in] force rotate even when the rotation is near-identity (final publication)
566 /// @return true if a rotation was applied
567 bool canonicalize_virtuals(World& world, tensorT& fock, vecfuncT& psi,
568 vecfuncT& Vpsi, const int nocc, const bool force = false) const;
569
570
573
574
575 void rotate_subspace(World& world, const tensorT& U, subspaceT& subspace,
576 int lo, int nfunc, double trantol) const;
577
578 void rotate_subspace(World& world, const distmatT& U, subspaceT& subspace,
579 int lo, int nfunc, double trantol) const;
580
581 void update_subspace(World& world,
585 double& bsh_residual, double& update_residual);
586
587 /// perform step restriction following the KAIN solver
588
589 /// undo the rotation from the KAIN solver if the rotation exceeds the
590 /// maxrotn parameter
591 /// @param[in] world the world
592 /// @param[in] mo vector of orbitals from previous iteration
593 /// @param[in,out] mo_new vector of orbitals from the KAIN solver
594 /// @param[in] spin "alpha" or "beta" for user information
595 /// @return max residual
596 double do_step_restriction(World& world, const vecfuncT& mo,
597 vecfuncT& mo_new, std::string spin) const;
598
599 /// orthonormalize the vectors
600
601 /// @param[in] world the world
602 /// @param[in,out] amo_new the vectors to be orthonormalized
603 void orthonormalize(World& world, vecfuncT& amo_new) const;
604
605 void orthonormalize(World& world, vecfuncT& amo_new, int nocc) const;
606
607 // For given protocol, solve the DFT/HF/response equations
608 void solve(World& world);
609
610 void output_calc_info_schema() const;
611
612 void output_scf_info_schema(const std::map<std::string, double> &vals,
613 const tensorT &dipole_T) const;
614
615};
616
617// Computes molecular energy as a function of the geometry
618// This is cludgy ... need better factorization of functionality
619// between calculation, main program and this ... or just merge it all.
623 mutable double coords_sum; // sum of square of coords at last solved geometry
624
625public:
628
629 std::string name() const { return "Molecularenerg"; }
630
631 bool selftest() { return true; }
632
633 bool provides_gradient() const { return true; }
634
635 double value(const Tensor<double>& x) {
636 double xsq = x.sumsq();
637 if (xsq == coords_sum) {
638 return calc.current_energy;
639 }
641 coords_sum = xsq;
642
643 // Decide once, here, where the orbitals come from and which rung of the
644 // ladder to start on. This replaces both the old `no_compute` early
645 // return and the "thresh drifted away from protocol[0], reset it" patch:
646 // the protocol is now set explicitly to the rung the plan names, so there
647 // is no drift to detect.
651
652 // set the target basis BEFORE reading, so load_mos reprojects straight
653 // into the rung we are about to iterate at rather than into whatever k
654 // FunctionDefaults happened to be left at
655 calc.set_protocol<3>(world, calc.param.protocol()[plan.protocol_start]);
656
657 // initialize the PCM solver for this geometry
658 if (calc.param.pcm_data() != "none") {
660 }
661
662 // The virtual step-down converges nv_extra extra virtuals first. Only
663 // virtuals that start from the atomic guess can be sized for them: a fresh
664 // guess, or a restart whose archive lacks them. A complete restart skips it.
665 const int nvalpha = calc.param.nmo_alpha() - calc.param.nalpha();
666 const int nvbeta = calc.param.nmo_beta() - calc.param.nbeta();
667 const bool pads_virtuals = plan.source == RestartSource::restartdata &&
668 plan.archive_nmo_alpha > 0 &&
669 plan.archive_nmo_alpha < std::size_t(calc.param.nmo_alpha());
670 const int nv_extra = (plan.source == RestartSource::initial_guess || pads_virtuals) ? calc.param.nv_extra() : 0;
671 if (calc.param.nv_extra() > 0 && nv_extra == 0 && world.rank() == 0)
672 print("virtual step-down skipped: the virtuals do not start from the atomic guess");
673 if (nv_extra > 0) {
674 calc.param.set_user_defined_value("nmo_alpha", calc.param.nalpha() + nvalpha + nv_extra);
675 if (calc.param.have_beta())
676 calc.param.set_user_defined_value("nmo_beta", calc.param.nbeta() + nvbeta + nv_extra);
677 }
678
680 // an archive converged at a looser rung is reprojected and accepted
682 (plan.source == RestartSource::restartdata and plan.archive_converged and
683 plan.archive_same_hamiltonian),
684 "freeze_occupied needs occupied orbitals from a restartdata archive that "
685 "converged for this Hamiltonian");
686
687 // Reading can invalidate the plan's premise. load_mos resets
688 // converged_for_thresh when it has to reproject, and it may have fallen
689 // back to the initial guess altogether; either way the orbitals are no
690 // longer the converged answer the plan took them for. An automatic plan
691 // changes its mind; an explicit read_only does not -- the user asserted
692 // these orbitals are the answer, and gets them plus a warning.
693 const double target_thresh = calc.param.protocol().back();
694 const double target_dconv = std::max(target_thresh, calc.param.dconv());
695 if (not plan.iterate and plan.mode == RestartMode::automatic and
698 plan.iterate = true;
699 plan.protocol_start = calc.param.protocol().size() - 1;
700 if (world.rank() == 0)
701 print("the orbitals had to be reprojected on reading and are no longer "
702 "converged; iterating at the final protocol rung after all");
703 }
704
705 // AOs are needed for final analysis, and for localization
706 calc.reset_aobasis("sto-3g");
707 calc.ao.clear(); world.gop.fence();
709
710 if (not plan.iterate) {
711 if (world.rank() == 0) print("not solving the SCF equations:", plan.why);
713 // The energy is the archive's, taken from its header. Not
714 // calc.current_energy: load_mos clears that whenever it reprojects,
715 // so reading a 1e-4 archive under `restart read_only` at a 1e-6
716 // request would otherwise hand back 1e10 instead of the stale energy
717 // the user asked to be given.
718 calc.current_energy = plan.stale_energy;
719 return calc.current_energy;
720 }
721
722 // The below is missing convergence test logic, etc.
723
724 // Make the nuclear potential, initial orbitals, etc.
725 for (unsigned int proto = plan.protocol_start; proto < calc.param.protocol().size(); proto++) {
726
727 // Drop the extra virtuals stepwise down to nvalpha on the first rung we
728 // run. Intermediate stages are capped at nv_its iterations; the last
729 // stage runs with the input maxiter.
730 const int extra = (proto == plan.protocol_start) ? nv_extra : 0;
731 const int nv_step = calc.param.nv_step() > 0 ? calc.param.nv_step() : std::max(extra, 1);
732 const int maxiter_input = calc.param.maxiter();
733 int nv_old = nvalpha + extra;
734
735 for (int nv = nvalpha + extra; ; nv = std::max(nv - nv_step, nvalpha)) {
736
737 if (extra > 0)
738 calc.param.set_user_defined_value("maxiter", nv > nvalpha ? calc.param.nv_its() : maxiter_input);
739 if (nv > 0 && world.rank() == 0)
740 std::cout << "Running with " << nv << " virtual states, maxiter " << calc.param.maxiter() << std::endl;
741
743 if (calc.param.have_beta())
744 calc.param.set_user_defined_value("nmo_beta", calc.param.nbeta() + nv + nvbeta - nvalpha);
745
748
749 if (nv != nv_old) {
750 // The virtuals are canonical (ascending eigenvalue), so shrinking
751 // the vector drops the highest ones.
752 calc.amo.resize(calc.param.nmo_alpha());
753 calc.aset.resize(calc.param.nmo_alpha());
756 for (int i = 0; i < calc.param.nalpha(); ++i)
757 calc.aocc[i] = 1.0;
758 if (calc.param.have_beta()) {
759 calc.bmo.resize(calc.param.nmo_beta());
760 calc.bset.resize(calc.param.nmo_beta());
761 calc.beps = copy(calc.beps(Slice(0, calc.param.nmo_beta() - 1)));
763 for (int i = 0; i < calc.param.nbeta(); ++i)
764 calc.bocc[i] = 1.0;
765 } else if (calc.param.nbeta() > 0) {
766 calc.bmo = calc.amo; // spin-restricted: bmo mirrors amo (see update_subspace)
767 }
768 }
769
770 // project orbitals into higher k. Not needed on the first rung we
771 // run: the orbitals were either just made at that k, or read at it
772 // because set_protocol ran before load_mos.
773 if (proto > plan.protocol_start) calc.project(world);
774
775 // If the basis for the inital guess was not sto-3g
776 // switch to sto-3g since this is needed for analysis
777 // of the MOs and orbital localization
778 // Only do this if not starting from NWChem.
779 // analysis will be done on NWChem orbitals.
780
781 if (calc.param.aobasis() != "sto-3g") { // was also && calc.param.nwfile() == "none"
782 calc.reset_aobasis("sto-3g");
783 }
784 calc.ao.clear(); world.gop.fence();
786 if (calc.param.freeze_occupied()) {
787 // The frozen solver reports the archive's energy. load_mos clears
788 // current_energy when it reprojects (a plan starting below the
789 // archive's rung), so take the header value the plan kept.
790 calc.current_energy = plan.stale_energy;
792 }
793 else calc.solve(world);
794
795 if (calc.param.save())
797
798 nv_old = nv;
799 if (nv == nvalpha) break;
800 }
801
802 }
803 return calc.current_energy;
804 }
805
807 value(x); // Ensures DFT equations are solved at this geometry
808
810 functionT brho = rho;
813 rho.gaxpy(1.0, brho, 1.0);
814
815 return calc.derivatives(world, rho);
816 }
817
818
820 value(molecule.get_all_coords().flat()); // Ensures DFT equations are solved at this geometry
821
823 functionT brho = rho;
826 rho.gaxpy(1.0, brho, 1.0);
827
830 }
831
833 nlohmann::json j = {};
837
839
840 nlohmann::json calc_precision={ };
842 calc_precision["dconv"]=calc.param.dconv();
843 calc_precision["econv"]=calc.param.econv();
846
847 auto mol_json=this->calc.molecule.to_json();
848
849 int_vals.push_back({"calcinfo_nmo", param.nmo_alpha() + param.nmo_beta()});
850 int_vals.push_back({"calcinfo_nalpha", param.nalpha()});
851 int_vals.push_back({"calcinfo_nbeta", param.nbeta()});
852 int_vals.push_back({"calcinfo_natom", calc.molecule.natom()});
853
854
855 to_json(j, int_vals);
856 // current_energy, not value(): a re-solve here would run on rank 0 only
857 // (non-collective), and the nwfile guess translates the molecule, which
858 // stales value()'s coords cache.
859 double_vals.push_back({"return_energy", calc.current_energy});
861 double_tensor_vals.push_back({"scf_eigenvalues_a", calc.aeps});
862 if (param.nbeta() != 0 && !param.spin_restricted()) {
863 double_tensor_vals.push_back({"scf_eigenvalues_b", calc.beps});
864 }
865
867 param.to_json(j);
869
870 j["precision"]=calc_precision;
871 j["molecule"]=mol_json;
872
873 output_schema(param.prefix()+".calc_info", j);
874 }
875
876
877};
878}
879
880#endif /* SCF_H_ */
881
void to_json(json &j, const FunctionIOData< T, NDIM > &p)
Definition FunctionIO.h:274
decide once, per geometry, where the initial orbitals come from
the header of a restartdata archive, in one place
Operators for the molecular HF and DFT code.
A MADNESS functor to compute either x, y, or z.
Definition preal.cc:115
Contracted Gaussian basis.
Definition madness/chem/molecularbasis.h:469
void read_file(std::string filename)
read the atomic basis set from file
Definition molecularbasis.cc:119
DipoleFunctor(int axis)
Definition SCF.h:152
double operator()(const coordT &x) const
Definition SCF.h:154
const int axis
Definition solver.h:167
interface class to simple-dftd3, Grimme's D3 empirical dispersion correction
Definition dispersion.h:62
Manages data associated with a row/column/block distributed array.
Definition distributed_matrix.h:388
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 void set_apply_randomize(bool value)
Sets the random load balancing for integral operators flag.
Definition funcdefaults.h:299
static void set_thresh(double value)
Sets the default threshold.
Definition funcdefaults.h:190
static void set_k(int value)
Sets the default wavelet order.
Definition funcdefaults.h:177
static const double & get_thresh()
Returns the default threshold.
Definition funcdefaults.h:183
static void set_autorefine(bool value)
Sets the default adaptive autorefinement flag.
Definition funcdefaults.h:267
static void set_project_randomize(bool value)
Sets the random load balancing for projection flag.
Definition funcdefaults.h:310
static void set_initial_level(int value)
Sets the default initial projection level.
Definition funcdefaults.h:207
static void set_cubic_cell(double lo, double hi)
Sets the user cell to be cubic with each dimension having range [lo,hi].
Definition funcdefaults.h:383
static void set_refine(bool value)
Sets the default adaptive refinement flag.
Definition funcdefaults.h:255
FunctionFactory implements the named-parameter idiom for Function.
Definition function_factory.h:86
Abstract base class interface required for functors used as input to Functions.
Definition function_interface.h:68
FunctionFunctorInterface()
Definition function_interface.h:77
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition funcimpl.h:136
bool is_leaf() const
Returns true if this does not have children.
Definition funcimpl.h:223
A multiresolution adaptive numerical function.
Definition mra.h:144
Function< T, NDIM > & gaxpy(const T &alpha, const Function< Q, NDIM > &other, const R &beta, bool fence=true)
Inplace, general bi-linear operation in wavelet basis. No communication except for optional fence.
Definition mra.h:1156
Key is the index for a node of the 2^NDIM-tree.
Definition key.h:70
Level level() const
Definition key.h:169
Definition SCF.h:620
bool selftest()
Definition SCF.h:631
bool provides_gradient() const
Override this to return true if the derivative is implemented.
Definition SCF.h:633
double value(const Tensor< double > &x)
Should return the value of the objective function.
Definition SCF.h:635
World & world
Definition SCF.h:621
SCF & calc
Definition SCF.h:622
double coords_sum
Definition SCF.h:623
void output_calc_info_schema()
Definition SCF.h:832
madness::Tensor< double > gradient(const Tensor< double > &x)
Should return the derivative of the function.
Definition SCF.h:806
void energy_and_gradient(const Molecule &molecule, double &energy, Tensor< double > &gradient)
Definition SCF.h:819
std::string name() const
Definition SCF.h:629
MolecularEnergy(World &world, SCF &calc)
Definition SCF.h:626
Definition molecule.h:129
void set_all_coords(const madness::Tensor< double > &newcoords)
Definition molecule.cc:474
size_t natom() const
Definition molecule.h:463
static void print_parameters()
Definition molecule.cc:120
json to_json() const
Definition molecule.cc:512
GeometryParameters parameters
Definition molecule.h:334
A MADNESS functor to compute the cartesian moment x^i * y^j * z^k (i, j, k integer and >= 0)
Definition SCF.h:161
const int j
Definition SCF.h:163
double operator()(const coordT &r) const
Definition SCF.h:171
MomentFunctor(int i, int j, int k)
Definition SCF.h:167
const int i
Definition SCF.h:163
MomentFunctor(const std::vector< int > &x)
Definition SCF.h:169
const int k
Definition SCF.h:163
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
void set_user_defined_value(const std::string &key, const T &value)
Definition chem/QCCalculationParametersBase.h:542
T get(const std::string key) const
Definition chem/QCCalculationParametersBase.h:306
void print(const std::string header="", const std::string footer="") const
print all parameters
Definition QCCalculationParametersBase.cc:32
class implementing properties of QC models
Definition QCPropertyInterface.h:11
Definition SCF.h:200
void copy_data(World &world, const SCF &other)
Definition SCF.cc:284
void do_plots(World &world)
Definition SCF.cc:583
tensorT derivatives(World &world, const functionT &rho) const
Definition SCF.cc:1663
void save_mos(World &world)
Definition SCF.cc:298
vecfuncT apply_bsh_plain(World &world, vecfuncT &Vpsi, const tensorT &eps, const CalculationParameters &param)
Single un-tiled apply (small systems / debugging). Consumes Vpsi.
Definition SCF.cc:1959
Representation restart_representation
Definition SCF.h:259
void output_scf_info_schema(const std::map< std::string, double > &vals, const tensorT &dipole_T) const
Definition SCF.cc:145
static vecfuncT project_ao_basis_only(World &world, const AtomicBasisSet &aobasis, const Molecule &molecule)
Definition SCF.cc:696
const tensorT & get_aocc() const
getter for the occupation numbers, alpha spin
Definition SCF.h:372
std::shared_ptr< GTHPseudopotential< double > > gthpseudopotential
Definition SCF.h:204
std::string restart_ncf
nuclear correlation factor behind restart_representation, e.g. "slater:2.0"
Definition SCF.h:262
void make_nuclear_potential(World &world)
Definition SCF.cc:671
bool pad_virtuals_from_guess(World &world)
Definition SCF.cc:1358
std::vector< long > localize_pivot_state_a
cholesky localization's pivot order from the previous iteration (per spin)
Definition SCF.h:231
vecfuncT apply_bsh_tiled(World &world, vecfuncT &Vpsi, const tensorT &eps, const CalculationParameters &param)
Definition SCF.cc:1924
std::vector< int > aset
Definition SCF.h:229
static void print_parameters()
Definition SCF.h:303
AtomicBasisSet aobasis
Definition SCF.h:219
SCF(World &world, const commandlineparser &parser)
forwarding constructor
Definition SCF.h:269
vecfuncT ao
MRA projection of the minimal basis set.
Definition SCF.h:234
scf_data e_data
Definition SCF.h:222
void apply_explicit_occupations(World &world)
overwrite the leading occupation numbers with the explicit aocc/bocc input, if given
Definition SCF.cc:1432
vecfuncT apply_potential(World &world, const tensorT &occ, const vecfuncT &amo, const functionT &vlocal, double &exc, double &enl, int ispin)
Definition SCF.cc:1538
vecfuncT amo
alpha and beta molecular orbitals
Definition SCF.h:225
vecfuncT compute_residual(World &world, tensorT &occ, tensorT &fock, const vecfuncT &psi, vecfuncT &Vpsi, double &err)
Definition SCF.cc:1981
const tensorT & get_bocc() const
getter for the occupation numbers, alpha spin
Definition SCF.h:375
std::vector< int > at_to_bf
Definition SCF.h:236
void get_initial_orbitals(World &world, RestartPlan &plan)
carry out a restart plan: read the orbitals it names, or make a guess
Definition SCF.cc:492
std::vector< int > bset
Definition SCF.h:229
void solve_virtuals(World &world)
Definition SCF.cc:2361
DispersionCorrection dispersion
Definition SCF.h:218
distmatT kinetic_energy_matrix(World &world, const vecfuncT &v) const
Definition SCF.cc:768
tensorT bocc
Definition SCF.h:239
double vtol
Definition SCF.h:245
tensorT dipole(World &world, const functionT &rho) const
compute the total dipole moment of the molecule
Definition SCF.cc:1745
PCM pcm
Definition SCF.h:210
bool is_spin_restricted() const
Definition SCF.h:377
poperatorT coulop
Definition SCF.h:243
double make_dft_energy(World &world, const vecfuncT &vf, int ispin)
Definition SCF.h:483
void output_calc_info_schema() const
Definition SCF.cc:160
static void help()
Definition SCF.h:285
void update_subspace(World &world, vecfuncT &Vpsia, vecfuncT &Vpsib, tensorT &focka, tensorT &fockb, subspaceT &subspace, tensorT &Q, double &bsh_residual, double &update_residual)
Definition SCF.cc:2552
Molecule molecule
Definition SCF.h:205
tensorT beps
Definition SCF.h:242
tensorT kain_solve(World &world, const vecfuncT &vm, const vecfuncT &rm, subspaceT &subspace, tensorT &Q) const
Definition SCF.cc:2467
void load_mos(World &world, const bool allow_fewer=true)
Definition SCF.cc:347
tensorT diag_fock_matrix(World &world, tensorT &fock, vecfuncT &psi, vecfuncT &Vpsi, tensorT &evals, const tensorT &occ, const double thresh) const
diagonalize the fock matrix, taking care of degenerate states
Definition SCF.cc:2187
const vecfuncT & get_amo() const
getter for the molecular orbitals, alpha spin
Definition SCF.h:366
static void analyze_vectors(World &world, const vecfuncT &mo, const vecfuncT &ao, double vtol, const Molecule &molecule, const int print_level, const AtomicBasisSet &aobasis, const tensorT &occ=tensorT(), const tensorT &energy=tensorT(), const std::vector< int > &set=std::vector< int >())
Definition SCF.cc:710
XCfunctional xc
Definition SCF.h:209
void initial_load_bal(World &world)
Definition SCF.cc:1448
std::vector< int > at_nbf
Definition SCF.h:236
std::vector< long > localize_pivot_state_b
Definition SCF.h:231
double do_step_restriction(World &world, const vecfuncT &mo, vecfuncT &mo_new, std::string spin) const
perform step restriction following the KAIN solver
Definition SCF.cc:2638
std::vector< std::shared_ptr< real_derivative_3d > > gradop
Definition SCF.h:244
vecfuncT kain_combine(World &world, const subspaceT &subspace, const tensorT &c, const size_t lo, const size_t n) const
KAIN: the updated orbitals lo..lo+n of the subspace's vectors for coefficients c.
Definition SCF.cc:2524
void set_print_timings(const bool value)
Definition SCF.cc:280
double converged_for_dconv
mos are converged for this density
Definition SCF.h:248
tensorT get_fock_transformation(World &world, const tensorT &overlap, tensorT &fock, tensorT &evals, const tensorT &occ, const double thresh_degenerate) const
compute the unitary transformation that diagonalizes the fock matrix
Definition SCF.cc:2156
vecfuncT apply_bsh_macrotask(World &world, vecfuncT &Vpsi, const tensorT &eps, const CalculationParameters &param, long batch, bool redistribute)
Definition SCF.cc:1794
bool restart_aos(World &world)
Definition SCF.cc:803
tensorT aeps
orbital energies for alpha and beta orbitals
Definition SCF.h:242
functionT make_coulomb_potential(const functionT &rho) const
make the Coulomb potential given the total density
Definition SCF.h:521
tensorT make_fock_matrix(World &world, const vecfuncT &psi, const vecfuncT &Vpsi, const tensorT &occ, double &ekinetic) const
Definition SCF.cc:2068
double converged_for_tconv
derivatives of mos are converged for this threshold
Definition SCF.h:249
Tensor< double > twoint(World &world, const vecfuncT &psi) const
Compute the two-electron integrals over the provided set of orbitals.
Definition SCF.cc:2126
tensorT aocc
occupation numbers for alpha and beta orbitals
Definition SCF.h:239
void set_protocol(World &world, double thresh)
Definition SCF.h:314
static functionT make_lda_potential(World &world, const functionT &arho)
Definition SCF.cc:1530
functionT make_density(World &world, const tensorT &occ, const vecfuncT &v) const
Definition SCF.cc:1465
void rotate_subspace(World &world, const tensorT &U, subspaceT &subspace, int lo, int nfunc, double trantol) const
Definition SCF.cc:2327
PCMParameters pcm_param
the pcm data group; inert unless param.pcm_data() is set
Definition SCF.h:208
bool canonicalize_virtuals(World &world, tensorT &fock, vecfuncT &psi, vecfuncT &Vpsi, const int nocc, const bool force=false) const
Definition SCF.cc:2220
void reset_aobasis(const std::string &aobasisname)
Definition SCF.h:398
void project(World &world)
Definition SCF.cc:649
double converged_for_thresh
mos are converged for this threshold
Definition SCF.h:247
bool suppress_raw_gradient_print
Definition SCF.h:266
CalculationParameters param
Definition SCF.h:206
double current_energy
Definition SCF.h:246
void loadbal(World &world, functionT &arho, functionT &brho, functionT &arho_old, functionT &brho_old, subspaceT &subspace)
Definition SCF.cc:2292
void vector_stats(const std::vector< double > &v, double &rms, double &maxabsval) const
Definition SCF.cc:1771
vecfuncT project_ao_basis(World &world, const AtomicBasisSet &aobasis)
Definition SCF.cc:688
std::vector< int > group_orbital_sets(World &world, const tensorT &eps, const tensorT &occ, const int nmo) const
group orbitals into sets of similar orbital energies for localization
Definition SCF.cc:1407
void initial_guess_ao_eigenvectors(World &world, tensorT &c, tensorT &e)
Definition SCF.cc:1107
void kain_trim(subspaceT &subspace, tensorT &Q) const
KAIN: drop the oldest history entry once the subspace holds maxsub of them.
Definition SCF.cc:2542
void initial_guess_from_nwchem(World &world)
Definition SCF.cc:859
functionT mask
Definition SCF.h:220
std::shared_ptr< PotentialManager > potentialmanager
Definition SCF.h:203
static std::vector< poperatorT > make_bsh_operators(World &world, const tensorT &evals, const CalculationParameters &param)
Definition SCF.cc:1506
const vecfuncT & get_bmo() const
getter for the molecular orbitals, beta spin
Definition SCF.h:369
vecfuncT bmo
Definition SCF.h:225
void solve(World &world)
Definition SCF.cc:2737
void orthonormalize(World &world, vecfuncT &amo_new) const
orthonormalize the vectors
Definition SCF.cc:2710
std::filesystem::path work_dir
Definition SCF.h:202
Definition operator.h:156
A slice defines a sub-range or patch of a dimension.
Definition slice.h:103
A tensor is a multidimensional array.
Definition tensor.h:318
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition tensor.h:1385
T sumsq() const
Returns the sum of the squares of the elements.
Definition tensor.h:1670
A simple, fixed dimension vector.
Definition vector.h:64
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
Simplified interface to XC functionals.
Definition xcfunctional.h:49
Definition SCF.h:180
std::map< std::string, std::vector< double > > e_data
Definition SCF.h:182
void add_gradient(const Tensor< double > &grad)
Definition SCF.cc:232
int iter
Definition SCF.h:185
void to_json(json &j) const
Definition SCF.cc:215
void add_data(std::map< std::string, double > values)
Definition SCF.cc:191
json hessian
Definition SCF.h:184
json gradient
Definition SCF.h:183
scf_data()
Definition SCF.cc:201
void print_data()
Definition SCF.cc:228
Declaration of core potential related class.
double(* energy)()
Definition derivatives.cc:58
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
static double lo
Definition dirac-hatom.cc:23
double psi(const Vector< double, 3 > &r)
Definition hatom_energy.cc:78
static const double v
Definition hatom_sf_dirac.cc:20
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Main include file for MADNESS and defines Function interface.
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
void print_header2(const std::string &s)
medium section heading
Definition print.cc:54
Vector< double, 3 > coordT
Definition corepotential.cc:54
static void user_to_sim(const Vector< double, NDIM > &xuser, Vector< double, NDIM > &xsim)
Convert user coords (cell[][]) to simulation coords ([0,1]^ndim)
Definition funcdefaults.h:469
Tensor< double > tensorT
Definition distpm.cc:21
Function< std::complex< double >, 3 > complex_functionT
Definition SCF.h:82
@ automatic
look at what is on disk and choose (the default)
RestartMode restart_mode_from_string(const std::string &s)
Definition RestartPlan.h:83
std::vector< pairvecfuncT > subspaceT
Definition SCF.h:76
double mask1(double x)
Definition SCF.h:108
RestartPlan make_restart_plan(World &world, const RestartMode mode, const CalculationParameters &param, const Molecule &requested, const Representation wanted, const RestartCapabilities &can, const std::string &ncf="")
Definition RestartPlan.h:619
DistributedMatrix< double > distmatT
Definition SCF.h:78
std::pair< vecfuncT, vecfuncT > pairvecfuncT
Definition SCF.h:75
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
FunctionFactory< double, 3 > factoryT
Definition corepotential.cc:57
nlohmann::json json
Definition chem/QCCalculationParametersBase.h:30
std::shared_ptr< operatorT> poperatorT
Definition SCF.h:81
Function< double, 3 > functionT
Definition corepotential.cc:56
NDIM & f
Definition mra.h:2668
std::shared_ptr< FunctionFunctorInterface< double, 3 > > functorT
Definition corepotential.cc:55
std::vector< complex_functionT > cvecfuncT
Definition SCF.h:83
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:1766
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
static double mask3(const coordT &ruser)
Definition SCF.h:122
std::shared_ptr< WorldDCPmapInterface< Key< 3 > > > pmapT
Definition SCF.h:70
@ initial_guess
atomic guess, i.e. no restart at all
@ restartdata
<prefix>.restartdata, MRA orbitals
std::vector< Function< T, NDIM > > grad(const Function< T, NDIM > &f, bool refine=false, bool fence=true)
shorthand gradient operator
Definition vmra.h:2316
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
SeparatedConvolution< double, 3 > operatorT
Definition SCF.h:80
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition mra.h:2233
Representation
Definition Restart.h:57
@ mo
moldft orbitals psi
static const size_t nfunc
Definition pcr.cc:63
Declaration of molecule-related classes and functions.
double Q(double a)
Definition relops.cc:20
static const double c
Definition relops.cc:10
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
Defines interfaces for optimization and non-linear equation solvers.
std::string prefix
Definition tdse.cc:71
Definition CalculationParameters.h:51
std::vector< double > protocol() const
Definition CalculationParameters.h:252
int nv_its() const
Definition CalculationParameters.h:208
std::string restart() const
the restart keyval as a string; parse with restart_mode_from_string()
Definition CalculationParameters.h:258
int k() const
Definition CalculationParameters.h:220
int nmo_alpha() const
Definition CalculationParameters.h:211
bool freeze_occupied() const
Definition CalculationParameters.h:209
bool save() const
Definition CalculationParameters.h:253
double dconv() const
Definition CalculationParameters.h:179
double econv() const
Definition CalculationParameters.h:178
int print_level() const
Definition CalculationParameters.h:229
std::string deriv() const
Definition CalculationParameters.h:234
double L() const
Definition CalculationParameters.h:219
int nv_step() const
Definition CalculationParameters.h:207
std::string aobasis() const
Definition CalculationParameters.h:250
int nalpha() const
Definition CalculationParameters.h:199
int nv_extra() const
Definition CalculationParameters.h:206
int nbeta() const
Definition CalculationParameters.h:200
int nmo_beta() const
Definition CalculationParameters.h:212
bool have_beta() const
Definition CalculationParameters.h:214
bool spin_restricted() const
Definition CalculationParameters.h:216
int maxiter() const
Definition CalculationParameters.h:231
double lo() const
Definition CalculationParameters.h:218
std::string pcm_data() const
Definition CalculationParameters.h:237
Definition convolution1d.h:985
double eprec() const
Definition molecule.h:306
The interface to be provided by functions to be optimized.
Definition solvers.h:176
static RestartCapabilities all()
Definition RestartPlan.h:146
the decision: one source, one starting rung, one reason
Definition RestartPlan.h:186
very simple command line parser
Definition commandlineparser.h:28
Definition SCF.h:87
double parent_value
Definition SCF.h:89
lbcost(double leaf_value=1.0, double parent_value=0.0)
Definition SCF.h:91
double leaf_value
Definition SCF.h:88
double operator()(const Key< NDIM > &key, const FunctionNode< T, NDIM > &node) const
Definition SCF.h:93
Class to compute the energy functional.
Definition xcfunctional.h:573
InputParameters param
Definition tdse.cc:203
void e()
Definition test_sig.cc:75
constexpr std::size_t NDIM
Definition testgconv.cc:54
static Molecule molecule
Definition testperiodicdft.cc:39
static Subspace * subspace
Definition testperiodicdft.cc:41