1 // 2 // BAGEL - Brilliantly Advanced General Electronic Structure Library 3 // Filename: smith.h 4 // Copyright (C) 2013 Toru Shiozaki 5 // 6 // Author: Matthew K. MacLeod <matthew.macleod@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 26 #ifndef __SRC_SMITH_SMITH_H 27 #define __SRC_SMITH_SMITH_H 28 29 #include <bagel_config.h> 30 #ifdef COMPILE_SMITH 31 #include <src/smith/spinfreebase.h> 32 #endif 33 #include <stddef.h> 34 #include <map> 35 #include <memory> 36 #include <src/wfn/method.h> 37 #include <src/wfn/reference.h> 38 #include <src/smith/tensor.h> 39 #include <src/grad/nacmtype.h> 40 41 namespace bagel { 42 43 class Smith : public Method { 44 public: 45 using Tensor = SMITH::Tensor_<double>; 46 47 protected: 48 #ifdef COMPILE_SMITH 49 std::shared_ptr<SMITH::SpinFreeMethod<double>> algo_; 50 #endif 51 52 // correlated density matrices 53 // second order density matrix 54 std::shared_ptr<const Matrix> dm1_; 55 // first order density matrices 56 std::shared_ptr<const Matrix> dm11_; 57 std::shared_ptr<const Tensor> dm2_; 58 // XMS density matrix 59 std::shared_ptr<const Matrix> dcheck_; 60 // second order spin density matrix 61 std::shared_ptr<const Matrix> sdm1_; 62 // first order spin density matrix 63 std::shared_ptr<const Matrix> sdm11_; 64 // norm of the first-order wave function <1|1> 65 std::vector<double> wf1norm_; 66 // ci derivative 67 std::shared_ptr<const Dvec> cider_; 68 // rotation matrix in MS-CASPT2 69 std::shared_ptr<const Matrix> msrot_; 70 std::shared_ptr<const Matrix> vd1_; 71 72 std::shared_ptr<const Matrix> coeff_; 73 74 public: 75 Smith(std::shared_ptr<const PTree>, std::shared_ptr<const Geometry>, std::shared_ptr<const Reference>); 76 77 void compute() override; 78 // Gradient module to be separated 79 void compute_gradient(const int istate, const int jstate, std::shared_ptr<const NacmType> nacmtype = std::make_shared<const NacmType>("interstate"), const bool nocider = false); 80 81 // just return the reference used in SMITH code conv_to_ref()82 std::shared_ptr<const Reference> conv_to_ref() const override { return ref_; } 83 dm1()84 std::shared_ptr<const Matrix> dm1() const { return dm1_; } dm11()85 std::shared_ptr<const Matrix> dm11() const { return dm11_; } dm2()86 std::shared_ptr<const Tensor> dm2() const { return dm2_; } dcheck()87 std::shared_ptr<const Matrix> dcheck() const { return dcheck_; } sdm1()88 std::shared_ptr<const Matrix> sdm1() const { return sdm1_; } sdm11()89 std::shared_ptr<const Matrix> sdm11() const { return sdm11_; } wf1norm()90 std::vector<double> wf1norm() const { return wf1norm_; } cideriv()91 std::shared_ptr<const Dvec> cideriv() const { return cider_; } msrot()92 std::shared_ptr<const Matrix> msrot() const { return msrot_; } vd1()93 std::shared_ptr<const Matrix> vd1() const { return vd1_; } 94 coeff()95 std::shared_ptr<const Matrix> coeff() const { return coeff_; } 96 97 #ifdef COMPILE_SMITH algo()98 std::shared_ptr<const SMITH::SpinFreeMethod<double>> algo() const { return algo_; } 99 #endif 100 101 }; 102 103 104 class RelSmith : public Method { 105 protected: 106 #ifdef COMPILE_SMITH 107 std::shared_ptr<SMITH::SpinFreeMethod<std::complex<double>>> algo_; 108 #endif 109 std::shared_ptr<const ZMatrix> coeff_; 110 111 public: 112 RelSmith(std::shared_ptr<const PTree>, std::shared_ptr<const Geometry>, std::shared_ptr<const Reference>); 113 compute()114 void compute() override { 115 #ifdef COMPILE_SMITH 116 algo_->solve(); 117 #endif 118 } 119 conv_to_ref()120 std::shared_ptr<const Reference> conv_to_ref() const override { return std::shared_ptr<const Reference>(); } coeff()121 std::shared_ptr<const ZMatrix> coeff() const { return coeff_; } 122 123 #ifdef COMPILE_SMITH algo()124 std::shared_ptr<const SMITH::SpinFreeMethod<std::complex<double>>> algo() const { return algo_; } 125 #endif 126 }; 127 128 } 129 #endif 130