1 /**********************************************************************
2 TRAN_Input_std.c:
3
4 TRAN_Input_std.c is a subroutine to read the input data.
5
6 Log of TRAN_Input_std.c:
7
8 24/July/2008 Released by H.Kino and T.Ozaki
9
10 ***********************************************************************/
11
12 #include <stdio.h>
13 #include <string.h>
14 #include <stdlib.h>
15 #include <math.h>
16 #include "Inputtools.h"
17 #include <mpi.h>
18 #include "tran_prototypes.h"
19 #include "tran_variables.h"
20
21 #define MAXBUF 256
22
23
24
25
TRAN_Input_std(MPI_Comm comm1,int Solver,int SpinP_switch,char * filepath,double kBvalue,double TRAN_eV2Hartree,double Electronic_Temperature,int * output_hks)26 void TRAN_Input_std(
27 MPI_Comm comm1,
28 int Solver, /* input */
29 int SpinP_switch,
30 char *filepath,
31 double kBvalue,
32 double TRAN_eV2Hartree,
33 double Electronic_Temperature,
34 /* output */
35 int *output_hks
36 )
37 {
38 FILE *fp;
39 int i,po;
40 int i_vec[20],i_vec2[20];
41 double r_vec[20];
42 char *s_vec[20];
43 char buf[MAXBUF];
44 int myid;
45 /* S MitsuakiKAWAMURA*/
46 int TRAN_Analysis_Dummy;
47 /* E MitsuakiKAWAMURA*/
48
49 MPI_Comm_rank(comm1,&myid);
50
51 /****************************************************
52 parameters for TRANSPORT
53 ****************************************************/
54
55 input_logical("NEGF.Output_HKS",&TRAN_output_hks,0);
56 *output_hks = TRAN_output_hks;
57
58 /* printf("NEGF.OutputHKS=%d\n",TRAN_output_hks); */
59 input_string("NEGF.filename.HKS",TRAN_hksoutfilename,"NEGF.hks");
60 /* printf("TRAN_hksoutfilename=%s\n",TRAN_hksoutfilename); */
61
62 input_logical("NEGF.Output.for.TranMain",&TRAN_output_TranMain,0);
63
64 if ( Solver!=4 ) { return; }
65
66 /**** show transport credit ****/
67 TRAN_Credit(comm1);
68
69 input_string("NEGF.filename.hks.l",TRAN_hksfilename[0],"NEGF.hks.l");
70 input_string("NEGF.filename.hks.r",TRAN_hksfilename[1],"NEGF.hks.r");
71
72 /* read data of leads */
73
74 TRAN_RestartFile(comm1, "read","left", filepath,TRAN_hksfilename[0]);
75 TRAN_RestartFile(comm1, "read","right",filepath,TRAN_hksfilename[1]);
76
77 /* check b-, and c-axes of the unit cell of leads. */
78
79 po = 0;
80 for (i=2; i<=3; i++){
81 if (1.0e-10<fabs(tv_e[0][i][1]-tv_e[1][i][1])) po = 1;
82 if (1.0e-10<fabs(tv_e[0][i][2]-tv_e[1][i][2])) po = 1;
83 if (1.0e-10<fabs(tv_e[0][i][3]-tv_e[1][i][3])) po = 1;
84 }
85
86 if (po==1){
87
88 if (myid==Host_ID){
89 printf("Warning: The b- or c-axis of the unit cell for the left lead is not same as that for the right lead.\n");
90 }
91
92 MPI_Finalize();
93 exit(1);
94 }
95
96 /* show chemical potentials */
97
98 if (myid==Host_ID){
99 printf("\n");
100 printf("Intrinsic chemical potential (eV) of the leads\n");
101 printf(" Left lead: %15.12f\n",ChemP_e[0]*TRAN_eV2Hartree);
102 printf(" Right lead: %15.12f\n",ChemP_e[1]*TRAN_eV2Hartree);
103 }
104
105 /* check the conflict of SpinP_switch */
106
107 if ( (SpinP_switch!=SpinP_switch_e[0]) || (SpinP_switch!=SpinP_switch_e[1]) ){
108
109 if (myid==Host_ID){
110 printf ("scf.SpinPolarization conflicts between leads or lead and center.\n");
111 }
112
113 MPI_Finalize();
114 exit(0);
115 }
116
117 input_int( "NEGF.Surfgreen.iterationmax", &tran_surfgreen_iteration_max, 600);
118 input_double("NEGF.Surfgreen.convergeeps", &tran_surfgreen_eps, 1.0e-12);
119
120 /**** k-points parallel to the layer, which are used for the SCF calc. ****/
121
122 i_vec2[0]=1;
123 i_vec2[1]=1;
124 input_intv("NEGF.scf.Kgrid",2,i_vec,i_vec2);
125 TRAN_Kspace_grid2 = i_vec[0];
126 TRAN_Kspace_grid3 = i_vec[1];
127
128 if (TRAN_Kspace_grid2<=0){
129
130 if (myid==Host_ID){
131 printf("NEGF.scf.Kgrid should be over 1\n");
132 }
133
134 MPI_Finalize();
135 exit(1);
136 }
137 if (TRAN_Kspace_grid3<=0){
138
139 if (myid==Host_ID){
140 printf("NEGF.scf.Kgrid should be over 1\n");
141 }
142
143 MPI_Finalize();
144 exit(1);
145 }
146
147 /* Poisson solver */
148
149 TRAN_Poisson_flag = 1;
150
151 /* beginning added by mari 07.23.2014 */
152 s_vec[0]="FD"; s_vec[1]="FFT"; s_vec[2]="FDG";
153 i_vec[0]=1 ; i_vec[1]=2 ; i_vec[2]=3 ;
154
155 input_string2int("NEGF.Poisson.Solver", &TRAN_Poisson_flag, 3, s_vec,i_vec);
156 /* end added by mari 07.23.2014 */
157
158 /* parameter to scale terms with Gpara=0 */
159
160 input_double("NEGF.Poisson_Gparazero.scaling", &TRAN_Poisson_Gpara_Scaling, 1.0);
161
162 /* the number of buffer cells in FFTE */
163
164 input_int("NEGF.FFTE.Num.Buffer.Cells", &TRAN_FFTE_CpyNum, 1);
165
166 /* the number of iterations by the Band calculation in the initial SCF iterations */
167
168 input_int("NEGF.SCF.Iter.Band", &TRAN_SCF_Iter_Band, 3);
169
170 /* integration method */
171
172 TRAN_integration = 0;
173
174 s_vec[0]="CF"; s_vec[1]="OLD";
175 i_vec[0]=0 ; i_vec[1]=1 ;
176 input_string2int("NEGF.Integration", &TRAN_integration, 2, s_vec,i_vec);
177
178 /* check whether analysis is made or not */
179
180 input_logical("NEGF.tran.analysis",&TRAN_analysis,1);
181
182 /* S MitsuakiKAWAMURA*/
183 input_logical("NEGF.tran.channel", &TRAN_Analysis_Dummy, 1);
184 if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1){
185 TRAN_analysis = 1;
186 if (myid == Host_ID)
187 printf("Since NEGF.tran.channel is on, NEGF.tran.analysis is automatically set to on.\n");
188 }
189 input_logical("NEGF.tran.CurrentDensity", &TRAN_Analysis_Dummy, 1);
190 if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1){
191 TRAN_analysis = 1;
192 if (myid == Host_ID)
193 printf("Since NEGF.tran.CurrentDensity is on, NEGF.tran.analysis is automatically set to on.\n");
194 }
195 input_logical("NEGF.OffDiagonalCurrent", &TRAN_Analysis_Dummy, 0);
196 if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1) {
197 TRAN_analysis = 1;
198 if (myid == Host_ID)
199 printf("Since NEGF.OffDiagonalCurrent is on, NEGF.tran.analysis is automatically set to on.\n");
200 }
201 /* E MitsuakiKAWAMURA*/
202
203 /* check whether the SCF calcultion is skipped or not */
204
205 i = 0;
206 s_vec[i] = "OFF"; i_vec[i] = 0; i++;
207 s_vec[i] = "ON"; i_vec[i] = 1; i++;
208 s_vec[i] = "Periodic"; i_vec[i] = 2; i++;
209
210 input_string2int("NEGF.tran.SCF.skip", &TRAN_SCF_skip, i, s_vec, i_vec);
211
212 /**** k-points parallel to the layer, which are used for the transmission calc. ****/
213
214 i_vec2[0]=TRAN_Kspace_grid2;
215 i_vec2[1]=TRAN_Kspace_grid3;
216 input_intv("NEGF.tran.Kgrid",2,i_vec,i_vec2);
217 TRAN_TKspace_grid2 = i_vec[0];
218 TRAN_TKspace_grid3 = i_vec[1];
219
220 if (TRAN_TKspace_grid2<=0){
221
222 if (myid==Host_ID){
223 printf("NEGF.tran.Kgrid should be over 1\n");
224 }
225
226 MPI_Finalize();
227 exit(1);
228 }
229 if (TRAN_TKspace_grid3<=0){
230
231 if (myid==Host_ID){
232 printf("NEGF.tran.Kgrid should be over 1\n");
233 }
234
235 MPI_Finalize();
236 exit(1);
237 }
238
239 /**** source and drain bias voltage ****/
240
241 input_logical("NEGF.bias.apply",&tran_bias_apply,1); /* default=on */
242
243 if ( tran_bias_apply ) {
244
245 double tmp;
246
247 tran_biasvoltage_e[0] = 0.0;
248 input_double("NEGF.bias.voltage", &tmp, 0.0); /* in eV */
249 tran_biasvoltage_e[1] = tmp/TRAN_eV2Hartree;
250
251 }
252 else {
253 tran_biasvoltage_e[0]=0.0;
254 tran_biasvoltage_e[1]=0.0;
255 }
256
257 if (tran_bias_apply) {
258
259 int side;
260 side=0;
261 TRAN_Apply_Bias2e(comm1, side, tran_biasvoltage_e[side], TRAN_eV2Hartree,
262 SpinP_switch_e[side], atomnum_e[side],
263 WhatSpecies_e[side], Spe_Total_CNO_e[side], FNAN_e[side], natn_e[side],
264 Ngrid1_e[side], Ngrid2_e[side], Ngrid3_e[side], OLP_e[side][0],
265 &ChemP_e[side],H_e[side], dVHart_Grid_e[side] ); /* output */
266 side=1;
267 TRAN_Apply_Bias2e(comm1, side, tran_biasvoltage_e[side], TRAN_eV2Hartree,
268 SpinP_switch_e[side], atomnum_e[side],
269 WhatSpecies_e[side], Spe_Total_CNO_e[side], FNAN_e[side], natn_e[side],
270 Ngrid1_e[side], Ngrid2_e[side], Ngrid3_e[side], OLP_e[side][0],
271 &ChemP_e[side], H_e[side], dVHart_Grid_e[side] ); /* output */
272 }
273
274 /**** gate voltage ****/
275
276 /* beginning added by mari 07.30.2014 */
277 if(TRAN_Poisson_flag == 3) {
278 r_vec[0] = 0.0;
279 r_vec[1] = 0.0;
280 input_doublev("NEGF.gate.voltage", 2, tran_gate_voltage, r_vec);
281 tran_gate_voltage[0] /= TRAN_eV2Hartree;
282 tran_gate_voltage[1] /= TRAN_eV2Hartree;
283 } else {
284 r_vec[0] = 0.0;
285 input_doublev("NEGF.gate.voltage", 1, tran_gate_voltage, r_vec);
286 tran_gate_voltage[0] /= TRAN_eV2Hartree;
287 }
288 /* end added by mari 07.30.2014 */
289
290 /******************************************************
291 parameters for the DOS calculation
292 ******************************************************/
293
294 i=0;
295 r_vec[i++] = -10.0;
296 r_vec[i++] = 10.0;
297 r_vec[i++] = 5.0e-3;
298 input_doublev("NEGF.Dos.energyrange",i, tran_dos_energyrange, r_vec); /* in eV */
299 /* change the unit from eV to Hartree */
300 tran_dos_energyrange[0] /= TRAN_eV2Hartree;
301 tran_dos_energyrange[1] /= TRAN_eV2Hartree;
302 tran_dos_energyrange[2] /= TRAN_eV2Hartree;
303
304 input_int("NEGF.Dos.energy.div",&tran_dos_energydiv,200);
305
306 i_vec2[0]=1;
307 i_vec2[1]=1;
308 input_intv("NEGF.Dos.Kgrid",2,i_vec,i_vec2);
309 TRAN_dos_Kspace_grid2 = i_vec[0];
310 TRAN_dos_Kspace_grid3 = i_vec[1];
311
312 /********************************************************
313 integration on real axis with a small imaginary part
314 for the "non-equilibrium" region
315 ********************************************************/
316
317 input_double("NEGF.bias.neq.im.energy", &Tran_bias_neq_im_energy, 1.0e-2); /* in eV */
318 if (Tran_bias_neq_im_energy<0.0) {
319 if (myid==Host_ID) printf("NEGF.bias.neq.im.energy should be positive.\n");
320 MPI_Finalize();
321 exit(1);
322 }
323 /* change the unit from eV to Hartree */
324 Tran_bias_neq_im_energy /= TRAN_eV2Hartree;
325
326 input_double("NEGF.bias.neq.energy.step", &Tran_bias_neq_energy_step, 0.02); /* in eV */
327 if (Tran_bias_neq_energy_step<0.0) {
328 if (myid==Host_ID) printf("NEGF.bias.neq.energy.step should be positive.\n");
329 MPI_Finalize();
330 exit(1);
331 }
332 /* change the unit from eV to Hartree */
333 Tran_bias_neq_energy_step /= TRAN_eV2Hartree;
334
335 input_double("NEGF.bias.neq.cutoff", &Tran_bias_neq_cutoff, 1.0e-8); /* dimensionless */
336
337 /********************************************************
338 contour integration based on a continued
339 fraction representation of the Fermi function
340 ********************************************************/
341
342 input_int("NEGF.Num.Poles", &tran_num_poles,150);
343
344 TRAN_Set_IntegPath( comm1, TRAN_eV2Hartree, kBvalue, Electronic_Temperature );
345 }
346
347
348
349