- Main Page
- Related Pages
- Classes
- Files

# mbpt.h

    00001 //
    00002 // mbpt.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Ida Nielsen <ibniels@kemi.aau.dk>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _chemistry_qc_mbpt_mbpt_h
    00029 #define _chemistry_qc_mbpt_mbpt_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <util/group/memory.h>
    00036 #include <util/group/message.h>
    00037 #include <util/group/thread.h>
    00038 #include <chemistry/qc/basis/obint.h>
    00039 #include <chemistry/qc/basis/tbint.h>
    00040 #include <chemistry/qc/scf/scf.h>
    00041
    00042 namespace sc {
    00043
    00044 // //////////////////////////////////////////////////////////////////////////
    00045
    00048 class MBPT2: public Wavefunction {
    00049   protected:
    00050 #define ref_to_mp2_acc 100.0
    00051
    00052     Ref<SCF> reference_;
    00053     Ref<MemoryGrp> mem;
    00054     int nfzc, nfzv;
    00055     size_t mem_alloc;
    00056
    00057     double cphf_epsilon_;
    00058     int eliminate_in_gmat_;
    00059     const double *intbuf_;
    00060     Ref<TwoBodyInt> tbint_;
    00061     Ref<TwoBodyInt> *tbints_;
    00062     Ref<TwoBodyDerivInt> *tbintder_;
    00063     int nbasis;
    00064     int noso;
    00065     Ref<MessageGrp> msg_;
    00066     int nvir, nocc, nsocc;
    00067
    00068     Ref<ThreadGrp> thr_;
    00069
    00070     // use a dynamic load balance algorithm if possible if true
    00071     // (will not work if messagegrp not thread safe and
    00072     // memorygrp needs catchup to work)
    00073     int dynamic_;
    00074
    00075     // control how frequently progress is printed
    00076     double print_percent_;
    00077
    00078     // The maximum number of orbitals in a pass.
    00079     int max_norb_;
    00080
    00081     // the irreps of the orbitals and the offset within the irrep
    00082     int *symorb_irrep_;
    00083     int *symorb_num_;
    00084
    00085     char *method_;
    00086     char *algorithm_;
    00087     // if do_d1_ is true, D1(MP2) will be computed even if the gradient is not
    00088     int do_d1_;
    00089     // if do_d2_ is true, D2(MP1) will be computed
    00090     int do_d2_;
    00091
    00092     int nfuncmax;
    00093
    00094     double hf_energy_;
    00095     RefSCVector hf_gradient_;
    00096
    00097     double restart_ecorr_;
    00098     int restart_orbital_v1_;
    00099     int restart_orbital_memgrp_;
    00100
    00101   protected:
    00102     void init_variables();
    00103
    00104     // implement the Compute::compute() function
    00105     void compute();
    00106
    00107     // Fill in the eigenvectors and eigenvalues (Guest & Saunders general
    00108     // form is used for the Fock matrix in the open shell case).
    00109     void eigen(RefDiagSCMatrix &vals, RefSCMatrix &vecs,
    00110                RefDiagSCMatrix &occs);
    00111
    00112     // calculate the opt2 energy using algorithm v1
    00113     void compute_hsos_v1();
    00114
    00115     // calculate the opt2 energy using algorithm v2
    00116     distsize_t compute_v2_memory(int ni,
    00117                              int nfuncmax, int nbfme, int nshell,
    00118                              int ndocc, int nsocc, int nvir, int nproc);
    00119     void compute_hsos_v2();
    00120
    00121     // calculate the opt2 energy using the load balanced version of v2
    00122     void compute_hsos_v2_lb();
    00123
    00124     // calculate the closed shell mp2 energy and gradient
    00125     int compute_cs_batchsize(size_t mem_static, int nocc_act);
    00126     // distsize_t is used to allow memory requirements to be
    00127     // estimated by starting the calculation on a single processor
    00128     distsize_t compute_cs_dynamic_memory(int ni, int nocc_act);
    00129     int make_cs_gmat(RefSymmSCMatrix& Gmat, double *DPmat);
    00130     int make_cs_gmat_new(RefSymmSCMatrix& Gmat, const RefSymmSCMatrix& DPmat);
    00131     void form_max_dens(double *DPmat, signed char *maxp);
    00132     int init_cs_gmat();
    00133     void done_cs_gmat();
    00134     int make_g_d_nor(RefSymmSCMatrix& Gmat,
    00135                      double *DPmat, const double *mgdbuff);
    00136     void cs_cphf(double **scf_vector,
    00137                  double *Laj, double *eigval, RefSCMatrix& P2aj);
    00138     void s2pdm_contrib(const double *intderbuf, double *PHF,
    00139                        double *P2AO, double **hf_ginter, double **ginter);
    00140     void hcore_cs_grad(double *PHF, double *PMP2,
    00141                        double **hf_ginter, double **ginter);
    00142     void overlap_cs_grad(double *WHF, double *WMP2,
    00143                          double **hf_ginter, double **ginter);
    00144     void compute_cs_grad();
    00145   public:
    00146     MBPT2(StateIn&);
    00230     MBPT2(const Ref<KeyVal>&);
    00231     ~MBPT2();
    00232
    00233     void save_data_state(StateOut&);
    00234
    00235     Ref<SCF> ref() { return reference_; }
    00236     double ref_energy();
    00237     double corr_energy();
    00238     RefSCVector ref_energy_gradient();
    00239     RefSCVector corr_energy_gradient();
    00240
    00241     int nelectron();
    00242
    00243     int nfzcore() const { return nfzc; };
    00244     int nfzvirt() const { return nfzv; };
    00245
    00246     RefSymmSCMatrix density();
    00247     int spin_polarized();
    00248
    00249     int gradient_implemented() const;
    00250     int value_implemented() const;
    00251
    00252     void symmetry_changed();
    00253
    00254     // override compute's obsolete so we can call the reference's obsolete
    00255     void obsolete();
    00256
    00257     void print(std::ostream&o=ExEnv::out0()) const;
    00258 };
    00259
    00260 }
    00261
    00262 #endif
    00263
    00264 // Local Variables:
    00265 // mode: c++
    00266 // c-file-style: "CLJ"
    00267 // End: