-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathfermi.h
executable file
·60 lines (57 loc) · 1.28 KB
/
fermi.h
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
struct Fermi {
Doub kk,etaa,thetaa;
Doub operator() (const Doub t);
Doub operator() (const Doub x, const Doub del);
Doub val(const Doub k, const Doub eta, const Doub theta);
};
Doub Fermi::operator() (const Doub t) {
Doub x;
x=exp(t-exp(-t));
return x*(1.0+exp(-t))*pow(x,kk)*sqrt(1.0+thetaa*0.5*x)/
(exp(x-etaa)+1.0);
}
Doub Fermi::operator() (const Doub x, const Doub del) {
if (x < 1.0)
return pow(del,kk)*sqrt(1.0+thetaa*0.5*x)/(exp(x-etaa)+1.0);
else
return pow(x,kk)*sqrt(1.0+thetaa*0.5*x)/(exp(x-etaa)+1.0);
}
Doub Fermi::val(const Doub k, const Doub eta, const Doub theta)
{
const Doub EPS=3.0e-9;
const Int NMAX=11;
Doub a,aa,b,bb,hmax,olds,sum;
kk=k;
etaa=eta;
thetaa=theta;
if (eta <= 15.0) {
a=-4.5;
b=5.0;
Trapzd<Fermi> s(*this,a,b);
for (Int i=1;i<=NMAX;i++) {
sum=s.next();
if (i > 3)
if (abs(sum-olds) <= EPS*abs(olds))
return sum;
olds=sum;
}
}
else {
a=0.0;
b=eta;
aa=eta;
bb=eta+60.0;
hmax=4.3;
DErule<Fermi> s(*this,a,b,hmax);
DErule<Fermi> ss(*this,aa,bb,hmax);
for (Int i=1;i<=NMAX;i++) {
sum=s.next()+ss.next();
if (i > 3)
if (abs(sum-olds) <= EPS*abs(olds))
return sum;
olds=sum;
}
}
throw("no convergence in fermi");
return 0.0;
}