Cytnx v0.7.6
Loading...
Searching...
No Matches
DMRG.hpp
Go to the documentation of this file.
1#ifndef _H_DMRG_
2#define _H_DMRG_
3
4#include "cytnx_error.hpp"
5#include "Device.hpp"
7#include "UniTensor.hpp"
8#include <iostream>
9#include <fstream>
10#include "utils/vec_clone.hpp"
11#include "Accessor.hpp"
12#include <vector>
13#include <initializer_list>
14#include <string>
15#include "Scalar.hpp"
16#include "tn_algo/MPS.hpp"
17#include "tn_algo/MPO.hpp"
18
19namespace cytnx{
20 namespace tn_algo{
22 class DMRG_impl: public intrusive_ptr_base<DMRG_impl>{
23 private:
24
25 public:
26
27 MPS mps;
28 MPO mpo;
29
30 //for getting excited states:
31 std::vector<MPS> ortho_mps;
32 double weight;
33
34 //iterative solver param:
35 cytnx_int64 maxit;
36 cytnx_int64 krydim;
37
38 //environ:
39 std::vector<UniTensor> LR;
40 std::vector<std::vector<UniTensor> >hLRs; //excited states
41
42 friend class MPS;
43 friend class MPO;
44
45 void initialize();
46 Scalar sweep(const bool &verbose,const cytnx_int64 &maxit, const cytnx_int64 &krydim);
47 Scalar sweepv2(const bool &verbose,const cytnx_int64 &maxit, const cytnx_int64 &krydim);
48
49 };
51
52
53 // API
54 class DMRG{
55 private:
56
57 public:
58
60 boost::intrusive_ptr<DMRG_impl> _impl;
61 DMRG(MPO mpo, MPS mps, std::vector<MPS> ortho_mps={}, const double &weight=30): _impl(new DMRG_impl()){
62 // currently default init is DMRG_impl;
63
64 // mpo and mps:
65 this->_impl->mpo = mpo;
66 this->_impl->mps = mps;
67
68 // for getting excited states:
69 this->_impl->ortho_mps = ortho_mps;
70 this->_impl->weight = weight;
71
72
73 };
74
75 DMRG(const DMRG &rhs){
76 _impl = rhs._impl;
77 }
79
80 DMRG& operator=(const DMRG &rhs){
81 _impl = rhs._impl;
82 return *this;
83 }
84
85
87 this->_impl->initialize();
88 return *this;
89 }
90
91 // return the current energy
92 Scalar sweep(const bool &verbose=false, const cytnx_int64 &maxit=4000, const cytnx_int64 &krydim=4){
93 return this->_impl->sweep(verbose,maxit,krydim);
94 }
95
96 // return the current energy
97 Scalar sweepv2(const bool &verbose=false, const cytnx_int64 &maxit=4000, const cytnx_int64 &krydim=4){
98 return this->_impl->sweepv2(verbose,maxit,krydim);
99 }
100
101 };
102
103
104
105
106
107
108 }
109}
110
111#endif
112
Definition Scalar.hpp:1751
Definition DMRG.hpp:54
Scalar sweepv2(const bool &verbose=false, const cytnx_int64 &maxit=4000, const cytnx_int64 &krydim=4)
Definition DMRG.hpp:97
DMRG & initialize()
Definition DMRG.hpp:86
DMRG & operator=(const DMRG &rhs)
Definition DMRG.hpp:80
Scalar sweep(const bool &verbose=false, const cytnx_int64 &maxit=4000, const cytnx_int64 &krydim=4)
Definition DMRG.hpp:92
Definition MPO.hpp:54
Definition MPS.hpp:170
Definition Accessor.hpp:12
int64_t cytnx_int64
Definition Type.hpp:25