1 //
2 // BAGEL - Brilliantly Advanced General Electronic Structure Library
3 // Filename: fci.h
4 // Copyright (C) 2011 Toru Shiozaki
5 //
6 // Author: Toru Shiozaki <shiozaki@northwestern.edu>
7 // Maintainer: Shiozaki group
8 //
9 // This file is part of the BAGEL package.
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 //
24 
25 // Desc :: The implementation closely follows Knowles and Handy 1984 CPL.
26 //         It is amazing how easy it is to implement FCI !!
27 //
28 
29 #ifndef __BAGEL_FCI_KNOWLESHANDY_H
30 #define __BAGEL_FCI_KNOWLESHANDY_H
31 
32 #include <src/ci/fci/fci.h>
33 
34 namespace bagel {
35 
36 class KnowlesHandy : public FCI {
37 
38   protected:
39     // denominator
40     void const_denom() override;
41 
42     // virtual application of Hamiltonian
43     std::shared_ptr<Dvec> form_sigma(std::shared_ptr<const Dvec> c, std::shared_ptr<const MOFile> jop, const std::vector<int>& conv) const override;
44 
45     // run-time functions
46     void sigma_1(std::shared_ptr<const Civec> cc, std::shared_ptr<Civec> sigma, std::shared_ptr<const MOFile> jop) const;
47     void sigma_3(std::shared_ptr<const Civec> cc, std::shared_ptr<Civec> sigma, std::shared_ptr<const MOFile> jop) const;
48     void sigma_2b (std::shared_ptr<Dvec> d, std::shared_ptr<Dvec> e, std::shared_ptr<const MOFile> jop) const;
49     void sigma_2c1(std::shared_ptr<Civec> sigma, std::shared_ptr<const Dvec> e) const;
50     void sigma_2c2(std::shared_ptr<Civec> sigma, std::shared_ptr<const Dvec> e) const;
51 
52   private:
53     friend class boost::serialization::access;
54     template<class Archive>
serialize(Archive & ar,const unsigned int version)55     void serialize(Archive& ar, const unsigned int version) {
56       boost::serialization::split_member(ar, *this, version);
57     }
58     template<class Archive>
save(Archive & ar,const unsigned int)59     void save(Archive& ar, const unsigned int) const {
60       ar << boost::serialization::base_object<FCI>(*this);
61       std::shared_ptr<const Matrix> coeff = jop_->coeff();
62       ar << coeff;
63     }
64     template<class Archive>
load(Archive & ar,const unsigned int)65     void load(Archive& ar, const unsigned int) {
66       ar >> boost::serialization::base_object<FCI>(*this);
67       std::shared_ptr<const Matrix> coeff;
68       ar >> coeff;
69       update(coeff);
70     }
71 
72   public:
KnowlesHandy()73     KnowlesHandy() { }
74 
75     KnowlesHandy(std::shared_ptr<const PTree> a, std::shared_ptr<const Geometry> g, std::shared_ptr<const Reference> b,
76         const int ncore = -1, const int nocc = -1, const int nstate = -1, const bool store = false);
77 
78     KnowlesHandy(std::shared_ptr<const CIWfn> ci, std::shared_ptr<const Reference> r);
79 
80     void update(std::shared_ptr<const Matrix>) override;
81 };
82 
83 }
84 
85 #include <src/util/archive.h>
86 BOOST_CLASS_EXPORT_KEY(bagel::KnowlesHandy)
87 
88 #endif
89 
90