v2DM-DOCI  1.0
doci2DM::TPM Class Reference

#include <TPM.h>

+ Inheritance diagram for doci2DM::TPM:
+ Collaboration diagram for doci2DM::TPM:

Public Member Functions

 TPM (int L, int N)
 
 TPM (const TPM &)=default
 
 TPM (TPM &&)=default
 
virtual ~TPM ()=default
 
TPMoperator= (const TPM &)=default
 
TPMoperator= (TPM &&)=default
 
double operator() (int a, int b, int c, int d) const
 
int gN () const
 
int gL () const
 
int gn () const
 
void HF_molecule (std::string filename)
 
void ham (std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V)
 
void WriteToFile (hid_t &group_id) const
 
void WriteToFile (std::string filename) const
 
void ReadFromFile (std::string filename)
 
void ReadFromFile (hid_t &group_id)
 
double S_2 () const
 
void unit ()
 
void init (const Lineq &)
 
void Proj_Tr ()
 
void collaps (const SUP &, const Lineq &)
 
void constr_grad (double t, const SUP &, const TPM &, const Lineq &)
 
void Q (const TPM &)
 
void Q (double a, double b, double c, const TPM &, bool=false)
 
int solve (double t, const SUP &, TPM &, const Lineq &)
 
void H (double t, const TPM &, const SUP &, const Lineq &)
 
double line_search (double t, SUP &, const TPM &) const
 
double line_search (double t, const TPM &, const TPM &) const
 
void ReadFromFileFull (std::string filename)
 
void Proj_E (const Lineq &, int option=0)
 
std::vector< TPMDOCI_constrains () const
 
std::vector< TPMsinglet_constrains () const
 
void S (const TPM &)
 
int InverseS (TPM &, const Lineq &)
 
double getDiag (int, int) const
 
void G (const PHM &)
 
void pairing (double)
 
void rotate_doci (int, int, double)
 
double calc_rotate_doci (const TPM &, int, int, double) const
 
double calc_rotate_slow_doci (const TPM &, int, int, double) const
 
std::pair< double, bool > find_min_angle_doci (const TPM &, int, int, double=0) const
 
double calc_rotate (int k, int l, double theta, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
 
double calc_rotate_slow (int k, int l, double theta, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
 
std::pair< double, bool > find_min_angle (int k, int l, double start_angle, std::function< double(int, int)> &T, std::function< double(int, int, int, int)> &V) const
 
void rotate (int, int, double, std::function< double(int, int)> &, std::function< double(int, int, int, int)> &)
 
void WriteFullToFile (std::string filename) const
 
void WriteFullToFile (hid_t &group) const
 
void setMatrixDim (int, int, int)
 
void setVectorDim (int, int, int)
 
Containeroperator+= (const Container &)
 
Containeroperator-= (const Container &)
 
Containerdaxpy (double alpha, const Container &)
 
Containeroperator*= (double)
 
Containeroperator/= (double)
 
Containermprod (const Container &, const Container &)
 
double & operator() (int block, int i, int j)
 
double operator() (int block, int i, int j) const
 
double & operator() (int block, int i)
 
double operator() (int block, int i) const
 
MatrixgetMatrix (int)
 
const MatrixgetMatrix (int) const
 
VectorgetVector (int)
 
const VectorgetVector (int) const
 
BlockMatrixgetMatrices ()
 
const BlockMatrixgetMatrices () const
 
BlockVectorgetVectors ()
 
const BlockVectorgetVectors () const
 
int gnr () const
 
int gnMatrix () const
 
int gnVector () const
 
int gdimMatrix (int) const
 
int gdimVector (int) const
 
int gdegMatrix (int) const
 
int gdegVector (int) const
 
double trace () const
 
double ddot (const Container &) const
 
void invert ()
 
void dscal (double)
 
void fill_Random ()
 
void fill_Random (int)
 
void sqrt (int)
 
void L_map (const Container &, const Container &)
 
void symmetrize ()
 
void sep_pm (Container &, Container &)
 

Static Public Member Functions

static TPM CreateFromFile (std::string filename)
 

Private Member Functions

void constr_lists (int L)
 

Private Attributes

int N
 number of particles More...
 
int L
 the size of the sp DOCI space (there are 2*L sp states) More...
 
int n
 dimension of the full TPM More...
 

Static Private Attributes

static std::unique_ptr< helpers::tmatrix< unsigned int > > s2t = nullptr
 table translating single particles indices to two particle indices More...
 
static std::unique_ptr< helpers::tmatrix< unsigned int > > t2s = nullptr
 table translating two particles indices to single particle indices More...
 

Friends

std::ostream & operator<< (std::ostream &output, doci2DM::TPM &tpm)
 

Detailed Description

Definition at line 43 of file TPM.h.

Constructor & Destructor Documentation

TPM::TPM ( int  L,
int  N 
)

Create a object in the Two Particle space

Parameters
Lthe number of levels (the sp space has size of 2*L)
Nthe number of particles

Definition at line 46 of file TPM.cpp.

+ Here is the call graph for this function:

doci2DM::TPM::TPM ( const TPM )
default
doci2DM::TPM::TPM ( TPM &&  )
default
virtual doci2DM::TPM::~TPM ( )
virtualdefault

Member Function Documentation

double TPM::calc_rotate ( int  k,
int  l,
double  theta,
std::function< double(int, int)> &  T,
std::function< double(int, int, int, int)> &  V 
) const

Calculate the energy change when you rotate orbital k and l over an angle of theta with the rotation in the full space of the orbitals.

Parameters
kthe first orbital
lthe second orbital
thetathe angle to rotate over
Tfunction that returns the one-particle matrix elements
Vfunction that returns the two-particle matrix elements
Returns
the new energy

Definition at line 1431 of file TPM.cpp.

double TPM::calc_rotate_doci ( const TPM ham,
int  k,
int  l,
double  theta 
) const

Calculate the energy change when you rotate orbital k and l over an angle of theta in the DOCI space.

Parameters
hamthe hamiltonian to use
kthe first orbital
lthe second orbital
thetathe angle to rotate over
Returns
the new energy

Definition at line 1223 of file TPM.cpp.

+ Here is the call graph for this function:

double TPM::calc_rotate_slow ( int  k,
int  l,
double  theta,
std::function< double(int, int)> &  T,
std::function< double(int, int, int, int)> &  V 
) const

The slow version of TPM::calc_rotate()

Parameters
kthe first orbital
lthe second orbital
thetathe angle to rotate over
Tfunction that returns the one-particle matrix elements
Vfunction that returns the two-particle matrix elements
Returns
the new energy

Definition at line 1383 of file TPM.cpp.

+ Here is the call graph for this function:

double TPM::calc_rotate_slow_doci ( const TPM ham,
int  k,
int  l,
double  theta 
) const

The slow version of TPM::calc_rotate_doci()

Parameters
hamthe hamiltonian to use
kthe first orbital
lthe second orbital
thetathe angle to rotate over
Returns
the new energy

Definition at line 1265 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::collaps ( const SUP S,
const Lineq lineq 
)

Collaps the full SUP to the TPM space: *this = S.I + Q(S.Q) + G^Down(S.G) + ... stores the result in *this

Parameters
SThe SUP to collaps
lineqthe linear inequalities to use

Definition at line 568 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::constr_grad ( double  t,
const SUP S,
const TPM ham,
const Lineq lineq 
)

Construct the -gradient, store in *this

Parameters
tthe barrier height
Sthe SUP to use
hamthe hamiltonian
lineqthe linear inequalities to use

Definition at line 595 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::constr_lists ( int  L)
private

Definition at line 61 of file TPM.cpp.

+ Here is the caller graph for this function:

TPM TPM::CreateFromFile ( std::string  filename)
static

Create a TPM object from a file. You don't need to know L or N for this. You cannot read a file with different dimensions and the already created TPM's.

Parameters
filenamethe file to use
Returns
a new TPM object with the contents of filename

Definition at line 1825 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Container & Container::daxpy ( double  alpha,
const Container orig 
)
inherited

Definition at line 116 of file Container.cpp.

+ Here is the caller graph for this function:

double Container::ddot ( const Container A) const
inherited

Definition at line 255 of file Container.cpp.

+ Here is the caller graph for this function:

std::vector< TPM > TPM::DOCI_constrains ( ) const

Created a vector with all necessary DOCI consistency constrains.

Returns
a vector of all constrains

Definition at line 872 of file TPM.cpp.

+ Here is the caller graph for this function:

void Container::dscal ( double  a)
inherited

Definition at line 266 of file Container.cpp.

+ Here is the caller graph for this function:

void Container::fill_Random ( )
inherited

Definition at line 272 of file Container.cpp.

void Container::fill_Random ( int  seed)
inherited

Definition at line 278 of file Container.cpp.

std::pair< double, bool > TPM::find_min_angle ( int  k,
int  l,
double  start_angle,
std::function< double(int, int)> &  T,
std::function< double(int, int, int, int)> &  V 
) const

Find the minimum with Newton-Raphson for the angle of a jacobi rotation between orbitals k and l in the DOCI space.

Parameters
kthe first orbital
lthe second orbital
start_anglethe starting point for the Newton-Raphson (defaults to zero)
Tfunction that returns the one-particle matrix elements
Vfunction that returns the two-particle matrix elements
Returns
pair of the angle with the lowest energy and boolean, true => minimum, false => maximum

Definition at line 1577 of file TPM.cpp.

+ Here is the caller graph for this function:

std::pair< double, bool > TPM::find_min_angle_doci ( const TPM ham,
int  k,
int  l,
double  start_angle = 0 
) const

Find the minimum with Newton-Raphson for the angle of a jacobi rotation between orbitals k and l in the DOCI space.

Parameters
hamthe hamiltonian to use
kthe first orbital
lthe second orbital
start_anglethe starting point for the Newton-Raphson (defaults to zero)
Returns
pair of the angle with the lowest energy and boolean, true => minimum, false => maximum

Definition at line 1317 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::G ( const PHM phm)

The down image of the DOCI-G image. Fills the current object with the G down image of phm

Parameters
phmthe G matrix to use

Definition at line 1030 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int Container::gdegMatrix ( int  i) const
inherited

Definition at line 240 of file Container.cpp.

+ Here is the caller graph for this function:

int Container::gdegVector ( int  i) const
inherited

Definition at line 245 of file Container.cpp.

+ Here is the caller graph for this function:

int Container::gdimMatrix ( int  i) const
inherited

Definition at line 230 of file Container.cpp.

+ Here is the caller graph for this function:

int Container::gdimVector ( int  i) const
inherited

Definition at line 235 of file Container.cpp.

+ Here is the caller graph for this function:

double TPM::getDiag ( int  a,
int  b 
) const

Get an element from the diag vector part. Warning: no check on a!=b.

Parameters
afirst sp index
bsecond sp index
Returns
the element a b ; a b

Definition at line 905 of file TPM.cpp.

+ Here is the caller graph for this function:

BlockMatrix & Container::getMatrices ( )
inherited

Definition at line 195 of file Container.cpp.

const BlockMatrix & Container::getMatrices ( ) const
inherited

Definition at line 200 of file Container.cpp.

Matrix & Container::getMatrix ( int  i)
inherited

Definition at line 174 of file Container.cpp.

+ Here is the caller graph for this function:

const Matrix & Container::getMatrix ( int  i) const
inherited

Definition at line 179 of file Container.cpp.

Vector & Container::getVector ( int  i)
inherited

Definition at line 184 of file Container.cpp.

+ Here is the caller graph for this function:

const Vector & Container::getVector ( int  i) const
inherited

Definition at line 189 of file Container.cpp.

BlockVector & Container::getVectors ( )
inherited

Definition at line 205 of file Container.cpp.

const BlockVector & Container::getVectors ( ) const
inherited

Definition at line 210 of file Container.cpp.

int TPM::gL ( ) const

Definition at line 115 of file TPM.cpp.

+ Here is the caller graph for this function:

int TPM::gN ( ) const

Definition at line 110 of file TPM.cpp.

+ Here is the caller graph for this function:

int TPM::gn ( ) const

Definition at line 120 of file TPM.cpp.

int Container::gnMatrix ( ) const
inherited

Definition at line 220 of file Container.cpp.

+ Here is the caller graph for this function:

int Container::gnr ( ) const
inherited

Definition at line 215 of file Container.cpp.

int Container::gnVector ( ) const
inherited

Definition at line 225 of file Container.cpp.

+ Here is the caller graph for this function:

void TPM::H ( double  t,
const TPM delta,
const SUP S,
const Lineq lineq 
)

Calculate the hessian

Parameters
tbarrier height
deltathe current delta in the TPM space
Sthe full filled SUP object
lineqthe linear inequalities to use

Definition at line 725 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::ham ( std::function< double(int, int)> &  T,
std::function< double(int, int, int, int)> &  V 
)

Build the reduced hamiltonian using 2 function objects: one for the one particles integrals, one for the two particle integrals. The functions should accept the spatial orbitals as argument.

Parameters
Ta function that accepts 2 orbitals a and b and returns the <a|T|b> matrix element
Va function that accepts 4 orbitals a, b, c and d and returns the <ab|V|cd> matrix element

Definition at line 183 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::HF_molecule ( std::string  filename)

Definition at line 243 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::init ( const Lineq lineq)

Construct a TPM that is OK with the constrains

Parameters
lineqthe constrains used in the optimalization

Definition at line 538 of file TPM.cpp.

+ Here is the call graph for this function:

int TPM::InverseS ( TPM b,
const Lineq lineq 
)

Calculate the inverse Overlap matrix S^-1 a = b by solving S b = a with conjugate gradient. Store the result in *this.

Parameters
bthe input matrix
lineqthe constrains to use
Returns
the number of iterations

Definition at line 981 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Container::invert ( )
inherited

Definition at line 260 of file Container.cpp.

void Container::L_map ( const Container A,
const Container B 
)
inherited

Definition at line 291 of file Container.cpp.

+ Here is the caller graph for this function:

double TPM::line_search ( double  t,
SUP S,
const TPM ham 
) const

Definition at line 767 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double TPM::line_search ( double  t,
const TPM rdm,
const TPM ham 
) const

line search for interpolation

Parameters
tbarriere hight
rdmcurrent rdm
hamthe hamiltonian
Returns
the step size

Definition at line 1073 of file TPM.cpp.

+ Here is the call graph for this function:

Container & Container::mprod ( const Container A,
const Container B 
)
inherited

General matrix matrix product of A and B. Stores result in *this.

Parameters
Amatrix A
Bmatrix B
Returns
A*B (in *this)

Definition at line 146 of file Container.cpp.

double TPM::operator() ( int  a,
int  b,
int  c,
int  d 
) const

General access operator to the rdm. Returns 0 if the sp indices are not in DOCI space

Parameters
afirst sp index
bsecond sp index
cthirth sp index
dfourth sp index
Returns
the value of the rdm with sp index a,b|c,d

Definition at line 134 of file TPM.cpp.

+ Here is the call graph for this function:

double & Container::operator() ( int  block,
int  i,
int  j 
)
inherited

Definition at line 154 of file Container.cpp.

double Container::operator() ( int  block,
int  i,
int  j 
) const
inherited

Definition at line 159 of file Container.cpp.

double & Container::operator() ( int  block,
int  i 
)
inherited

Definition at line 164 of file Container.cpp.

double Container::operator() ( int  block,
int  i 
) const
inherited

Definition at line 169 of file Container.cpp.

Container & Container::operator*= ( double  a)
inherited

Definition at line 124 of file Container.cpp.

Container & Container::operator+= ( const Container orig)
inherited

Definition at line 99 of file Container.cpp.

Container & Container::operator-= ( const Container orig)
inherited

Definition at line 108 of file Container.cpp.

Container & Container::operator/= ( double  a)
inherited

Definition at line 132 of file Container.cpp.

TPM& doci2DM::TPM::operator= ( const TPM )
default
TPM& doci2DM::TPM::operator= ( TPM &&  )
default
void TPM::pairing ( double  g)

Build pairing hamiltonian

Parameters
gthe pairing strength

Definition at line 1087 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::Proj_E ( const Lineq lineq,
int  option = 0 
)

Definition at line 852 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::Proj_Tr ( )

Definition at line 546 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::Q ( const TPM tpm)

The Q image: stores the result in *this

Parameters
tpmThe input matrix

Definition at line 610 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::Q ( double  a,
double  b,
double  c,
const TPM tpm,
bool  inverse = false 
)

Definition at line 635 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::ReadFromFile ( std::string  filename)

Read a TPM from a HDF5 file. The TPM object must have the correct dimension. It will fill the object on which this method is called.

Parameters
filenamethe file to read

Definition at line 442 of file TPM.cpp.

+ Here is the caller graph for this function:

void TPM::ReadFromFile ( hid_t &  group_id)

Read a TPM from a HDF5 group. The TPM object must have the correct dimension. It will fill the object on which this method is called.

Parameters
group_idreference to the HDF5 group to use

Definition at line 468 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::ReadFromFileFull ( std::string  filename)

Reads a rdm from a HDF5 file stored as a full RDM: no split up between a LxL block and a vector. This method will read the full rdm and only keep the LxL block and the vector

Parameters
filenamethe file to read

Definition at line 817 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::rotate ( int  k,
int  l,
double  angle,
std::function< double(int, int)> &  T,
std::function< double(int, int, int, int)> &  V 
)

Rotate this TPM object with a jacobi rotation between orbitals k and l over angle in the full space.

Parameters
kthe first orbital
lthe second orbital
anglethe angle to rotate over
Tfunction that returns the one-particle matrix elements
Vfunction that returns the two-particle matrix elements

Definition at line 1684 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::rotate_doci ( int  k,
int  l,
double  angle 
)

Rotate this TPM object with a jacobi rotation between orbitals k and l over an angle of angle in the DOCI space

Parameters
kthe first orbital
lthe second orbital
anglethe angle to rotate over

Definition at line 1163 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::S ( const TPM tpm_d)

( Overlapmatrix of the U-basis ) - map, maps a TPM onto a different TPM, this map is actually a Q-like map for which the paramaters a,b and c are calculated in primal_dual.pdf. Since it is a Q-like map the inverse can be taken as well.

Parameters
tpm_dthe input TPM

Definition at line 922 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double TPM::S_2 ( ) const
Todo:
Optimize to DOCI form
Returns
S^2 expectation value

Definition at line 497 of file TPM.cpp.

void Container::sep_pm ( Container pos,
Container neg 
)
inherited

Definition at line 302 of file Container.cpp.

void Container::setMatrixDim ( int  block,
int  dim,
int  degen 
)
inherited

Set dimension and degeneracy for a Matrix

Parameters
blockwhich matrix
dimthe dimensions
degenthe degeneracy of the matrix

Definition at line 59 of file Container.cpp.

+ Here is the caller graph for this function:

void Container::setVectorDim ( int  block,
int  dim,
int  degen 
)
inherited

Set dimension and degeneracy for a Vector

Parameters
blockwhich vector
dimthe dimensions
degenthe degeneracy of the vector

Definition at line 70 of file Container.cpp.

+ Here is the caller graph for this function:

std::vector<TPM> doci2DM::TPM::singlet_constrains ( ) const
int TPM::solve ( double  t,
const SUP S,
TPM grad,
const Lineq lineq 
)

Definition at line 666 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Container::sqrt ( int  option)
inherited

Definition at line 285 of file Container.cpp.

void Container::symmetrize ( )
inherited

Definition at line 297 of file Container.cpp.

double Container::trace ( ) const
inherited

Definition at line 250 of file Container.cpp.

+ Here is the caller graph for this function:

void TPM::unit ( )

Set this object to the unit matrix

Definition at line 523 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::WriteFullToFile ( std::string  filename) const

Definition at line 1741 of file TPM.cpp.

void TPM::WriteFullToFile ( hid_t &  group) const

Definition at line 1759 of file TPM.cpp.

+ Here is the call graph for this function:

void TPM::WriteToFile ( hid_t &  group_id) const

Write a TPM object to a HDF5 group.

Parameters
group_idreference to the HDF5 group to use

Definition at line 304 of file TPM.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TPM::WriteToFile ( std::string  filename) const

Write a TPM object to a HDF5 file

Parameters
filenamethe filename to use

Definition at line 418 of file TPM.cpp.

+ Here is the call graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
doci2DM::TPM tpm 
)
friend

Definition at line 159 of file TPM.cpp.

Member Data Documentation

int doci2DM::TPM::L
private

the size of the sp DOCI space (there are 2*L sp states)

Definition at line 157 of file TPM.h.

int doci2DM::TPM::N
private

number of particles

Definition at line 154 of file TPM.h.

int doci2DM::TPM::n
private

dimension of the full TPM

Definition at line 160 of file TPM.h.

std::unique_ptr< helpers::tmatrix< unsigned int > > TPM::s2t = nullptr
staticprivate

table translating single particles indices to two particle indices

Definition at line 163 of file TPM.h.

std::unique_ptr< helpers::tmatrix< unsigned int > > TPM::t2s = nullptr
staticprivate

table translating two particles indices to single particle indices

Definition at line 166 of file TPM.h.


The documentation for this class was generated from the following files: