File: Tetrahedron_Blochl.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 (168 lines) | stat: -rw-r--r-- 3,783 bytes parent folder | download | duplicates (4)
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
#include <stdio.h>

/*****************************************************************
   Improved analytical tetrahedron method 
   Idea: PRB 49, 16223 (1994), by Bloechl, Jepsen and Andersen 
*******************************************************************/

/*
  input e[0:3],n
  output: e[0]<e[1]<e[2]<e[4]
*/
void OrderE0(double *e, int n)
{

 int i,j;
 double t;

 for (i=0;i<n-1;i++) {
   for (j=i;j<n;j++) {
      if (e[j]<e[i]) {
          t = e[j];
          e[j]=e[i];
          e[i]=t;

      }
   }
 }
}



/*
  input e[0:3],a[0:3],n
  output: e[0]<e[1]<e[2]<e[4] 
          a[] is also interchanged corresponding to e[]:
*/
void OrderE(double *e,double *a, int n)
{

 int i,j;
 double t;

 for (i=0;i<n-1;i++) {
   for (j=i;j<n;j++) {
      if (e[j]<e[i]) {
          t = e[j];
          e[j]=e[i];
          e[i]=t;

          t = a[j];
          a[j]=a[i];
          a[i]=t;

      }
   }
 }
}


/*
 density of states 
 Appendix C of the paper

   assume that et[] is orderd 

   input et[0:3], *e
   output dos
*/

void ATM_Dos(double *et, double *e, double *dos)
{
    double e21, e31, e32, e41, e42, e43;
    double e1,e2,e4;

    /* Parameter adjustments */
    --et;
#if 0
    printf("ATM: %lf %lf %lf %lf %lf\n",*e,et[1],et[2],et[3],et[4]);
#endif

    e21 = et[2] - et[1];
    e31 = et[3] - et[1];
    e32 = et[3] - et[2];
    e41 = et[4] - et[1];
    e42 = et[4] - et[2];
    e43 = et[4] - et[3];
    if (*e < et[1]) {
        *dos = 0.;
    } else if (*e > et[1] && *e < et[2]) {
        e1=(*e - et[1]);
        *dos =  3.0 * e1*e1 / (e21 * e31 * e41);
    } else if (*e > et[2] && *e < et[3]) {
        e2=(*e - et[2]);
        *dos = (e21 * 3. + e2 * 6. - (e31 + e42) * 3. * e2 * e2 
                  / (e32 * e42)) / (e31 * e41);
    } else if (*e > et[3] && *e < et[4]) {
        e4= (et[4] - *e);
        *dos =  3.0* e4*e4 / (e41 * e42 * e43);
    } else if (*e > et[4]) {
        *dos = 0.;
    }
#if 0
    printf("ATM_Dos: %lf %lf %lf %lf %lf->%lf\n",*e, et[1],et[2],et[3],et[4],*dos);
#endif

}


/* 
 Appendix B of the paper
 In the Appendix B, integrated weight is written, differenciate it. 
  assume that et[] is ordered. 

  input et[0:3], at[0:3],*e
  output spectrum

  <at> = sum_i at[i] w[i]
  w[i] is a function of et[i]
  An integrated w[i]  is written in the paper. 

*/
void ATM_Spectrum(double *et,double *at, double *e, double *spectrum)
{
     double a21, a31, a32, a41;
     double e21, e31, e32, e41, e42, e43;
     double a42, a43;
     double dos;

    /* Parameter adjustments , ---  f2c technique */
    --at;

    ATM_Dos(et, e, &dos);
    --et; 
#if 0
    printf("DOS-> %lf %lf\n",*e,dos);
    printf("%lf %lf %lf %lf\n",et[1],et[2],et[3],et[4]);
#endif
    e21 = et[2] - et[1];
    e31 = et[3] - et[1];
    e32 = et[3] - et[2];
    e41 = et[4] - et[1];
    e42 = et[4] - et[2];
    e43 = et[4] - et[3];
    a21 = at[2] - at[1];
    a31 = at[3] - at[1];
    a32 = at[3] - at[2];
    a41 = at[4] - at[1];
    a42 = at[4] - at[2];
    a43 = at[4] - at[3];
    if (*e < et[1]) {
        *spectrum = 0.;
    } else if (*e > et[1] && *e < et[2]) {
        *spectrum = dos * (at[1] + (*e - et[1]) * .33333333333333331 * (a21 / 
                e21 + a31 / e31 + a41 / e41));
    } else if (*e > et[2] && *e < et[3]) {
        *spectrum = dos * (at[1] + (a21 + e21 * a31 / e31 + e21 * a41 / e41) *
                 .33333333333333331 * (et[3] - *e) / e32 + (at[4] - at[1] - (
                e43 * a41 / e41 + e43 * a42 / e42 + a43) * .33333333333333331)
                 * (*e - et[2]) / e32);
    } else if (*e > et[3] && *e < et[4]) {
        *spectrum = dos * (at[4] + (*e - et[4]) * .33333333333333331 * (a41 / 
                e41 + a42 / e42 + a43 / e43));
    } else if (*e > et[4]) {
        *spectrum = 0.;
    }

}