File: TRAN_Calc_CentGreenLesser.c

package info (click to toggle)
openmx 3.2.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 62,572 kB
  • ctags: 2,684
  • sloc: ansic: 130,666; python: 876; makefile: 560; xml: 63; perl: 18; sh: 4
file content (130 lines) | stat: -rw-r--r-- 2,702 bytes parent folder | download
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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#ifdef nompi
#include "mimic_mpi.h"
#else
#include <mpi.h>
#endif

#include "tran_prototypes.h"
#include "lapack_prototypes.h"



/*
 *  calculate G^<(w) 
 *     G^< (w) = G^R(w) ( Gamma_L(w) nf(w-ChemP_L) + Gamma_R(w) nf(w-ChemP_R) ) G^A(w) 
 * 
 *  ... w_weight includes -1 factor 
 *    rho(w) = -1/PI Im G(w) 
 *
 *  ... therefore, this function returns -G^< (w) 
 *
 *
 *  no implicit variables 
 */
void TRAN_Calc_CentGreenLesser(
                                /* input */
                      dcomplex w,
                      double ChemP_e[2],

                      int nc, 
                      dcomplex *SigmaL,
                      dcomplex *SigmaR, 
                      dcomplex *GC, /*  input */
                      dcomplex *v1, /* work, nc*nc */
                      dcomplex *Gless /*  output */
                      )
#define GC_ref(i,j)  GC[nc*((j)-1)+(i)-1]
#define SigmaL_ref(i,j) SigmaL[nc*((j)-1)+(i)-1]
#define SigmaR_ref(i,j) SigmaR[nc*((j)-1)+(i)-1]
#define v1_ref(i,j)  v1[nc*((j)-1)+(i)-1] 
#define Gless_ref(i,j)  Gless[nc*((j)-1)+(i)-1]

{
  int i,j;
  int side;
  dcomplex alpha,beta;

  alpha.r=1.0;
  alpha.i=0.0;
  beta.r=0.0;
  beta.i=0.0;


  for (j=1;j<=nc;j++) {
    for (i=1;i<=nc;i++) {
      Gless_ref(i,j).r = 0.0;
      Gless_ref(i,j).i = 0.0;
    }
  }

  side=0;
  if ( w.r <= ChemP_e[side] )  {

    for (j=1;j<=nc;j++) {
      for (i=1;i<=nc;i++) {
	Gless_ref(i,j).r += 0.0;   /* Gamma_L */
	Gless_ref(i,j).i += -SigmaL_ref(i,j).i*2.0; 
      }
    }

  }
#ifdef DEBUG
  TRAN_Print2_dcomplex("self+",nc,nc,Gless);
#endif


  side=1;
  if ( w.r <= ChemP_e[side] )  {

    for (j=1;j<=nc;j++) {
      for (i=1;i<=nc;i++) {
	Gless_ref(i,j).r +=  0.0; 
	Gless_ref(i,j).i +=  -SigmaR_ref(i,j).i*2.0;   /* Gamma_R */
      }
    }

  }

#ifdef DEBUG
  TRAN_Print2_dcomplex("self+self",nc,nc,Gless);
#endif

  if (w.r > ChemP_e[0] && w.r >  ChemP_e[1] )  {
    /* then Gless =0 as it is here */
    return;
  }


  /* now Gless = Gamma_L f(w-EF_L) + Gamma_R f(w-EF_R) */

  F77_NAME(zgemm,ZGEMM)("N","N",&nc,&nc,&nc,&alpha, GC, &nc, Gless, &nc, &beta, v1, &nc);
  /*   G^R(w) * ( Gamma_L f(w-EF_L) + Gamma_R f(w-EF_R)  ) */

#ifdef DEBUG
  TRAN_Print2_dcomplex("GxSelf",nc,nc,v1);
#endif


  for (j=1;j<=nc;j++) {
    for (i=1;i<=nc;i++) {
      GC_ref(i,j).i = - GC_ref(i,j).i;   /* G^A(w) */
    }
  }

  F77_NAME(zgemm,ZGEMM)("N","N",&nc,&nc,&nc,&alpha, v1, &nc, GC, &nc, &beta, Gless, &nc);
  /* v1=  G^R(w) * ( Gamma_L f(w-EF_L) + Gamma_R f(w-EF_R)  )  G^A(w) */

  for (j=1;j<=nc;j++) {
    for (i=1;i<=nc;i++) {
      GC_ref(i,j).i = - GC_ref(i,j).i;   /* G^R(w) */
    }
  }

}