1 /**********************************************************************
2   TRAN_Calc_CentGreenLesser.c:
3 
4   TRAN_Calc_CentGreenLesser.c is a subroutine to calculate the lesser
5   Green's function of the central part.
6 
7   Log of TRAN_Calc_CentGreenLesser.c:
8 
9      24/July/2008  Released by H. Kino and T. Ozaki
10 
11 ***********************************************************************/
12 
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <mpi.h>
17 #include "tran_prototypes.h"
18 #include "lapack_prototypes.h"
19 #define PI              3.1415926535897932384626
20 
21 
22 
TRAN_Calc_CentGreenLesser(dcomplex w,double ChemP_e[2],int nc,int Order_Lead_Side[2],dcomplex * SigmaL,dcomplex * SigmaR,dcomplex * GC,dcomplex * HCCk,dcomplex * SCC,dcomplex * v1,dcomplex * v2,dcomplex * Gless)23 void TRAN_Calc_CentGreenLesser(
24                       /* input */
25                       dcomplex w,
26                       double ChemP_e[2],
27                       int nc,
28                       int Order_Lead_Side[2],
29                       dcomplex *SigmaL,
30                       dcomplex *SigmaR,
31                       dcomplex *GC,
32                       dcomplex *HCCk,
33                       dcomplex *SCC,
34 
35                       /* work, nc*nc */
36                       dcomplex *v1,
37                       dcomplex *v2,
38 
39                       /*  output */
40                       dcomplex *Gless
41                       )
42 
43 #define GC_ref(i,j)        GC[nc*((j)-1)+(i)-1]
44 #define GC_Ad_ref(i,j)     GC[nc*((i)-1)+(j)-1]     /* Sign change will be taken into account during the calculation */
45 #define SigmaL_ref(i,j)    SigmaL[nc*((j)-1)+(i)-1]
46 #define SigmaL_Ad_ref(i,j) SigmaL[nc*((i)-1)+(j)-1] /* Sign change will be taken into account during the calculation */
47 #define SigmaR_ref(i,j)    SigmaR[nc*((j)-1)+(i)-1]
48 #define SigmaR_Ad_ref(i,j) SigmaR[nc*((i)-1)+(j)-1] /* Sign change will be taken into account during the calculation */
49 #define SCC_ref(i,j)       SCC[nc*((j)-1)+(i)-1]
50 #define HCCk_ref(i,j)      HCCk[nc*((j)-1)+(i)-1]
51 #define v1_ref(i,j)        v1[nc*((j)-1)+(i)-1]
52 #define v2_ref(i,j)        v2[nc*((j)-1)+(i)-1]
53 #define Gless_ref(i,j)     Gless[nc*((j)-1)+(i)-1]
54 
55 {
56   int i,j;
57   int side;
58   dcomplex alpha,beta;
59   dcomplex ctmp;
60 
61   alpha.r = 1.0;
62   alpha.i = 0.0;
63   beta.r  = 0.0;
64   beta.i  = 0.0;
65 
66   /******************************************************
67     lesser Green's function
68   ******************************************************/
69 
70   /* v1 = -\sigama_{L or R}(z^*) */
71 
72   if (Order_Lead_Side[1]==0){
73 
74     for (i=1; i<=nc; i++) {
75       for (j=1; j<=nc; j++) {
76 
77 	v1_ref(i,j).r = SigmaL_ref(i,j).r - SigmaL_Ad_ref(i,j).r;
78 	v1_ref(i,j).i = SigmaL_ref(i,j).i + SigmaL_Ad_ref(i,j).i;
79       }
80     }
81   }
82   else{
83 
84     for (i=1; i<=nc; i++) {
85       for (j=1; j<=nc; j++) {
86 
87 	v1_ref(i,j).r = SigmaR_ref(i,j).r - SigmaR_Ad_ref(i,j).r;
88 	v1_ref(i,j).i = SigmaR_ref(i,j).i + SigmaR_Ad_ref(i,j).i;
89       }
90     }
91   }
92 
93   /* v2 = G(z) * v1 */
94 
95   F77_NAME(zgemm,ZGEMM)("N","N", &nc, &nc, &nc, &alpha, GC, &nc, v1, &nc, &beta, v2, &nc);
96 
97   /* Gless = G(z) * v1 * G^{dag}(z)  */
98 
99   F77_NAME(zgemm,ZGEMM)("N","C", &nc, &nc, &nc, &alpha, v2, &nc, GC, &nc, &beta, Gless, &nc);
100 
101   /******************************************************
102     -1/(i 2Pi) * Gless
103   ******************************************************/
104 
105   for (i=1; i<=nc; i++) {
106     for (j=1; j<=nc; j++) {
107       ctmp.r = Gless_ref(i,j).r/(2.0*PI);
108       ctmp.i = Gless_ref(i,j).i/(2.0*PI);
109       Gless_ref(i,j).r =-ctmp.i;
110       Gless_ref(i,j).i = ctmp.r;
111     }
112   }
113 
114 }
115 
116