File: TRAN_Calc_OneTransmission.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 (114 lines) | stat: -rw-r--r-- 3,053 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
/**********************************************************************
  TRAN_Calc_OneTransmission.c:

  TRAN_Calc_OneTransmission.c is a subroutine to calculate the transmission.

   input: SigmaL, SigmaR, G_CC^R(w)
   assuming w= w+i delta 

   Gamma(w) = i (Sigma^R(w) - Sigma^A(w))
 
   T(w) = Trace[ Gamma_L(w) G^R(w) Gamma_R(w) G^A(w) ]

   work: v1,v2  dcomplex size=nc*nc


  Log of TRAN_Calc_OneTransmission.c:

     11/Dec/2005   Released by H.Kino

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

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

/* 
 * calculate transmission 
 *
 * input: SigmaL, SigmaR, G_CC^R(w)
 *   assuming w= w+i delta 
 *
 *   Gamma(w) = i (Sigma^R(w) - Sigma^A(w))
 * 
 *   T(w) = Trace[ Gamma_L(w) G^R(w) Gamma_R(w) G^A(w) ]
 *
 * work: v1,v2  dcomplex size=nc*nc
 */

void TRAN_Calc_OneTransmission(int nc, 
			       dcomplex *SigmaL_R,   /* at w, changed when exit */
			       dcomplex *SigmaL_A,   /* at w, changed when exit */
			       dcomplex *SigmaR_R,   /* at w, changed when exit */
			       dcomplex *SigmaR_A,   /* at w, changed when exit */
			       dcomplex *GC_R,       /* at w, changed when exit */
			       dcomplex *GC_A,       /* at w, changed when exit */
			       dcomplex *v1,         /* work */
			       dcomplex *v2,         /* work */
			       dcomplex *value       /* output, transmission */
			       )

#define SigmaL_R_ref(i,j) SigmaL_R[nc*((j)-1)+(i)-1]
#define SigmaL_A_ref(i,j) SigmaL_A[nc*((j)-1)+(i)-1]
#define SigmaR_R_ref(i,j) SigmaR_R[nc*((j)-1)+(i)-1]
#define SigmaR_A_ref(i,j) SigmaR_A[nc*((j)-1)+(i)-1]
#define GC_R_ref(i,j)     GC_R[nc*((j)-1)+(i)-1]
#define GC_A_ref(i,j)     GC_A[nc*((j)-1)+(i)-1]
#define v1_ref(i,j)       v1[nc*((j)-1)+(i)-1]

{
  int i,j;
  dcomplex alpha,beta;
  double tmpr,tmpi;

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

  /* Gamma_l = i (Sigma_l^R-Sigma_l^A) */
   
  for (j=1; j<=nc; j++) {
    for (i=1; i<=nc; i++) {

      tmpr = -(SigmaL_R_ref(i,j).i - SigmaL_A_ref(i,j).i);
      tmpi =  (SigmaL_R_ref(i,j).r - SigmaL_A_ref(i,j).r);

      SigmaL_R_ref(i,j).r = tmpr;
      SigmaL_R_ref(i,j).i = tmpi;

      tmpr = -(SigmaR_R_ref(i,j).i - SigmaR_A_ref(i,j).i);
      tmpi =  (SigmaR_R_ref(i,j).r - SigmaR_A_ref(i,j).r);

      SigmaR_R_ref(i,j).r = tmpr;
      SigmaR_R_ref(i,j).i = tmpi;
    }
  }

  /* sigma -> gamma */

  /* transmission= tr[GammaL G^R GammaR G^A] */

  /* GammaL * GR */
  F77_NAME(zgemm,ZGEMM)("N","N", &nc,&nc,&nc, &alpha, SigmaL_R, &nc, GC_R, &nc, &beta, v1, &nc );


  /* (GammaL * GR ) * GammaR */
  F77_NAME(zgemm,ZGEMM)("N","N", &nc,&nc,&nc, &alpha, v1, &nc, SigmaR_R, &nc, &beta, v2, &nc );

  /* (GammaL G^R GammaR ) * G^A */

  F77_NAME(zgemm,ZGEMM)("N","N", &nc,&nc,&nc, &alpha, v2, &nc, GC_A, &nc, &beta, v1, &nc );

  value->r=0.0; value->i = 0.0;

  /* trace */
  for (i=1;i<=nc;i++) {
    value->r += v1_ref(i,i).r;
    value->i += v1_ref(i,i).i;
  } 

}