4 "DMRG executable for the Spin-1/2 J1-J2 XY Model on a two-dimensional square lattice.\n";
6 #include "DMRGBlock.hpp" 7 #include "Hamiltonians.hpp" 8 #include "DMRGBlockContainer.hpp" 12 PetscErrorCode Correlators(
DMRG_t& DMRG);
15 int main(
int argc,
char **argv)
18 PetscMPIInt nprocs, rank;
19 ierr = SlepcInitialize(&argc, &argv, (
char*)0, help); CHKERRQ(ierr);
20 ierr = MPI_Comm_size(PETSC_COMM_WORLD, &nprocs); CHKERRQ(ierr);
21 ierr = MPI_Comm_rank(PETSC_COMM_WORLD, &rank); CHKERRQ(ierr);
23 DMRG_t DMRG(PETSC_COMM_WORLD);
24 ierr = DMRG.Initialize(); CHKERRQ(ierr);
27 ierr = Correlators(DMRG); CHKERRQ(ierr);
30 ierr = DMRG.Warmup(); CHKERRQ(ierr);
31 ierr = DMRG.Sweeps(); CHKERRQ(ierr);
33 ierr = DMRG.Destroy(); CHKERRQ(ierr);
35 ierr = SlepcFinalize(); CHKERRQ(ierr);
40 PetscErrorCode Correlators(
DMRG_t& DMRG)
46 PetscInt NumSitesSys = Lx*Ly/2;
49 for(PetscInt idx=0; idx < NumSitesSys; ++idx)
51 std::vector< Op > OpList;
52 OpList.push_back({
OpSz,idx});
58 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
60 std::string name =
"Magnetization(" + std::to_string(idx) +
")";
67 const std::vector< std::vector < PetscInt > > nnp = DMRG.
HamiltonianRef().NeighborPairs();
68 for(
const std::vector< PetscInt > pair : nnp)
70 if(pair.size()!=2) SETERRQ1(PETSC_COMM_WORLD,1,
"Invalid 2-point correlator. Got %lu operators instead.", pair.size());
72 for (
const std::vector< Op_t >& OpTypes : OpTypesList)
74 std::vector< Op > OpList;
75 std::string desc =
"< ";
76 std::string name = std::string(
"NearestNeighbor") +
OpToStr(OpTypes[0]) +
OpToStr(OpTypes[1]) +
"( ";
77 for(PetscInt i=0; i < 2; ++i)
79 const PetscInt idx = pair.at(i);
80 const Op_t OpType = OpTypes.at(i);
81 OpList.push_back({OpType,idx});
84 desc +=
OpToStr(OpType) +
"_{" + std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
85 name += std::to_string(idx) +
" ";
96 std::vector< Op > OpList;
99 for(PetscInt i = 0; i < Lx; ++i){
100 const PetscInt ix = i;
101 const PetscInt jy = 1;
103 OpList.push_back({
OpSz,idx});
104 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
107 ierr = DMRG.
SetUpCorrelation(OpList,
"MagnetizationRowX1", desc); CHKERRQ(ierr);
113 std::vector< Op > OpList;
116 for(PetscInt j = 0; j < Ly; ++j){
117 const PetscInt ix = 1;
118 const PetscInt jy = j;
120 OpList.push_back({
OpSz,idx});
121 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
130 std::vector< Op > OpList;
133 for(PetscInt j = 0; j < Ly; ++j){
134 const PetscInt ix = Lx-2;
135 const PetscInt jy = j;
137 OpList.push_back({
OpSz,idx});
138 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
146 std::vector< Op > OpList;
149 for(PetscInt j = 1; j < Ly-2; ++j){
150 const PetscInt ix = 1;
151 const PetscInt jy = j;
153 OpList.push_back({
OpSz,idx});
154 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
156 for(PetscInt i = 1; i < Lx-2; ++i){
157 const PetscInt ix = i;
158 const PetscInt jy = Ly-2;
160 OpList.push_back({
OpSz,idx});
161 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
163 for(PetscInt j = Ly-2; j > 1; --j){
164 const PetscInt ix = Lx-2;
165 const PetscInt jy = j;
167 OpList.push_back({
OpSz,idx});
168 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
170 for(PetscInt i = Lx-2; i > 1; --i){
171 const PetscInt ix = i;
172 const PetscInt jy = 1;
174 OpList.push_back({
OpSz,idx});
175 desc +=
"Sz_{"+ std::to_string(ix) +
"," + std::to_string(jy) +
"} ";
PetscErrorCode SetUpCorrelation(const std::vector< Op > &OpList, const std::string &name, const std::string &desc)
Sets up measurement of correlation functions at the end of each sweep.
Op_t
Identifies the three possible spin operators and also represents the shift associated to its action o...
#define OpToStr(OP)
Convert the input Op_t to a C++ string.
const Hamiltonian & HamiltonianRef() const
Const reference to the Hamiltonian object for extracting its parameters.
Contains and manipulates the system and environment blocks used in a single DMRG run.