HPhi++  3.1.0
HPhiTrans.cpp
Go to the documentation of this file.
1 /* HPhi - Quantum Lattice Model Simulator */
2 /* Copyright (C) 2015 The University of Tokyo */
3 
4 /* This program is free software: you can redistribute it and/or modify */
5 /* it under the terms of the GNU General Public License as published by */
6 /* the Free Software Foundation, either version 3 of the License, or */
7 /* (at your option) any later version. */
8 
9 /* This program is distributed in the hope that it will be useful, */
10 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
11 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
12 /* GNU General Public License for more details. */
13 
14 /* You should have received a copy of the GNU General Public License */
15 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 
17 #include "Common.hpp"
18 #include "HPhiTrans.hpp"
19 #include "FileIO.hpp"
20 #include "wrapperMPI.hpp"
21 
45 int HPhiTrans(struct BindStruct *X) {
46  FILE *fp_err;
47  char sdt_err[D_FileNameMax];
48 
49  int i, k;
50  int cnt_trans;
51 
52  strcpy(sdt_err, "WarningOnTransfer.dat");
53  if (childfopenMPI(sdt_err, "w", &fp_err) != 0) {
54  return -1;
55  }
56  fclose(fp_err);
57 
58  //Transefer
59  cnt_trans = 0;
60 
61  for (i = 0; i < X->Def.EDNTransfer; i++) {
62  // eliminate double counting
63  for (k = 0; k < cnt_trans; k++) {
64  if (X->Def.EDGeneralTransfer[i][1] == X->Def.EDGeneralTransfer[k][1]
65  && X->Def.EDGeneralTransfer[i][3] == X->Def.EDGeneralTransfer[k][3]) {
66  if (X->Def.EDGeneralTransfer[i][0] == X->Def.EDGeneralTransfer[k][0]
67  && X->Def.EDGeneralTransfer[i][2] == X->Def.EDGeneralTransfer[k][2]) {
68  sprintf(sdt_err, "WarningOnTransfer.dat");
69  childfopenMPI(sdt_err, "a", &fp_err);
70  fprintf(fp_err, "double conuntings in transfers: i=%d j=%d spni %d spnj %d \n",
71  X->Def.EDGeneralTransfer[k][0], X->Def.EDGeneralTransfer[k][2],
72  X->Def.EDGeneralTransfer[k][1], X->Def.EDGeneralTransfer[k][3]);
73  fclose(fp_err);
74  }
75  }
76  }
77  cnt_trans += 1;
78  }
79 
80  return 0;
81 }
82 
93 int TransferWithPeierls(struct BindStruct *X, const double time) {
94  int i;
95  int ri_x, rj_x;
96  int ri_y, rj_y;
97  std::complex<double> dir;
98  const int Mode = (int) (X->Def.ParaLaser[0]);
99  const double Avp = X->Def.ParaLaser[1];
100  const double omega = X->Def.ParaLaser[2];
101  const double time_d = X->Def.ParaLaser[3];
102  const double time_c = X->Def.ParaLaser[4];
103  const int Lx = (int) (X->Def.ParaLaser[5]);
104  const int Ly = (int) (X->Def.ParaLaser[6]);
105  const double dirX = X->Def.ParaLaser[7];
106  const double dirY = X->Def.ParaLaser[8];
107  const double dt = time - time_c;
108  const double dt2 = time - (time_c + time_d);
109  const double td = time_c / 3.0;
110  double VecPot;
111 
112  //printf("Make Trasfer with Pierles factor");
113 
114  if (Mode == 0) {//Gaussian Wave
115  VecPot = Avp * cos(omega * dt) * exp(-dt * dt / (2.0 * time_d * time_d));
116  } else if (Mode == 1) {//Cosine Wave
117  VecPot = Avp * sin(omega * dt);
118  } else if (Mode == 2) {//DC Limit
119  VecPot = Avp * dt;
120  } else if (Mode == 3) {//Pulse
121  VecPot = Avp * exp(-time_d * dt);
122  } else if (Mode == 4) {//Linear
123  if (dt <= 0.0) {
124  VecPot = 0.0;
125  } else if (dt < time_d) {
126  VecPot = Avp * cos(omega * dt) * (dt / time_d);
127  } else {
128  VecPot = Avp * cos(omega * dt);
129  }
130  } else if (Mode == 5) {//Linear
131  if (time <= 0.0) {
132  VecPot = 0.0;
133  } else if (time < time_c) {
134  VecPot = Avp * cos(omega * dt) * exp(-dt * dt / (2.0 * td * td));
135  } else if (time < time_c + time_d) {
136  VecPot = Avp * cos(omega * dt);
137  } else {
138  VecPot = Avp * cos(omega * dt) * exp(-dt2 * dt2 / (2.0 * td * td));
139  }
140  }
141 
142  for (i = 0; i < X->Def.EDNTransfer; i++) {
143  ri_x = X->Def.EDGeneralTransfer[i][0] % Lx;
144  rj_x = X->Def.EDGeneralTransfer[i][2] % Lx;
145  ri_y = X->Def.EDGeneralTransfer[i][0] / Lx;
146  rj_y = X->Def.EDGeneralTransfer[i][2] / Lx;
147  if (ri_x - rj_x > 1) {
148  rj_x += Lx;
149  } else if (ri_x - rj_x < -1) {
150  rj_x -= Lx;
151  }
152  if (ri_y - rj_y > 1) {
153  rj_y += Ly;
154  } else if (ri_y - rj_y < -1) {
155  rj_y -= Ly;
156  }
157  dir = dirX * (ri_x - rj_x) + dirY * (ri_y - rj_y);
158 
159  X->Def.EDParaGeneralTransfer[i] = X->Def.ParaGeneralTransfer[i] * std::exp(-I * VecPot * dir);
160  }
161 
162  return 0;
163 }
164 
175 int TransferForQuench(struct BindStruct *X, const double time) {
176  int i;
177  int ri_x, rj_x;
178  int ri_y, rj_y;
179  const int Mode = (int) (X->Def.ParaLaser[0]);
180  const double Avp = X->Def.ParaLaser[1];
181  const double time_d = X->Def.ParaLaser[3];
182  const double time_c = X->Def.ParaLaser[4];
183  const int Lx = (int) (X->Def.ParaLaser[5]);
184  const int Ly = (int) (X->Def.ParaLaser[6]);
185  const double dt = time - time_c;
186  double Bessel;
187 
188  //printf("Make Trasfer with Pierles factor");
189 
190  if (Mode == 0) {//Gaussian Wave
191  if (dt <= 0.0) {
192  Bessel = 0.0;
193  } else if (dt < time_d) {
194  Bessel = j0(Avp * dt / time_d);
195  } else {
196  Bessel = j0(Avp);
197  }
198  }
199 
200  for (i = 0; i < X->Def.EDNTransfer; i++) {
201  ri_x = X->Def.EDGeneralTransfer[i][0] % Lx;
202  rj_x = X->Def.EDGeneralTransfer[i][2] % Lx;
203  ri_y = X->Def.EDGeneralTransfer[i][0] / Lx;
204  rj_y = X->Def.EDGeneralTransfer[i][2] / Lx;
205  if (ri_x - rj_x > 1) {
206  rj_x += Lx;
207  } else if (ri_x - rj_x < -1) {
208  rj_x -= Lx;
209  }
210  if (ri_y - rj_y > 1) {
211  rj_y += Ly;
212  } else if (ri_y - rj_y < -1) {
213  rj_y -= Ly;
214  }
215 
216  X->Def.EDParaGeneralTransfer[i] = X->Def.ParaGeneralTransfer[i] * Bessel;
217  }
218 
219  return 0;
220 }
221 
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
std::complex< double > * EDParaGeneralTransfer
Value of general transfer integrals by a def file. malloc in setmem_def(). Data Format [DefineList::N...
Definition: struct.hpp:116
int HPhiTrans(struct BindStruct *X)
Function of checking transfers not to count the same type of operators. .
Definition: HPhiTrans.cpp:45
std::complex< double > I(0.0, 1.0)
int ** EDGeneralTransfer
Index of transfer integrals for calculation. malloc in setmem_def(). Data Format [DefineList::NTransf...
Definition: struct.hpp:110
double * ParaLaser
Definition: struct.hpp:253
int EDNTransfer
Number of transfer integrals for calculation.
Definition: struct.hpp:105
Bind.
Definition: struct.hpp:394
int TransferForQuench(struct BindStruct *X, const double time)
Function of getting transfer for quench.
Definition: HPhiTrans.cpp:175
int TransferWithPeierls(struct BindStruct *X, const double time)
Function of getting transfer with peierls.
Definition: HPhiTrans.cpp:93
std::complex< double > * ParaGeneralTransfer
Value of general transfer integrals by a def file. malloc in setmem_def(). Data Format [DefineList::N...
Definition: struct.hpp:113
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.cpp:27