Psi4
ccsd.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2018 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef CCSD_H
30 #define CCSD_H
31 
32 #include "psi4/psi4-dec.h"
33 #include "psi4/libiwl/iwl.h"
34 #include "psi4/libpsio/psio.hpp"
35 #include "psi4/libpsio/psio.h"
37 #include "psi4/psifiles.h"
39 
40 PSI_API long int Position(long int i, long int j);
41 
42 namespace psi {
43 namespace fnocc {
44 
45 class CoupledCluster : public Wavefunction {
46  public:
47  CoupledCluster(std::shared_ptr<Wavefunction> reference_wavefunction, Options &options);
49 
50  double compute_energy();
51 
52  protected:
53  int iter;
55 
56  void common_init();
57  void finalize();
58 
60  bool t2_on_disk;
61 
64  int ccmethod;
65 
68 
70  void DefineTasks();
71  void DefineLinearTasks();
72  void DefineQuadraticTasks();
73  long int ncctasks, nqtasks, nltasks;
74 
76  struct CCTaskParams {
77  int mtile, ntile, ktile;
78  };
80 
82  struct CCTask {
84  double flopcount;
85  char *name;
86  };
88 
91 
93  void SCS_MP2();
95 
97  void SCS_CCSD();
99 
103  double et;
104 
106  void mp4_triples();
107  double emp4_t;
108 
109  void WriteBanner();
110  void WriteOptions();
111 
113  virtual void AllocateMemory();
114 
122 
134 
141 
143  void MP2();
144 
146  void MP4_SDQ();
147 
151 
153  void UpdateT1(long int iter);
154  void UpdateT1_mp4(long int iter);
155 
157  void UpdateT2(long int iter);
158  void UpdateT2_mp4(long int iter);
159 
161  double CheckEnergy();
162 
164  void I2ijkl(CCTaskParams params);
166  void Vabcd1(CCTaskParams params);
167  void Vabcd2(CCTaskParams params);
168  void Vabcd(CCTaskParams params);
169  void K(CCTaskParams params);
171 
173  void DIIS(double *c, long int nvec, long int n, int replace_diis_iter);
174  void DIISOldVector(long int iter, int diis_iter, int replace_diis_iter);
175  double DIISErrorVector(int diis_iter, int replace_diis_iter, int iter);
176  void DIISNewAmplitudes(int diis_iter, int &replace_diis_iter);
177  long int maxdiis;
178  double *diisvec;
179 
182 
184  long int memory;
185 
187  long int maxiter;
188 
190  double e_conv;
191 
193  double r_conv;
194 
196  double *eps;
197 
199  double escf;
200 
202  double *integrals, *tempt, *tempv;
203 
205  double *tb, *t1;
206 
208  double *w1, *I1, *I1p;
209 
211  void DefineTilingCPU();
215 };
216 
217 // DF CC class
219  public:
220  DFCoupledCluster(SharedWavefunction ref_wfn, Options &options);
221  ~DFCoupledCluster();
222 
223  double compute_energy();
224 
225  protected:
226  void finalize();
227 
229  PsiReturnType CCSDIterations();
230 
231  void WriteBanner();
232 
234  virtual void AllocateMemory();
235 
237  void UpdateT1();
238 
240  virtual void UpdateT2();
241 
243  virtual void Vabcd1();
244 
246  double *Abij, *Sbij;
247 
249  virtual double CheckEnergy();
250 
253  long int nQ;
254  long int nQ_scf;
255  double *Qov, *Qvv, *Qoo;
256  void ThreeIndexIntegrals();
257 
259  double *Ca_L, *Ca_R, **Ca;
260  double *Fij, *Fab, *Fia, *Fai;
262 
264  virtual void T1Integrals();
266  virtual void T1Fock();
267 
269  virtual void CCResidual();
270 
272  virtual void SCS_MP2();
273 
275  virtual void SCS_CCSD();
276 };
277 
278 // coupled pair class
279 class CoupledPair : public CoupledCluster {
280  public:
281  CoupledPair(std::shared_ptr<psi::Wavefunction> wfn, Options &options);
282  ~CoupledPair();
283 
284  double compute_energy();
285 
286  protected:
289 
291  void finalize();
292 
294  void PairEnergy();
295  double *pair_energy;
296 
298  char *cepa_type;
300 
302  double CheckEnergy();
303 
305  double VariationalEnergy();
306  double evar;
307 
309  void UpdateT1();
310 
312  void UpdateT2();
313 
315  void SCS_CEPA();
316 
318  void OPDM();
319 
321  void WriteBanner();
322 };
323 }
324 }
325 
326 #endif
long int maxelem
Definition: ccsd.h:213
long int ndoccact
basic parameters
Definition: ccsd.h:181
double CheckEnergy()
check energy
Definition: coupled_pair.cc:733
double emp2_ss
Definition: ccsd.h:94
long int ncctasks
Definition: ccsd.h:73
void CPU_t1_vmeai_linear(CCTaskParams params)
Definition: linear.cc:47
long int nfzc
Definition: ccsd.h:181
long int lastov2tile
Definition: ccsd.h:212
void CPU_I2p_abci_refactored_term1_linear(CCTaskParams params)
Definition: linear.cc:157
bool ischolesky_
3-index integrals for density fitting.
Definition: ccsd.h:252
void WriteBanner()
banner
Definition: coupled_pair.cc:102
double eccsd
Definition: ccsd.h:98
Options & options() const
Definition: wavefunction.cc:572
double * Qvv
Definition: ccsd.h:255
double eccsd_ss
Definition: ccsd.h:98
double * Fij
Definition: ccsd.h:260
void I2iabj_linear(CCTaskParams params)
linear diagrams for mp4
Definition: linear.cc:574
void DefineTasks()
define qci/cc/mp tasks
Definition: ccsd.cc:2068
void SCS_CCSD()
SCS-CCSD function and variables.
Definition: ccsd.cc:1953
long int nov2tiles
Definition: ccsd.h:214
CCTask * CCSubTasklist2
Definition: ccsd.h:87
double * I1
Definition: ccsd.h:208
void I2piajk_linear(CCTaskParams params)
Definition: linear.cc:417
SharedMatrix H
Definition: ccsd.h:261
bool mp2_only
which cc method?
Definition: ccsd.h:63
double et
Definition: ccsd.h:103
void DIISNewAmplitudes(int diis_iter, int &replace_diis_iter)
Definition: fnocc/diis.cc:200
long int lasttile
Definition: ccsd.h:213
long int tilesize
Definition: ccsd.h:213
double eccsd_os
Definition: ccsd.h:98
void UpdateT1(long int iter)
Update t1.
Definition: ccsd.cc:1929
CCTask * LTasklist
Definition: ccsd.h:87
double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: ccsd.cc:161
void MP2()
mp2
Definition: fnocc/mp2.cc:60
CCTaskParams * CCParams
Definition: ccsd.h:79
void UpdateT2(long int iter)
Update t2.
Definition: ccsd.cc:1879
double * pair_energy
Definition: ccsd.h:295
long int nvirt_no
Definition: ccsd.h:181
int ccmethod
Definition: ccsd.h:64
~CoupledCluster()
Definition: ccsd.cc:79
double CheckEnergy()
evaluate energy
Definition: ccsd.cc:2027
void I2piajk(CCTaskParams params)
Definition: ccsd.cc:1323
void(psi::fnocc::CoupledCluster::* func)(CCTaskParams)
Definition: ccsd.h:83
PsiReturnType
Definition: psi4-dec.h:46
long int memory
available memory
Definition: ccsd.h:184
Definition: pointgrp.h:104
long int maxiter
maximum number of iterations
Definition: ccsd.h:187
long int nvirt
Definition: ccsd.h:181
bool isccsd
Definition: ccsd.h:63
void CPU_t1_vmeni_linear(CCTaskParams params)
Definition: linear.cc:72
double emp2_os_fac
Definition: ccsd.h:94
long int ovtilesize
Definition: ccsd.h:212
void Vabcd2_linear(CCTaskParams params)
Definition: linear.cc:507
double emp4_t
Definition: ccsd.h:107
double * tempv
Definition: ccsd.h:202
PsiReturnType CEPAIterations()
coupled pair iterations
Definition: coupled_pair.cc:243
CoupledCluster(std::shared_ptr< Wavefunction > reference_wavefunction, Options &options)
Definition: ccsd.cc:73
long int nfzv
Definition: ccsd.h:181
double * t1
Definition: ccsd.h:205
void DefineQuadraticTasks()
Definition: linear.cc:742
double DIISErrorVector(int diis_iter, int replace_diis_iter, int iter)
Definition: fnocc/diis.cc:165
void I2ijkl(CCTaskParams params)
the n^6 cc/qci diagrams
Definition: ccsd.cc:1254
void PairEnergy()
pair energies
Definition: coupled_pair.cc:462
char * cepa_type
what kind of coupled pair method?
Definition: ccsd.h:298
double emp4_q_ss
Definition: ccsd.h:150
void CPU_t1_vmaef(CCTaskParams params)
Definition: ccsd.cc:930
PsiReturnType CCSDIterations()
solve qcisd/ccsd equations
Definition: ccsd.cc:396
void UpdateT2()
update t2 amplitudes
Definition: coupled_pair.cc:497
double * eps
orbital energies
Definition: ccsd.h:196
CoupledPair(std::shared_ptr< psi::Wavefunction > wfn, Options &options)
Definition: coupled_pair.cc:63
int iter
Definition: ccsd.h:53
double * Sbij
Definition: ccsd.h:246
void DIISOldVector(long int iter, int diis_iter, int replace_diis_iter)
Definition: fnocc/diis.cc:128
void UpdateT1_mp4(long int iter)
Definition: linear.cc:198
long int novtiles
Definition: ccsd.h:214
void Vabcd2(CCTaskParams params)
Definition: ccsd.cc:1476
CCTask * QTasklist
Definition: ccsd.h:87
CCTaskParams * QParams
Definition: ccsd.h:79
void DefineLinearTasks()
Definition: linear.cc:717
double emp2_ss_fac
Definition: ccsd.h:94
Definition: ccsd.h:45
long int ntiles
Definition: ccsd.h:214
CCTask * CCTasklist
Definition: ccsd.h:87
double * tb
t1 and t2 buffers
Definition: ccsd.h:205
double emp3_os
components of mp3 and mp4 energies
Definition: ccsd.h:149
PSI_API PsiReturnType lowmemory_triples()
Definition: lowmemory_triples.cc:46
CCTaskParams * LParams
Definition: ccsd.h:79
SharedWavefunction fnocc(SharedWavefunction, Options &)
Definition: fnocc.cc:40
long int ov2tilesize
Definition: ccsd.h:212
void CPU_I1pij_I1ia_lessmem_quadratic(CCTaskParams params)
Definition: quadratic.cc:127
void K(CCTaskParams params)
Definition: ccsd.cc:1556
bool mp4_only
Definition: ccsd.h:63
bool t2_on_disk
is t2 on disk or held in main memory?
Definition: ccsd.h:60
long int maxdiis
Definition: ccsd.h:177
long int lastovtile
Definition: ccsd.h:212
double escf
reference energy
Definition: ccsd.h:199
void OPDM()
compute opdm - only valid for cisd, acpf, aqcc, and cepa(0)
Definition: fnocc/opdm.cc:44
double emp4_q_os
Definition: ccsd.h:150
long int ndocc
Definition: ccsd.h:181
bool isLowMemory
flag for low-memory triples algorithm
Definition: ccsd.h:67
double * w1
buffers for singles residual and a couple of tiny intermediates
Definition: ccsd.h:208
void DefineTilingCPU()
define tiling
Definition: ccsd.cc:658
double VariationalEnergy()
check energy for coupled pair methods that have an energy functional
Definition: coupled_pair.cc:653
double emp4_sd_os
Definition: ccsd.h:149
long int nQ_scf
Definition: ccsd.h:254
Definition: liboptions.h:353
void CPU_I2p_abci_refactored_term2(CCTaskParams params)
Definition: ccsd.cc:1103
~CoupledPair()
Definition: coupled_pair.cc:100
void UpdateT1()
update t1 amplitudes
Definition: coupled_pair.cc:572
void I2ijkl_quadratic(CCTaskParams params)
Definition: quadratic.cc:240
double emp3
Definition: ccsd.h:149
double emp3_ss
Definition: ccsd.h:149
double flopcount
Definition: ccsd.h:84
int nso() const
Returns the number of SOs.
Definition: wavefunction.h:394
double evar
Definition: ccsd.h:306
double eccsd_ss_fac
Definition: ccsd.h:98
CCTaskParams * CCSubParams1
Definition: ccsd.h:79
void CPU_t1_vmaef_linear(CCTaskParams params)
Definition: linear.cc:102
task parameters - not used currently
Definition: ccsd.h:76
void DIIS(double *c, long int nvec, long int n, int replace_diis_iter)
DIIS functions.
Definition: fnocc/diis.cc:44
void Vabcd(CCTaskParams params)
double * Ca_R
Definition: ccsd.h:259
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
std::shared_ptr< Wavefunction > wfn
Definition: dx_write.cc:60
double emp2_os
Definition: ccsd.h:94
void common_init()
Definition: ccsd.cc:84
bool mp3_only
Definition: ccsd.h:63
std::shared_ptr< Wavefunction > reference_wavefunction() const
Returns the reference wavefunction.
Definition: wavefunction.cc:608
void SCS_CEPA()
scs functions
Definition: coupled_pair.cc:615
long int nQ
Definition: ccsd.h:253
double emp4_sd_ss
Definition: ccsd.h:149
double emp4_sd
Definition: ccsd.h:149
void I2iajb_linear(CCTaskParams params)
Definition: linear.cc:629
Simple wavefunction base class.
Definition: wavefunction.h:85
#define PSI_API
Definition: pragma.h:155
void Vabcd1_linear(CCTaskParams params)
Definition: linear.cc:448
double emp2
Definition: ccsd.h:94
void I2iabj_quadratic(CCTaskParams params)
linear diagrams for mp4
Definition: quadratic.cc:293
double * diisvec
Definition: ccsd.h:178
void SCS_MP2()
SCS-MP2 function and variables.
Definition: ccsd.cc:1991
double * integrals
workspace buffers.
Definition: ccsd.h:202
virtual void AllocateMemory()
allocate memory
Definition: ccsd.cc:745
long int nltasks
Definition: ccsd.h:73
void MP4_SDQ()
mp4(sdq)
Definition: ccsd.cc:2127
long int nmotemp
Definition: ccsd.h:181
double * tempt
Definition: ccsd.h:202
long int Position(long int i, long int j)
Definition: fnocc/blas.cc:38
void Vabcd1(CCTaskParams params)
Definition: ccsd.cc:1405
int nmo() const
Returns the number of MOs.
Definition: wavefunction.h:396
PsiReturnType triples()
cc or qci (t)
Definition: fnocc/triples.cc:47
CCTaskParams * CCSubParams2
Definition: ccsd.h:79
CCTask * CCSubTasklist1
Definition: ccsd.h:87
void CPU_I1pij_I1ia_lessmem(CCTaskParams params)
Definition: ccsd.cc:1139
void CPU_I1ab_quadratic(CCTaskParams params)
Definition: quadratic.cc:53
double r_conv
amplitude convergence
Definition: ccsd.h:193
EXTERN struct Params params
Definition: cc/ccdensity/globals.h:55
double * I1p
Definition: ccsd.h:208
void finalize()
Definition: ccsd.cc:153
void I2iajb_quadratic(CCTaskParams params)
Definition: quadratic.cc:405
Definition: ccsd.h:279
double emp4_q
Definition: ccsd.h:150
std::shared_ptr< Wavefunction > SharedWavefunction
Definition: typedefs.h:54
void TwoJminusK(CCTaskParams params)
Definition: ccsd.cc:1691
void CPU_t1_vmeni(CCTaskParams params)
Definition: ccsd.cc:899
void CPU_t1_vmeai(CCTaskParams params)
some cc/qci diagrams
Definition: ccsd.cc:872
double e_conv
energy convergence
Definition: ccsd.h:190
void CPU_I1ab(CCTaskParams params)
Definition: ccsd.cc:985
Definition: ccsd.h:218
double eccsd_os_fac
Definition: ccsd.h:98
void UpdateT2_mp4(long int iter)
Definition: linear.cc:223
cc/qci/mp task
Definition: ccsd.h:82
int cepa_level
Definition: ccsd.h:299
double compute_energy()
Compute energy. Subclasses override this function to compute its energy.
Definition: coupled_pair.cc:139
long int nqtasks
Definition: ccsd.h:73
void finalize()
free memory
Definition: coupled_pair.cc:770
char * name
Definition: ccsd.h:85
void mp4_triples()
mp4 triples
void I2ijkl_linear(CCTaskParams params)
Definition: linear.cc:379
int brueckner_iter
Definition: ccsd.h:54
void WriteOptions()
Definition: ccsd.cc:377
void WriteBanner()
Definition: ccsd.cc:356