CheMPS2
TensorOperator.h
1 /*
2  CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
3  Copyright (C) 2013-2016 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 TENSOROPERATOR_CHEMPS2_H
21 #define TENSOROPERATOR_CHEMPS2_H
22 
23 #include "Tensor.h"
24 #include "TensorT.h"
25 #include "SyBookkeeper.h"
26 
27 namespace CheMPS2{
42  class TensorOperator : public Tensor{
43 
44  public:
45 
47 
56  TensorOperator( const int boundary_index, const int two_j, const int n_elec, const int n_irrep, const bool moving_right, const bool prime_last, const bool jw_phase, const SyBookkeeper * bk_up, const SyBookkeeper * bk_down );
57 
59  virtual ~TensorOperator();
60 
62 
63  int gNKappa() const;
64 
66 
67  double * gStorage();
68 
70 
77  int gKappa( const int N1, const int TwoS1, const int I1, const int N2, const int TwoS2, const int I2 ) const;
78 
80 
82  int gKappa2index( const int kappa ) const;
83 
85 
92  double * gStorage( const int N1, const int TwoS1, const int I1, const int N2, const int TwoS2, const int I2 );
93 
95 
96  int gIndex() const;
97 
99 
100  int get_2j() const;
101 
103 
104  int get_nelec() const;
105 
107 
108  int get_irrep() const;
109 
111 
115  void update( TensorOperator * previous, TensorT * mps_tensor_up, TensorT * mps_tensor_down, double * workmem );
116 
118 
120  void daxpy( double alpha, TensorOperator * to_add );
121 
123 
125  void daxpy_transpose_tensorCD( const double alpha, TensorOperator * to_add );
126 
128  void clear();
129 
131 
134  double inproduct( TensorOperator * buddy, const char trans ) const;
135 
136  protected:
137 
140 
143 
145  int two_j;
146 
148  int n_elec;
149 
151  int n_irrep;
152 
155 
158 
161 
164 
167 
169 
174  void update_moving_right( const int ikappa, TensorOperator * previous, TensorT * mps_tensor_up, TensorT * mps_tensor_down, double * workmem );
175 
177 
182  void update_moving_left( const int ikappa, TensorOperator * previous, TensorT * mps_tensor_up, TensorT * mps_tensor_down, double * workmem );
183 
186 
188  bool jw_phase;
189 
190  private:
191 
192  };
193 }
194 
195 #endif
void update(TensorOperator *previous, TensorT *mps_tensor_up, TensorT *mps_tensor_down, double *workmem)
Clear and update.
virtual ~TensorOperator()
Destructor.
int * sector_nelec_up
The up particle number sector.
int get_2j() const
Get twice the spin of the tensor operator.
int * sector_spin_down
The down spin symmetry sector (pointer points to sectorTwoS1 if two_j == 0)
Definition: CASPT2.h:42
int get_nelec() const
Get how many electrons there are more in the symmetry sector of the lower leg compared to the upper l...
int gKappa(const int N1, const int TwoS1, const int I1, const int N2, const int TwoS2, const int I2) const
Get the index corresponding to a certain tensor block.
bool prime_last
Convention in which the tensor operator is stored (see class information)
const SyBookkeeper * bk_down
The bookkeeper of the lower MPS.
int gKappa2index(const int kappa) const
Get the storage jump corresponding to a certain tensor block.
double * gStorage()
Get the pointer to the storage.
double inproduct(TensorOperator *buddy, const char trans) const
Make the in-product of two TensorOperator.
void daxpy(double alpha, TensorOperator *to_add)
daxpy for TensorOperator
bool moving_right
Whether or not moving right.
int * sector_spin_up
The up spin symmetry sector.
int n_irrep
The (real-valued abelian) point group irrep difference between the symmetry sectors of the lower and ...
void update_moving_left(const int ikappa, TensorOperator *previous, TensorT *mps_tensor_up, TensorT *mps_tensor_down, double *workmem)
Update moving left.
int * sector_irrep_up
The up spin symmetry sector.
TensorOperator(const int boundary_index, const int two_j, const int n_elec, const int n_irrep, const bool moving_right, const bool prime_last, const bool jw_phase, const SyBookkeeper *bk_up, const SyBookkeeper *bk_down)
Constructor.
void daxpy_transpose_tensorCD(const double alpha, TensorOperator *to_add)
daxpy_transpose for C- and D-tensors (with special spin-dependent factors)
int gNKappa() const
Get the number of symmetry blocks.
const SyBookkeeper * bk_up
The bookkeeper of the upper MPS.
bool jw_phase
Whether or not to include a Jordan-Wigner phase due to the fermion anti-commutation relations...
int get_irrep() const
Get the (real-valued abelian) point group irrep difference between the symmetry sectors of the lower ...
void clear()
Set all storage variables to 0.0.
int gIndex() const
Get the boundary index.
int n_elec
How many electrons there are more in the symmetry sector of the lower leg compared to the upper leg...
int two_j
Twice the spin of the tensor operator.
void update_moving_right(const int ikappa, TensorOperator *previous, TensorT *mps_tensor_up, TensorT *mps_tensor_down, double *workmem)
Update moving right.