104 return value(
nemo_ptr->get_calc()->molecule.get_all_coords());
110 double xsq = x.
sumsq();
119 return nemo_ptr->get_calc()->current_energy;
184 return nemo_ptr->get_calc()->amo[i];
191 std::vector<real_function_3d>
nemos()
const {
199 return nemo_ptr->get_calc()->aeps[i];
213 return nemo_ptr->get_calc()->potentialmanager->vnuclear();
219 return nemo_ptr->get_param().nalpha();
239 if (
function.world().rank() == 0) {
240 printf(
"final correlation energy %2d %2d %12.8f %12.8f\n",
265 template<
typename Archive>
267 bool fexist =
function.is_initialized();
271 if (fexist) ar &
function;
279 if (world.
rank() == 0) printf(
"loading matrix elements %s",
name.c_str());
282 if (world.
rank() == 0) printf(
" %s\n", (
converged) ?
" converged" :
" not converged");
286 if (world.
rank() == 0)
print(
"could not find pair ",
i,
j,
" on disk");
293 if (world.
rank() == 0) printf(
"storing matrix elements %s\n",
name.c_str());
300 if (world.
rank() == 0) {
301 std::cout << std::setw(20) << std::setfill(
' ') <<
" *Information about Electron Pair " <<
i <<
j <<
" "
302 << std::setw(20) << std::setfill(
' ') << std::endl;
303 std::cout << std::setw(20) << std::setfill(
' ') <<
" *e_singlet " <<
e_singlet <<
" " << std::setw(20)
304 << std::setfill(
' ') << std::endl;
305 std::cout << std::setw(20) << std::setfill(
' ') <<
" *e_triplet " <<
e_triplet <<
" " << std::setw(20)
306 << std::setfill(
' ') << std::endl;
307 std::cout << std::setw(20) << std::setfill(
' ') <<
" *ij_gQf_ij " <<
ij_gQf_ij <<
" " << std::setw(20)
308 << std::setfill(
' ') << std::endl;
309 std::cout << std::setw(20) << std::setfill(
' ') <<
" *ji_gQf_ij " <<
ji_gQf_ij <<
" " << std::setw(20)
310 << std::setfill(
' ') << std::endl;
327 initialize < double > (
"thresh", 1.e-3,
"recommended values: 1.e-4 < econv < 1.e-8");
328 initialize < double > (
"econv", 1.e-3,
"recommended values: 1.e-4 < econv < 1.e-8");
329 initialize < double > (
"dconv", 1.e-3,
"recommended values: 1.e-4 < econv < 1.e-8");
330 initialize < std::vector<int> > (
"pair", {-1, -1});
331 initialize < int > (
"freeze", 0);
332 initialize < int > (
"maxsub", 2);
333 initialize < bool > (
"restart",
true);
334 initialize < bool > (
"no_compute",
false);
335 initialize < int > (
"maxiter", 5);
361 double thresh()
const {
return get<double>(
"thresh"); }
362 double econv()
const {
return get<double>(
"econv"); }
363 double dconv()
const {
return this->get<double>(
"dconv"); }
364 int freeze()
const {
return this->get<int>(
"freeze"); }
365 int i()
const {
return this->get<std::vector<int> >(
"pair")[0]; }
366 int j()
const {
return this->get<std::vector<int> >(
"pair")[1]; }
367 int restart()
const {
return this->get<bool>(
"restart"); }
368 int no_compute()
const {
return this->get<bool>(
"no_compute"); }
369 int maxiter()
const {
return this->get<int>(
"maxiter"); }
370 int maxsub()
const {
return this->get<int>(
"maxsub"); }
383 return allpairs.find(std::make_pair(i, j))->second;
388 return allpairs[std::make_pair(i, j)];
393 std::pair<int, int> key = std::make_pair(i, j);
394 allpairs.insert(std::make_pair(key, pair));
401 std::shared_ptr<HartreeFock>
hf;
420 std::string
name()
const {
return "MP2";};
424 print(
"The mp2 code computes second order correlation energies based on a moldft or nemo calculation");
425 print(
"You can print all available calculation parameters by running\n");
426 print(
"mp2 --print_parameters\n");
427 print(
"You can perform a simple calculation by running\n");
428 print(
"mp2 --geometry=h2o.xyz\n");
429 print(
"provided you have an xyz file in your directory.");
435 print(
"default parameters for the mp2 program are");
437 print(
"\n\nthe molecular geometry must be specified in a separate block:");
464 return hf->orbital_energy(i) +
hf->orbital_energy(j);
484 const double econv,
const double dconv)
const;
492 const double econv,
const double dconv)
const;
524 std::cout << std::setfill(
' ') << std::setw(30);
525 std::cout << option <<
" " << val << std::endl;
535 template<
typename T,
size_t NDIM>
539 template<
typename T,
size_t NDIM>
610 const bool hc =
false)
const;
624 const bool hc =
false)
const;
637 const bool hc =
false)
const;
641 const bool hc =
false)
const;
655 const int i,
const int j)
const;
660 const int i,
const int j) {
672 const std::vector<real_function_3d>& nemos =
hf->nemos();
673 const std::vector<real_function_3d>& R2amo =
hf->R2orbitals();
676 print(
"set orbital spaces for the SO projector");
677 print(
"Q12,R = (1-|nemo><nemo|R2) (1-|nemo><nemo|R2)");
689 fock =
hf->nemo_ptr->compute_fock_matrix(
hf->nemos(), occ);
691 print(
"The Fock matrix");
716 if (
world.
rank() == 0) printf(
"timer: %20.20s %8.2fs %8.2fs\n", msg,
sss,
ttt);
enhanced POD for the pair functions
Definition: mp2.h:225
void print_energy() const
print the pair's energy
Definition: mp2.h:238
double ij_gQf_ij
<ij | g12 Q12 f12 | ij>
Definition: mp2.h:254
ElectronPair(const int i, const int j)
ctor; initialize energies with a large number
Definition: mp2.h:232
double ji_gQf_ij
<ji | g12 Q12 f12 | ij>
Definition: mp2.h:255
void store_pair(World &world)
Definition: mp2.h:291
bool converged
is the pair function converged
Definition: mp2.h:258
void serialize(Archive &ar)
serialize this ElectronPair
Definition: mp2.h:266
ElectronPair()
default ctor; initialize energies with a large number
Definition: mp2.h:229
double e_singlet
the energy of the singlet pair ij
Definition: mp2.h:251
bool load_pair(World &world)
Definition: mp2.h:275
double e_triplet
the energy of the triplet pair ij
Definition: mp2.h:252
int j
orbitals i and j
Definition: mp2.h:247
int iteration
current iteration for restart
Definition: mp2.h:257
int i
Definition: mp2.h:247
real_function_6d function
pair function for a specific pair w/o correlation factor part
Definition: mp2.h:248
static double uninitialized()
Definition: mp2.h:245
real_function_6d constant_term
the first order contribution to the MP1 wave function
Definition: mp2.h:249
void info(World &world) const
Definition: mp2.h:299
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:204
FunctionNode holds the coefficients, etc., at each node of the 2^NDIM-tree.
Definition: funcimpl.h:124
coeffT & coeff()
Returns a non-const reference to the tensor containing the coeffs.
Definition: funcimpl.h:223
void set_thresh(double value, bool fence=true)
Sets the value of the truncation threshold. Optional global fence.
Definition: mra.h:577
bool is_initialized() const
Returns true if the function is initialized.
Definition: mra.h:147
long size() const
Definition: lowranktensor.h:482
Definition: hartreefock.h:138
real_function_3d R2orbital(const int i) const
return orbital i, multiplied with the square nuclear correlation factor
Definition: mp2.h:173
bool provides_gradient() const
Definition: mp2.h:101
Tensor< double > gradient(const Tensor< double > &x)
Definition: mp2.h:130
double value()
Definition: mp2.h:103
double value(const Tensor< double > &x)
Definition: mp2.h:107
std::vector< real_function_3d > orbitals_
reconstructed orbitals: R * phi, where R is the nuclear correlation factor
Definition: mp2.h:87
std::vector< real_function_3d > R2orbitals_
Definition: mp2.h:91
real_function_3d nemo(const int i) const
return nemo i, which is the regularized orbital
Definition: mp2.h:182
std::shared_ptr< Nemo > nemo_ptr
Definition: mp2.h:79
int nocc() const
return the number of occupied orbitals
Definition: mp2.h:217
SCF & get_calc()
Definition: mp2.h:140
World & world
Definition: mp2.h:77
HartreeFock(World &world, std::shared_ptr< Nemo > nemo)
Definition: mp2.h:95
const SCF & get_calc() const
Definition: mp2.h:138
real_function_3d coulomb
Definition: mp2.h:84
std::vector< real_function_3d > R2orbitals() const
return orbitals, multiplied with the square nuclear correlation factor
Definition: mp2.h:164
World & get_world()
Definition: mp2.h:99
double orbital_energy(const int i) const
return orbital energy i
Definition: mp2.h:197
double coord_chksum() const
Definition: mp2.h:136
void reset_orbitals(const MolecularOrbitals< double, 3 > &mos)
Definition: mp2.h:122
double coords_sum
Definition: mp2.h:81
real_function_3d orbital(const int i) const
return full orbital i, multiplied with the nuclear correlation factor
Definition: mp2.h:146
real_function_3d get_coulomb_potential() const
return the Coulomb potential
Definition: mp2.h:203
std::vector< real_function_3d > orbitals() const
return full orbitals, multiplied with the nuclear correlation factor
Definition: mp2.h:155
std::vector< real_function_3d > nemos() const
return nemo, which are the regularized orbitals
Definition: mp2.h:191
real_function_3d get_nuclear_potential() const
return the nuclear potential
Definition: mp2.h:212
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
a class for computing the first order wave function and MP2 pair energies
Definition: mp2.h:317
double asymmetry(const real_function_6d &f, const std::string s) const
Definition: madness/chem/mp2.cc:490
CorrelationFactor corrfac
correlation factor: Slater
Definition: mp2.h:402
ElectronPair make_pair(const int i, const int j) const
compute some matrix elements that don't change during the SCF
bool check_core_valence_separation() const
make sure frozen orbitals don't couple with correlated ones – relocalize if necessary
Definition: madness/chem/mp2.cc:140
Tensor< double > fock
the Fock matrix
Definition: mp2.h:404
std::vector< real_function_3d > make_chi(const real_function_3d &phi, const real_convolution_3d &op, const bool hc=false) const
make the quantity chi_k
void END_TIMER(World &world, const char *msg) const
Definition: mp2.h:713
real_function_6d JK2phi0_on_demand(const int i, const int j, const bool hc=false) const
return the function (J(2)-K(2)) |phi0> as on-demand function
real_function_6d apply_exchange(const real_function_6d &f, const real_function_3d &orbital_ket, const real_function_3d &orbital_bra, const int particle) const
apply the exchange operator on f
real_function_6d get_residue(const real_function_6d &f, const int i, const int j)
Definition: mp2.h:659
virtual bool selftest()
Definition: mp2.h:440
Parameters param
SCF parameters for MP2.
Definition: mp2.h:400
double value()
return the molecular correlation energy energy (without the HF energy)
Definition: madness/chem/mp2.cc:134
double coord_chksum() const
return a checksum for the geometry
Definition: mp2.h:445
real_function_6d phi0_on_demand(const int i, const int j) const
return the function |phi0> as on-demand function
std::string name() const
Definition: mp2.h:420
real_function_6d make_Uphi0(ElectronPair &pair) const
return the function Uphi0; load from disk if available
Definition: madness/chem/mp2.cc:640
double solve_coupled_equations(Pairs< ElectronPair > &pairs, const double econv, const double dconv) const
solve the coupled MP1 equations (e.g. for local orbitals)
Definition: madness/chem/mp2.cc:366
double coords_sum
check sum for the geometry
Definition: mp2.h:408
double compute_energy(ElectronPair &pair) const
compute the singlet and triplet energy for a given electron pair
std::shared_ptr< HartreeFock > hf
our reference
Definition: mp2.h:401
real_function_6d make_fKphi0(const int i, const int j) const
apply the operator K on the reference and multiply with f; fK |phi^0>
MP2(World &world, const commandlineparser &parser)
ctor
Definition: madness/chem/mp2.cc:80
void add_local_coupling(const Pairs< ElectronPair > &pairs, Pairs< real_function_6d > &coupling) const
add the coupling terms for local MP2
void guess_mp1_3(ElectronPair &pair) const
compute the first iteration of the residual equations and all intermediates
World & world
the world
Definition: mp2.h:399
std::vector< real_function_3d > make_xi(const real_function_3d &phi_i, const real_function_3d &phi_j, const real_convolution_3d &op, const bool hc=false) const
make the quantity xi_k
real_function_6d nemo0_on_demand(const int i, const int j) const
return the function |F1F2> as on-demand function
Pairs< ElectronPair > pairs
pair functions and energies
Definition: mp2.h:406
real_function_6d K(const real_function_6d &phi, const bool is_symmetric=false) const
apply the exchange operator on a pair function
double ttt
Definition: mp2.h:705
void enforce_core_valence_separation()
make sure frozen orbitals don't couple with correlated ones – relocalize if necessary
Definition: madness/chem/mp2.cc:171
StrongOrthogonalityProjector< double, 3 > Q12
Definition: mp2.h:410
void save_function(const Function< T, NDIM > &f, const std::string name) const
save a function
Definition: madness/chem/mp2.cc:620
real_function_6d make_KffKphi0(const ElectronPair &pair) const
return the function [K,f] phi0; load from disk if available
std::shared_ptr< real_convolution_3d > poisson
Definition: mp2.h:414
void print_options(const std::string option, const T val) const
pretty print the options
Definition: mp2.h:523
double compute_gQf_cc2interface(const int i, const int j, const real_function_6d &f) const
compute the matrix element <ij | g12 Q12 f12 | phi^0>
Definition: mp2.h:510
std::shared_ptr< NuclearCorrelationFactor > nuclear_corrfac
Definition: mp2.h:403
static void help()
Definition: mp2.h:422
void load_function(Function< T, NDIM > &f, const std::string name) const
load a function
Definition: madness/chem/mp2.cc:631
Tensor< double > get_fock_matrix() const
Definition: mp2.h:686
real_function_6d multiply_with_0th_order_Hamiltonian(const real_function_6d &f, const int i, const int j) const
multiply the given function with the 0th order Hamiltonian, exluding the 0th order energy
double compute_gQf(const int i, const int j, ElectronPair &pair) const
compute the matrix element <ij | g12 Q12 f12 | phi^0>
Definition: madness/chem/mp2.cc:506
static void print_parameters()
Definition: mp2.h:433
double correlation_energy
the correlation energy
Definition: mp2.h:407
real_function_6d JK1phi0_on_demand(const int i, const int j, const bool hc=false) const
return the function (J(1)-K(1)) |phi0> as on-demand function
void solve_residual_equations(ElectronPair &pair, const double econv, const double dconv) const
solve the residual equation for electron pair (i,j)
Definition: madness/chem/mp2.cc:273
double zeroth_order_energy(const int i, const int j) const
return the 0th order energy of pair ij (= sum of orbital energies)
Definition: mp2.h:463
real_function_6d iterate(const real_function_6d &f) const
solve the residual equation for electron pair (i,j)
Definition: mp2.h:473
real_function_6d apply_exchange_vector(const real_function_6d &f, const int particle) const
HartreeFock & get_hf()
return the underlying HF reference
Definition: mp2.h:460
real_function_3d K(const real_function_3d &phi, const bool hc=false) const
apply the exchange operator on an orbital
void increment(ElectronPair &pair, real_convolution_6d &green)
compute increments: psi^1 = C + GV C + GVGV C + GVGVGV C + ..
Definition: madness/chem/mp2.cc:453
double sss
Definition: mp2.h:705
void START_TIMER(World &world) const
Definition: mp2.h:707
real_function_3d J(const real_function_3d &phi) const
apply the Coulomb operator a on orbital
real_function_6d debug_cc2(const real_function_6d &f, const size_t &i, const size_t &j) const
Definition: mp2.h:528
Definition: MolecularOrbitals.h:24
std::vector< Function< T, NDIM > > get_mos() const
Definition: MolecularOrbitals.h:64
Tensor< double > get_eps() const
Definition: MolecularOrbitals.h:68
static void print_parameters()
Definition: molecule.cc:110
@ None
Definition: correlationfactor.h:85
class for holding the parameters for calculation
Definition: QCCalculationParametersBase.h:290
virtual void read_input_and_commandline_options(World &world, const commandlineparser &parser, const std::string tag)
Definition: QCCalculationParametersBase.h:325
void print(const std::string header="", const std::string footer="") const
print all parameters
Definition: QCCalculationParametersBase.cc:22
void set_derived_value(const std::string &key, const T &value)
Definition: QCCalculationParametersBase.h:403
class implementing properties of QC models
Definition: QCPropertyInterface.h:11
Convolutions in separated form (including Gaussian)
Definition: operator.h:136
void set_spaces(const vecfuncT &p)
set the same spaces for the projectors for particle 1 and 2
Definition: projector.h:281
Tensor< T > reshape(int ndimnew, const long *d)
Returns new view/tensor reshaping size/number of dimensions to conforming tensor.
Definition: tensor.h:1384
T sumsq() const
Returns the sum of the squares of the elements.
Definition: tensor.h:1669
bool has_data() const
Definition: tensor.h:1886
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition: worldgop.cc:161
A parallel world class.
Definition: world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
WorldGopInterface & gop
Global operations.
Definition: world.h:205
static std::enable_if_t< std::is_same< X, BinaryFstreamInputArchive >::value||std::is_same< X, BinaryFstreamOutputArchive >::value, bool > exists(World &world, const char *filename)
Returns true if the named, unopened archive exists on disk with read access.
Definition: parallel_archive.h:224
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition: parallel_archive.h:321
Objects that implement their own parallel archive interface should derive from this class.
Definition: parallel_archive.h:58
Wraps an archive around a text filestream for input.
Definition: text_fstream_archive.h:148
Wraps an archive around a text filestream for output.
Definition: text_fstream_archive.h:54
auto T(World &world, response_space &f) -> response_space
Definition: global_functions.cc:34
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
Implements (2nd generation) static load/data balancing for functions.
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition: madness_exception.h:190
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition: madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
Main include file for MADNESS and defines Function interface.
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static std::string stringify(T arg)
Definition: funcplot.h:1034
void print_header2(const std::string &s)
medium section heading
Definition: print.cc:54
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition: timers.h:127
void truncate(World &world, response_space &v, double tol, bool fence)
Definition: basic_operators.cc:30
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:2002
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition: print.h:225
NDIM & f
Definition: mra.h:2416
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition: timers.cc:48
std::string name(const FuncType &type, const int ex=-1)
Definition: ccpairfunction.h:28
Implementation of Krylov-subspace nonlinear equation solver.
double leaf_value
Definition: mp2.h:64
double operator()(const Key< 6 > &key, const FunctionNode< double, 6 > &node) const
Definition: mp2.h:70
LBCost(double leaf_value=1.0, double parent_value=1.0)
Definition: mp2.h:67
double parent_value
Definition: mp2.h:65
POD holding all electron pairs with easy access.
Definition: mp2.h:376
std::map< std::pair< int, int >, T > pairmapT
Definition: mp2.h:378
pairmapT allpairs
Definition: mp2.h:379
const T & operator()(int i, int j) const
getter
Definition: mp2.h:382
T & operator()(int i, int j)
getter
Definition: mp2.h:387
void insert(int i, int j, T pair)
setter
Definition: mp2.h:392
POD for MP2 keywords.
Definition: mp2.h:320
bool do_oep1
use OEP orbitals
Definition: mp2.h:323
int i() const
convenience function
Definition: mp2.h:365
Parameters()
Definition: mp2.h:325
int restart() const
convenience function
Definition: mp2.h:367
double dconv() const
convenience function
Definition: mp2.h:363
int maxsub() const
convenience function
Definition: mp2.h:370
int freeze() const
convenience function
Definition: mp2.h:364
int maxiter() const
convenience function
Definition: mp2.h:369
bool do_oep() const
convenience function
Definition: mp2.h:371
void read_and_set_derived_values(World &world, const commandlineparser &parser)
Definition: mp2.h:346
Parameters(World &world, const commandlineparser &parser)
ctor reading out the input file
Definition: mp2.h:339
int j() const
convenience function
Definition: mp2.h:366
double thresh() const
Definition: mp2.h:361
double econv() const
convenience function
Definition: mp2.h:362
int no_compute() const
convenience function
Definition: mp2.h:368
void check_input(const std::shared_ptr< HartreeFock > hf) const
check the user input
Definition: mp2.h:354
The interface to be provided by functions to be optimized.
Definition: solvers.h:176
Definition: CCStructures.h:421
very simple command line parser
Definition: commandlineparser.h:15
Definition: lowrankfunction.h:332
Implements an archive wrapping text filestream.