费米分布函数是一种概率分布,它是由美国物理学家费米(Enrico Fermi)提出的。
using System;
namespace Legalsoft.Truffer
{
public class Fermi : UniVarRealValueFun, RealValueFun
{
private double kk { get; set; }
private double etaa { get; set; }
private double thetaa { get; set; }
public double get(double t)
{
double x = Math.Exp(t - Math.Exp(-t));
return x * (1.0 + Math.Exp(-t)) * Math.Pow(x, kk) * Math.Sqrt(1.0 + thetaa * 0.5 * x) / (Math.Exp(x - etaa) + 1.0);
}
public double funk(double t)
{
return get(t);
}
public double funk(double[] x)
{
return get(x[0], x[1]);
}
public double get(double x, double del)
{
if (x < 1.0)
{
return Math.Pow(del, kk) * Math.Sqrt(1.0 + thetaa * 0.5 * x) / (Math.Exp(x - etaa) + 1.0);
}
else
{
return Math.Pow(x, kk) * Math.Sqrt(1.0 + thetaa * 0.5 * x) / (Math.Exp(x - etaa) + 1.0);
}
}
public double val(double k, double eta, double theta)
{
const double EPS = 3.0e-9;
const int NMAX = 11;
double olds = 0.0;
kk = k;
etaa = eta;
thetaa = theta;
if (eta <= 15.0)
{
double a = -4.5;
double b = 5.0;
Trapzd s = new Trapzd(this, a, b);
for (int i = 1; i <= NMAX; i++)
{
double sum = s.next();
if (i > 3)
{
if (Math.Abs(sum - olds) <= EPS * Math.Abs(olds))
{
return sum;
}
}
olds = sum;
}
}
else
{
double a = 0.0;
double b = eta;
double aa = eta;
double bb = eta + 60.0;
double hmax = 4.3;
DErule s = new DErule(this, a, b, hmax);
DErule ss = new DErule(this, aa, bb, hmax);
for (int i = 1; i <= NMAX; i++)
{
double sum = s.next() + ss.next();
if (i > 3)
{
if (Math.Abs(sum - olds) <= EPS * Math.Abs(olds))
{
return sum;
}
}
olds = sum;
}
}
throw new Exception("no convergence in fermi");
}
}
}