StatMech
Loading...
Searching...
No Matches
EnergySpectrum.c File Reference

Functions

double getETtime ()
 
int main (int argc, char **argv)
 

Function Documentation

◆ getETtime()

double getETtime ( )
14 {
15 struct timeval tv;
16 gettimeofday(&tv, NULL);
17 return tv.tv_sec +(double)tv.tv_usec *1e-6;
18}

◆ main()

int main ( int  argc,
char **  argv 
)
20 {
21 if(argc != 7) {
22 fprintf(stderr, "Usage: 1.This 2.(Number of elements) 3.(Number of blocks) 4.(Max elements on a site) 5.|U|*100 6.|V|*100 7.OutDir\n");
23 exit(EX_USAGE);
24 }
25 const MKL_INT N = atoi(argv[1]);
26 const MKL_INT L = atoi(argv[2]);
27 const MKL_INT MaxOnSite = atoi(argv[3]);
28 const double U = -atoi(argv[4])/100.0;
29 double V = -atoi(argv[5])/100.0;
30
31 const MKL_INT NDIV = 200;
32 MKL_INT dim_tot, dim_odd, dim_even, NumPairs;
33
34 double start, end;
35
36 //******************** Allocation ********************//
37 MKL_INT **basis=NULL, *order=NULL;
38 double **eigenEnergy;
39 MKL_Complex16 **Hamiltonian_Odd, **Hamiltonian_Even;
40 fprintf(stdout, "# Generating basis vectors...\n");
41 dim_tot = alloc_BasisVectors(N, L, MaxOnSite, &basis, &order, &NumPairs);
42 dim_odd = NumPairs;
43 dim_even = dim_tot -dim_odd;
44 fprintf(stdout, "# dim_tot = %lld, dim_even = %lld, dim_odd = %lld\n", dim_tot, dim_even, dim_odd);
45 eigenEnergy = alloc_dmatrix(NDIV+1, dim_tot);
46 Hamiltonian_Odd = alloc_zmatrix(dim_odd, dim_odd);
47 Hamiltonian_Even = alloc_zmatrix(dim_even, dim_even);
48 //******************** (END)Allocation ********************//
49
50
51 //****************************************//
52 //****************************************//
53 for(MKL_INT rep = 0;rep <= NDIV; ++rep) {
54 V = -20.0*rep/NDIV;
55 fprintf(stdout, "# Constructing Hamiltonian...\n");
56 Construct_Hamiltonian(Hamiltonian_Odd, dim_odd, Hamiltonian_Even, dim_even, L, basis, U, V);
57 start = getETtime();
58 fprintf(stdout, "# Diagonalizing Hamiltonian...\n"); fflush(stdout);
59 EigenEnergy_zmatrix(dim_even, Hamiltonian_Even, &(eigenEnergy[rep][0]));
60 EigenEnergy_zmatrix(dim_odd, Hamiltonian_Odd, &(eigenEnergy[rep][dim_even]));
61 end = getETtime();
62 fprintf(stderr, "# (%lld %lld), Real time(sec): %.6lf sec\n", N, L, end-start);
63 fflush(stdout); fflush(stderr);
64 }
65
66 //************************************************************//
67 //************************************************************//
68 //************************************************************//
69 //******************** Check for the directory structure ********************
70 const MKL_INT BUFSIZE = 1000;
71 char dstr[BUFSIZE], str[BUFSIZE], stemp[BUFSIZE];
72 strcpy(dstr, argv[6]);
73 strcat(dstr, "/BICData"); mkdir(dstr, 0744);
74 strcat(dstr, "/PBC"); mkdir(dstr, 0744);
75 if(U > 0) sprintf(stemp, "/N%lld_U%lld_Max%lld_L%lld", N, (MKL_INT)( 100*U), MaxOnSite, L);
76 else sprintf(stemp, "/N%lld_nU%lld_Max%lld_L%lld", N, (MKL_INT)(-100*U), MaxOnSite, L);
77 strcat(dstr, stemp); mkdir(dstr, 0744);
78 //******************** (END)Check for the directory structure ********************
79
80 char *filename = str;
81 strcpy(str, dstr);
82 sprintf(stemp, "/EnergySpectra.txt");
83 strcat(str, stemp);
84 FILE* OutFp;
85 OutFp = fopen(filename, "w");
86 if(OutFp == NULL) {
87 printf("Can't open a file %s.", filename);
88 exit(EX_CANTCREAT);
89 }
90 fprintf(OutFp, "# N=%lld, L=%lld, MaxOnSite=%lld\n", N, L, MaxOnSite);
91 fprintf(OutFp, "# U=%+lf\n", U);
92 fprintf(OutFp, "# dim_even=%lld\n", dim_even);
93 fprintf(OutFp, "# 1.(V) 2.(Eigenergy)\n\n");
94 start = getETtime();
95 for(MKL_INT rep = 0;rep <= NDIV; ++rep) {
96 V = -20.0*rep/NDIV;
97 fprintf(OutFp, "%lf ", V);
98 for(MKL_INT j = 0;j < dim_tot; ++j) fprintf(OutFp, "%+le ", eigenEnergy[rep][j]);
99 fprintf(OutFp, "\n");
100 }
101
102 //******************** Free ********************//
103 free_dmatrix(eigenEnergy);
104 free_zmatrix(Hamiltonian_Odd);
105 free_zmatrix(Hamiltonian_Even);
106 free_BasisVectors(basis, order);
107 //******************** (END)Free ********************//
108
109 return 0;
110}
double getETtime()
Definition EnergySpectrum.c:14
void free_zmatrix(double complex **mat)
Definition translation.c:73
double complex ** alloc_zmatrix(int m, int n)
Definition translation.c:54