File: TRAN_Set_SurfOverlap_NC.c

package info (click to toggle)
openmx 3.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 325,856 kB
  • ctags: 3,575
  • sloc: ansic: 152,655; f90: 2,080; python: 876; makefile: 675; sh: 25; perl: 18
file content (233 lines) | stat: -rw-r--r-- 7,651 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/**********************************************************************
  TRAN_Set_SurfOverlap_NC.c:

  TRAN_Set_SurfOverlap_NC.c is a subroutine to construct H00_e, H01_e, 
  S00_e, and S01_e to make surface Green's functions 

  Log of TRAN_Set_SurfOverlap_NC.c:

     11/Dec/2005   Released by H.Kino

***********************************************************************/
/* revised by Y. Xiao for Noncollinear NEGF calculations */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <mpi.h>
#include "tran_prototypes.h"
#include "tran_variables.h"

/***************************************** 

explanation:

atv_ijk[Rn][1..3] has index to the supercell


Rn==0, atv_ijk[Rn][1..3]=0 => means the same cell   => S00

atv_ijk[Rn][1]=1 or -1 means the overlap to the nearest neighbor
cell in the direction of the electrode 
1 or -1 => S01 

assuming atv_ijk[Rn][1]=-1,0 or 1 

---------------------------------------------------------
output 

double S00_nc_e, S01_nc_e, H00_nc_e, H01_nc_e, 

***********************************************/

#define S00_ref(i,j) ( ((j)-1)*NUM+(i)-1 ) 
#define S01_ref(i,j) ( ((j+NUM0)-1)*NUM+(i)-1 )
#define S10_ref(i,j) ( ((j)-1)*NUM+(i+NUM0)-1 )
#define S11_ref(i,j) ( ((j+NUM0)-1)*NUM+(i+NUM0)-1 )

void TRAN_Set_SurfOverlap_NC( MPI_Comm comm1,
                           char *position, 
                           double k2,
                           double k3)  
{
  int NUM,NUM0,n2;
  int Anum, Bnum, wanA, tnoA;
  int i,j,k;
  int GA_AN;
  int GB_AN, LB_AN,wanB, tnoB,Rn;
  int l1,l2,l3; 
  int direction,iside;
  double si,co,kRn;
  double s,h[10];
  double a00,a11,a01r,a01i,b00,b11,b01;
  static double epscutoff=1.0e-8;
  int *MP;
  /*debug */
  char msg[100];
  /*end debug */

  /*
  printf("<TRAN_Set_SurfOverlap, direction=%s>\n",position);
  */

  /* position -> direction */
  if      ( strcasecmp(position,"left")==0) {
    direction = -1;
    iside = 0;
  }
  else if ( strcasecmp(position,"right")==0) {
    direction = 1;
    iside = 1;
  } 

  /* set MP */
/*  TRAN_Set_MP(0, atomnum_e[iside], WhatSpecies_e[iside], Spe_Total_CNO_e[iside], &NUM, &i); */
  MP = (int*)malloc(sizeof(int)*(atomnum_e[iside]+1));
  TRAN_Set_MP(1, atomnum_e[iside], WhatSpecies_e[iside], Spe_Total_CNO_e[iside], &NUM, MP);
  NUM0=NUM;
  NUM=2*NUM;

  n2 = NUM + 1;   

  for (i=0; i<n2*n2; i++){
    S00_nc_e[iside][i].r = 0.0;
    S00_nc_e[iside][i].i = 0.0;
    S01_nc_e[iside][i].r = 0.0;
    S01_nc_e[iside][i].i = 0.0;
  }
  
  for (i=0; i<n2*n2; i++){
    H00_nc_e[iside][i].r = 0.0;
    H00_nc_e[iside][i].i = 0.0;
    H01_nc_e[iside][i].r = 0.0;
    H01_nc_e[iside][i].i = 0.0;
  }

  for (GA_AN=1; GA_AN<=atomnum_e[iside]; GA_AN++){

    wanA = WhatSpecies_e[iside][GA_AN];
    tnoA = Spe_Total_CNO_e[iside][wanA];
    Anum = MP[GA_AN];

    for (LB_AN=0; LB_AN<=FNAN_e[iside][GA_AN]; LB_AN++){

      GB_AN = natn_e[iside][GA_AN][LB_AN];
      Rn = ncn_e[iside][GA_AN][LB_AN];
      wanB = WhatSpecies_e[iside][GB_AN];
      tnoB = Spe_Total_CNO_e[iside][wanB];
      Bnum = MP[GB_AN];

      l1 = atv_ijk_e[iside][Rn][1];
      l2 = atv_ijk_e[iside][Rn][2];
      l3 = atv_ijk_e[iside][Rn][3];

      kRn = k2*(double)l2 + k3*(double)l3;
      si = sin(2.0*PI*kRn);
      co = cos(2.0*PI*kRn);

      if (l1==0) {
	for (i=0; i<tnoA; i++){
	  for (j=0; j<tnoB; j++){

            /* S_alpha-alpha */
	    S00_nc_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
	    S00_nc_e[iside][S00_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            /* S_beta-beta */
            S00_nc_e[iside][S11_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            S00_nc_e[iside][S11_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            
            a00=H_e[iside][0][GA_AN][LB_AN][i][j];
            a11=H_e[iside][1][GA_AN][LB_AN][i][j];
            a01r=H_e[iside][2][GA_AN][LB_AN][i][j];
            a01i=H_e[iside][3][GA_AN][LB_AN][i][j];

            b00=iHNL_e[iside][0][GA_AN][LB_AN][i][j];
            b11=iHNL_e[iside][1][GA_AN][LB_AN][i][j];
            b01=iHNL_e[iside][2][GA_AN][LB_AN][i][j];
            /* H_alpha-alpha */
            H00_nc_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*a00 - si*b00;
            H00_nc_e[iside][S00_ref(Anum+i,Bnum+j)].i += co*b00 + si*a00;
            /* H_alpha-beta */
            H00_nc_e[iside][S01_ref(Anum+i,Bnum+j)].r += co*a01r - si*(a01i+b01);
            H00_nc_e[iside][S01_ref(Anum+i,Bnum+j)].i += si*a01r + co*(a01i+b01);
            /* H_beta-beta */
            H00_nc_e[iside][S11_ref(Anum+i,Bnum+j)].r += co*a11 - si*b11;
            H00_nc_e[iside][S11_ref(Anum+i,Bnum+j)].i += co*b11 + si*a11;
           
            /*
            S00_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            S00_e[iside][S00_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];

            for (k=0; k<=SpinP_switch_e[iside]; k++ ){
              H00_e[iside][k][S00_ref(Anum+i,Bnum+j)].r += co*H_e[iside][k][GA_AN][LB_AN][i][j];
              H00_e[iside][k][S00_ref(Anum+i,Bnum+j)].i += si*H_e[iside][k][GA_AN][LB_AN][i][j];
            } 
            */

	  }
	}
      }

      if (l1==direction) {

	for (i=0; i<tnoA; i++){
	  for (j=0; j<tnoB; j++){

            /* S_alpha-alpha */
            S01_nc_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            S01_nc_e[iside][S00_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            /* S_beta-beta */
            S01_nc_e[iside][S11_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
            S01_nc_e[iside][S11_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];

            a00=H_e[iside][0][GA_AN][LB_AN][i][j];
            a11=H_e[iside][1][GA_AN][LB_AN][i][j];
            a01r=H_e[iside][2][GA_AN][LB_AN][i][j];
            a01i=H_e[iside][3][GA_AN][LB_AN][i][j];
            
            b00=iHNL_e[iside][0][GA_AN][LB_AN][i][j];
            b11=iHNL_e[iside][1][GA_AN][LB_AN][i][j];
            b01=iHNL_e[iside][2][GA_AN][LB_AN][i][j];
            /* H_alpha-alpha */
            H01_nc_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*a00 - si*b00;
            H01_nc_e[iside][S00_ref(Anum+i,Bnum+j)].i += co*b00 + si*a00;
            /* H_alpha-beta */
            H01_nc_e[iside][S01_ref(Anum+i,Bnum+j)].r += co*a01r - si*(a01i+b01);
            H01_nc_e[iside][S01_ref(Anum+i,Bnum+j)].i += si*a01r + co*(a01i+b01);
            /* H_beta-beta */
            H01_nc_e[iside][S11_ref(Anum+i,Bnum+j)].r += co*a11 - si*b11;
            H01_nc_e[iside][S11_ref(Anum+i,Bnum+j)].i += co*b11 + si*a11;

            /*
	    S01_e[iside][S00_ref(Anum+i,Bnum+j)].r += co*OLP_e[iside][0][GA_AN][LB_AN][i][j];
	    S01_e[iside][S00_ref(Anum+i,Bnum+j)].i += si*OLP_e[iside][0][GA_AN][LB_AN][i][j];

	    for (k=0; k<=SpinP_switch_e[iside]; k++ ){
	      H01_e[iside][k][S00_ref(Anum+i,Bnum+j)].r += co*H_e[iside][k][GA_AN][LB_AN][i][j];
	      H01_e[iside][k][S00_ref(Anum+i,Bnum+j)].i += si*H_e[iside][k][GA_AN][LB_AN][i][j];
	    }
            */
	  }
	}
      }

    }
  }  /* GA_AN */
    
   for (i=1; i<=NUM0; i++) {
     for (j=1; j<=NUM0; j++) {

       H00_nc_e[iside][(j-1)*NUM+i+NUM0-1].r =  H00_nc_e[iside][(i+NUM0-1)*NUM+j-1].r;
       H00_nc_e[iside][(j-1)*NUM+i+NUM0-1].i = -H00_nc_e[iside][(i+NUM0-1)*NUM+j-1].i;

       H01_nc_e[iside][(j-1)*NUM+i+NUM0-1].r =  H01_nc_e[iside][(i+NUM0-1)*NUM+j-1].r;
       H01_nc_e[iside][(j-1)*NUM+i+NUM0-1].i = -H01_nc_e[iside][(i+NUM0-1)*NUM+j-1].i;

      }
    }

  /* free arrays */

  free(MP);
}