1 /* 2 CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry 3 Copyright (C) 2013-2018 Sebastian Wouters 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along 16 with this program; if not, write to the Free Software Foundation, Inc., 17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef TENSORX_CHEMPS2_H 21 #define TENSORX_CHEMPS2_H 22 23 #include "Tensor.h" 24 #include "TensorL.h" 25 #include "TensorQ.h" 26 #include "TensorOperator.h" 27 #include "TensorF0.h" 28 #include "TensorF1.h" 29 #include "Problem.h" 30 #include "SyBookkeeper.h" 31 32 namespace CheMPS2{ 33 /** TensorX class. 34 \author Sebastian Wouters <sebastianwouters@gmail.com> 35 \date March 6, 2013 36 37 The TensorX class is a storage and manipulation class for completely contracted Hamiltonian terms. */ 38 class TensorX : public TensorOperator{ 39 40 public: 41 42 //! Constructor 43 /** \param boundary_index The boundary index 44 \param moving_right If true: sweep from left to right. If false: sweep from right to left 45 \param denBK The symmetry bookkeeper with symmetry sector virtual dimensions 46 \param Prob The Problem containing the Hamiltonian matrix elements */ 47 TensorX(const int boundary_index, const bool moving_right, const SyBookkeeper * denBK, const Problem * Prob); 48 49 //! Destructor 50 virtual ~TensorX(); 51 52 //! Clear and add the relevant terms to the TensorX 53 /** \param denT TensorT from which the new TensorX should be made 54 \param Ltensors Array with the TensorL's 55 \param Xtensor The previous TensorX 56 \param Qtensor The previous TensorQ 57 \param Atensor The previous A-tensor 58 \param Ctensor The previous C-tensor 59 \param Dtensor The previous D-tensor */ 60 void update(TensorT * denT, TensorL ** Ltensors, TensorX * Xtensor, TensorQ * Qtensor, TensorOperator * Atensor, TensorOperator * Ctensor, TensorOperator * Dtensor); 61 62 //! Clear and add the relevant terms to the TensorX 63 /** \param denT TensorT from which the new TensorX should be made */ 64 void update(TensorT * denT); 65 66 private: 67 68 //Problem containing the matrix elements 69 const Problem * Prob; 70 71 //helper functions 72 void makenewRight(const int ikappa, TensorT * denT); 73 void makenewLeft(const int ikappa, TensorT * denT); 74 void addTermQLRight(const int ikappa, TensorT * denT, TensorL ** Lprev, TensorQ * Qprev, double * workmemRR, double * workmemLR, double * workmemLL); 75 void addTermQLLeft(const int ikappa, TensorT * denT, TensorL ** Lprev, TensorQ * Qprev, double * workmemLL, double * workmemLR, double * workmemRR); 76 void addTermALeft(const int ikappa, TensorT * denT, TensorOperator * Aprev, double * workmemLR, double * workmemLL); 77 void addTermARight(const int ikappa, TensorT * denT, TensorOperator * Aprev, double * workmemRR, double * workmemLR); 78 void addTermCRight(const int ikappa, TensorT * denT, TensorOperator * denC, double * workmemLR); 79 void addTermCLeft(const int ikappa, TensorT * denT, TensorOperator * denC, double * workmemLR); 80 void addTermDRight(const int ikappa, TensorT * denT, TensorOperator * denD, double * workmemLR); 81 void addTermDLeft(const int ikappa, TensorT * denT, TensorOperator * denD, double * workmemLR); 82 83 }; 84 } 85 86 #endif 87