1 #ifndef __HAMILTONIANS__ 2 #define __HAMILTONIANS__ 5 #include "DMRGBlock.hpp" 93 ierr = PetscOptionsGetReal(NULL,NULL,
"-J1",&_J1,NULL); CHKERRQ(ierr);
94 ierr = PetscOptionsGetReal(NULL,NULL,
"-J2",&_J2,NULL); CHKERRQ(ierr);
95 ierr = PetscOptionsGetReal(NULL,NULL,
"-Jz1",&_Jz1,NULL); CHKERRQ(ierr);
96 ierr = PetscOptionsGetReal(NULL,NULL,
"-Jz2",&_Jz2,NULL); CHKERRQ(ierr);
97 ierr = PetscOptionsGetInt(NULL,NULL,
"-Lx",&_Lx,NULL); CHKERRQ(ierr);
98 ierr = PetscOptionsGetInt(NULL,NULL,
"-Ly",&_Ly,NULL); CHKERRQ(ierr);
99 ierr = PetscOptionsGetBool(NULL,NULL,
"-verbose",&verbose,NULL); CHKERRQ(ierr);
102 ierr = PetscOptionsGetReal(NULL,NULL,
"-heisenberg",&_Jz1,&heisenberg); CHKERRQ(ierr);
110 PetscBool BCopen = PETSC_FALSE;
111 ierr = PetscOptionsGetBool(NULL,NULL,
"-BCopen",&BCopen,NULL); CHKERRQ(ierr);
112 if(BCopen) { _BCx=OpenBC; _BCy=OpenBC; }
113 PetscBool BCperiodic = PETSC_FALSE;
114 ierr = PetscOptionsGetBool(NULL,NULL,
"-BCperiodic",&BCperiodic,NULL); CHKERRQ(ierr);
115 if(BCperiodic) { _BCx=PeriodicBC; _BCy=PeriodicBC; }
116 set_from_options = PETSC_TRUE;
127 std::vector< std::string > keys = {
139 std::ostringstream oss;
140 for(std::string& key: keys) {
141 ierr = PetscOptionsGetString(NULL,NULL,key.c_str(),val,4096,&
set); CHKERRQ(ierr);
143 std::string val_str(val);
144 if(val_str.empty()) val_str =
"yes";
145 oss << key <<
" " << val_str << std::endl;
150 ierr = PetscFOpen(PETSC_COMM_SELF,filename.c_str(),
"w", &fp); CHKERRQ(ierr);
151 ierr = PetscFPrintf(PETSC_COMM_SELF,fp,
"%s",oss.str().c_str()); CHKERRQ(ierr);
152 ierr = PetscFClose(PETSC_COMM_SELF,fp); CHKERRQ(ierr);
165 std::vector< Term > H(
166 const PetscInt& nsites
173 printf(
"HAMILTONIAN: HeisenbergModel_SquareLattice\n");
177 printf(
"HAMILTONIAN: J1J2XXZModel_SquareLattice\n");
179 printf(
" Lx : %lld\n", LLD(_Lx));
180 printf(
" Ly : %lld\n", LLD(_Ly));
181 printf(
" J1 : %g\n", _J1);
182 printf(
" Jz1 : %g\n", _Jz1);
183 printf(
" J2 : %g\n", _J2);
184 printf(
" Jz2 : %g\n", _Jz2);
185 printf(
" BCx : %s\n", _BCx?
"Periodic":
"Open");
186 printf(
" BCy : %s\n", _BCy?
"Periodic":
"Open");
191 fprintf(fp,
" \"Hamiltonian\": {\n");
194 fprintf(fp,
" \"label\":\"HeisenbergModel_SquareLattice\",\n");
198 fprintf(fp,
" \"label\":\"J1J2XXZModel_SquareLattice\",\n");
200 fprintf(fp,
" \"parameters\": {\n");
201 fprintf(fp,
" \"Lx\" : %lld,\n", LLD(_Lx));
202 fprintf(fp,
" \"Ly\" : %lld,\n", LLD(_Ly));
203 fprintf(fp,
" \"J1\" : %g,\n", _J1);
204 fprintf(fp,
" \"Jz1\" : %g,\n", _Jz1);
205 fprintf(fp,
" \"J2\" : %g,\n", _J2);
206 fprintf(fp,
" \"Jz2\" : %g,\n", _Jz2);
207 fprintf(fp,
" \"BCx\" : \"%s\",\n", _BCx?
"Periodic":
"Open");
208 fprintf(fp,
" \"BCy\" : \"%s\"\n", _BCy?
"Periodic":
"Open");
214 PetscInt Lx()
const {
return _Lx; }
216 PetscInt Ly()
const {
return _Ly; }
230 std::vector< std::vector< PetscInt > > NeighborPairs(
const PetscInt d=1)
const;
235 PetscBool heisenberg = PETSC_FALSE;
238 PetscBool set_from_options = PETSC_FALSE;
241 PetscScalar _Jz1 = 0.0;
244 PetscScalar _Jz2 = 0.0;
247 PetscScalar _J1 = 1.0;
250 PetscScalar _J2 = 1.0;
259 PetscBool verbose = PETSC_FALSE;
270 SETERRQ1(PETSC_COMM_SELF,1,
"Function %s not implemented.", __FUNCTION__);
274 std::vector<PetscInt> GetNearestNeighbors(
275 const PetscInt& ix,
const PetscInt& jy,
const PetscInt& nsites_in
279 std::vector<PetscInt> GetNextNearestNeighbors(
280 const PetscInt& ix,
const PetscInt& jy,
const PetscInt& nsites_in
287 PetscBool H_full_filled = PETSC_FALSE;
293 #endif // __HAMILTONIANS__ PetscInt NumSites() const
Returns the number of sites in the square lattice.
Op_t Iop
The operator type for the left side.
PetscScalar a
Constant coefficient.
PetscInt Isite
The index of the site for the left side.
Op_t
Identifies the three possible spin operators and also represents the shift associated to its action o...
PetscErrorCode SaveAsOptions(const std::string &filename)
Dumps options keys and values to file.
Implements the Hamiltonian for the J1-J2 XY model on the square lattice.
A single interaction term on a one-dimensional lattice.
std::vector< Term > H_full
Contains the Hamiltonian involving the entire lattice.
PetscErrorCode PrintInfo() const
Prints some information related to the parameters of the Hamiltonian.
Implementation of Hamiltonian classes.
PetscInt Jsite
The index of the site for the right side.
Op_t Jop
The operator type for the right side.
PetscErrorCode SetFromOptions()
Set attributes from command line arguments.
J1J2XXZModel_SquareLattice()
Constructor.
PetscInt NumEnvSites() const
Returns the number of sites in a single cluster/column of the environment block as suggested by Liang...
void SaveOut(FILE *fp) const
Writes out some JSON information to stdout.
BC_t
Identifies the possible boundary conditions at the edges of the lattice.
void PrintOut() const
Prints out some information to stdout.