/usr/include/chemps2/Sobject.h is in libchemps2-dev 1.8.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | /*
CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
Copyright (C) 2013-2018 Sebastian Wouters
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef SOBJECT_CHEMPS2_H
#define SOBJECT_CHEMPS2_H
#include "TensorT.h"
#include "SyBookkeeper.h"
namespace CheMPS2{
/** Sobject class.
\author Sebastian Wouters <sebastianwouters@gmail.com>
\date February 18, 2013
Handles the storage of a spin-coupled two-site object, as is needed for the effective Hamiltonian DMRG equations. Extra functionalities are:
- the formation of an S-object out of two neighbouring TensorT's
- the decomposition into two TensorT's */
class Sobject{
public:
//! Constructor
/** \param index The first index ( S spans index & index + 1 ).
\param denBK Contains the virtual dimensions. Not constant as Sobject is allowed to set the virtual dimensions of symmetry sectors based on the Schmidt spectrum. */
Sobject( const int index, SyBookkeeper * denBK );
//! Destructor
virtual ~Sobject();
//! Get the number of symmetry blocks
/** \return The number of symmetry blocks */
int gNKappa() const;
//! Get the pointer to the storage
/** return pointer to the storage */
double * gStorage();
//! Get the index corresponding to a certain symmetry block
/** \param NL The left particle number sector
\param TwoSL The left spin symmetry sector
\param IL The left irrep sector
\param N1 The first site particle number sector
\param N2 The second site particle number sector
\param TwoJ The recoupled two-site spin symmetry sector
\param NR The right particle number sector
\param TwoSR The right spin symmetry sector
\param IR The right irrep sector
\return The kappa corresponding to the input parameters; -1 means no such block */
int gKappa( const int NL, const int TwoSL, const int IL, const int N1, const int N2, const int TwoJ, const int NR, const int TwoSR, const int IR ) const;
//! Get the storage jump corresponding to a certain symmetry block
/** \param kappa The symmetry block
\return kappa2index[kappa], the memory jumper to a certain block */
int gKappa2index( const int kappa ) const;
//! Get the pointer to the storage of a certain symmetry block
/** \param NL The left particle number sector
\param TwoSL The left spin symmetry sector
\param IL The left irrep sector
\param N1 The first site particle number sector
\param N2 The second site particle number sector
\param TwoJ The recoupled two-site spin symmetry sector
\param NR The right particle number sector
\param TwoSR The right spin symmetry sector
\param IR The right irrep sector
\return Pointer to the requested block; NULL means no such block ( kappa == -1 ) */
double * gStorage( const int NL, const int TwoSL, const int IL, const int N1, const int N2, const int TwoJ, const int NR, const int TwoSR, const int IR );
//! Get the location index
/** \return the index */
int gIndex() const;
//! Join two sites to form a composite S-object.
/** \param Tleft Left TensorT to form the composite S-object
\param Tright Right TensorT to form the composite S-object */
void Join( TensorT * Tleft, TensorT * Tright );
//! SVD an S-object into 2 TensorT's.
/** \param Tleft Left TensorT storage space. At output left normalized.
\param Tright Right TensorT storage space. At output right normalized.
\param virtualdimensionD The virtual dimension which is partitioned over the different symmetry blocks based on the Schmidt spectrum
\param movingright When true, the singular values are multiplied into V^T, when false, into U.
\param change Whether or not the symmetry virtual dimensions are allowed to change (when false: D doesn't matter)
\return the discarded weight if change==true ; else 0.0 */
double Split( TensorT * Tleft, TensorT * Tright, const int virtualdimensionD, const bool movingright, const bool change );
//! Add noise to the current S-object
/** \param NoiseLevel The noise added to the S-object is of size (-0.5 < random number < 0.5) * NoiseLevel / infinity-norm(gStorage()) */
void addNoise( const double NoiseLevel );
//! Convert the storage from diagram convention to symmetric Hamiltonian convention
void prog2symm();
//! Convert the storage from symmetric Hamiltonian convention to diagram convention
void symm2prog();
//! Get the left particle number symmetry of block ikappa
/** \param ikappa The tensor block number
\return the left particle number symmetry of block ikappa */
int gNL( const int ikappa ) const;
//! Get the left spin symmetry of block ikappa
/** \param ikappa The tensor block number
\return the left spin symmetry of block ikappa */
int gTwoSL( const int ikappa ) const;
//! Get the left irrep symmetry of block ikappa
/** \param ikappa The tensor block number
\return the left irrep symmetry of block ikappa */
int gIL( const int ikappa ) const;
//! Get the left local particle number symmetry of block ikappa
/** \param ikappa The tensor block number
\return the left local particle number symmetry of block ikappa */
int gN1( const int ikappa ) const;
//! Get the right local particle number symmetry of block ikappa
/** \param ikappa The tensor block number
\return the right local particle number symmetry of block ikappa */
int gN2( const int ikappa ) const;
//! Get the central spin symmetry of block ikappa
/** \param ikappa The tensor block number
\return the central spin symmetry of block ikappa */
int gTwoJ( const int ikappa ) const;
//! Get the right particle number symmetry of block ikappa
/** \param ikappa The tensor block number
\return the right particle number symmetry of block ikappa */
int gNR( const int ikappa ) const;
//! Get the right spin symmetry of block ikappa
/** \param ikappa The tensor block number
\return the right spin symmetry of block ikappa */
int gTwoSR( const int ikappa ) const;
//! Get the right irrep symmetry of block ikappa
/** \param ikappa The tensor block number
\return the right irrep symmetry of block ikappa */
int gIR( const int ikappa ) const;
//! Get the blocks from large to small: blocksize(reorder[i])>=blocksize(reorder[i+1])
/** \param ikappa The index which counts from large to small
\return The original block index */
int gReorder( const int ikappa ) const;
private:
//! First site index
int index;
//! The local irrep of site index
int Ilocal1;
//! The local irrep of site index+1
int Ilocal2;
//! Pointer to the symmetry BK
SyBookkeeper * denBK;
//! The number of symmetry blocks
int nKappa;
//! Symmetry sector arrays; length nKappa
int * sectorNL;
int * sectorTwoSL;
int * sectorIL;
int * sectorN1;
int * sectorN2;
int * sectorTwoJ;
int * sectorNR;
int * sectorTwoSR;
int * sectorIR;
//! kappa2index[ kappa ] indicates the start of tensor block kappa in storage. kappa2index[ nKappa ] gives the size of storage.
int * kappa2index;
//! The actual variables. Symmetry block kappa begins at storage + kappa2index[ kappa ] and ends at storage + kappa2index[ kappa + 1 ].
double * storage;
//! The array reorder: blocksize( reorder[ i ] ) >= blocksize( reorder[ i + 1 ] ), with blocksize( k ) = kappa2index[ k + 1 ] - kappa2index[ k ]
int * reorder;
};
}
#endif
|