| 1 | ;; Fermi-Dirac function. |
|---|
| 2 | ;; Liam Healy, Sat Apr 22 2006 - 16:12 |
|---|
| 3 | ;; Time-stamp: <2008-02-16 21:37:25EST fermi-dirac.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | ;;;;**************************************************************************** |
|---|
| 9 | ;;;; Complete Fermi-Dirac Integrals |
|---|
| 10 | ;;;;**************************************************************************** |
|---|
| 11 | |
|---|
| 12 | (defmfun fermi-dirac-m1 (x) |
|---|
| 13 | "gsl_sf_fermi_dirac_m1_e" ((x :double) (ret sf-result)) |
|---|
| 14 | :documentation ; FDL |
|---|
| 15 | "The complete Fermi-Dirac integral with an index of -1. |
|---|
| 16 | This integral is given by F_{-1}(x) = e^x / (1 + e^x).") |
|---|
| 17 | |
|---|
| 18 | (defmfun fermi-dirac-0 (x) |
|---|
| 19 | "gsl_sf_fermi_dirac_0_e" ((x :double) (ret sf-result)) |
|---|
| 20 | :documentation ; FDL |
|---|
| 21 | "The complete Fermi-Dirac integral with an index of 0. |
|---|
| 22 | This integral is given by F_0(x) = \ln(1 + e^x).") |
|---|
| 23 | |
|---|
| 24 | (defmfun fermi-dirac-1 (x) |
|---|
| 25 | "gsl_sf_fermi_dirac_1_e" ((x :double) (ret sf-result)) |
|---|
| 26 | :documentation ; FDL |
|---|
| 27 | "The complete Fermi-Dirac integral with an index of 1, |
|---|
| 28 | F_1(x) = \int_0^\infty dt (t /(\exp(t-x)+1)).") |
|---|
| 29 | |
|---|
| 30 | (defmfun fermi-dirac-2 (x) |
|---|
| 31 | "gsl_sf_fermi_dirac_2_e" ((x :double) (ret sf-result)) |
|---|
| 32 | :documentation ; FDL |
|---|
| 33 | "The complete Fermi-Dirac integral with an index of 2, |
|---|
| 34 | F_2(x) = (1/2) \int_0^\infty dt (t^2 /(\exp(t-x)+1)).") |
|---|
| 35 | |
|---|
| 36 | (defmfun fermi-dirac-integral (j x) |
|---|
| 37 | "gsl_sf_fermi_dirac_int_e" ((j :int) (x :double) (ret sf-result)) |
|---|
| 38 | :documentation ; FDL |
|---|
| 39 | "The complete Fermi-Dirac integral with an integer index of j, |
|---|
| 40 | F_j(x) = (1/\Gamma(j+1)) \int_0^\infty dt (t^j /(\exp(t-x)+1)).") |
|---|
| 41 | |
|---|
| 42 | (defmfun fermi-dirac-m1/2 (x) |
|---|
| 43 | "gsl_sf_fermi_dirac_mhalf_e" ((x :double) (ret sf-result)) |
|---|
| 44 | :documentation ; FDL |
|---|
| 45 | "The complete Fermi-Dirac integral F_{-1/2}(x).") |
|---|
| 46 | |
|---|
| 47 | (defmfun fermi-dirac-1/2 (x) |
|---|
| 48 | "gsl_sf_fermi_dirac_half_e" ((x :double) (ret sf-result)) |
|---|
| 49 | :documentation ; FDL |
|---|
| 50 | "The complete Fermi-Dirac integral F_{1/2}(x).") |
|---|
| 51 | |
|---|
| 52 | (defmfun fermi-dirac-3/2 (x) |
|---|
| 53 | "gsl_sf_fermi_dirac_3half_e" ((x :double) (ret sf-result)) |
|---|
| 54 | :documentation ; FDL |
|---|
| 55 | "The complete Fermi-Dirac integral F_{3/2}(x).") |
|---|
| 56 | |
|---|
| 57 | ;;;;**************************************************************************** |
|---|
| 58 | ;;;; Incomplete Fermi-Dirac Integrals |
|---|
| 59 | ;;;;**************************************************************************** |
|---|
| 60 | |
|---|
| 61 | (defmfun fermi-dirac-inc-0 (x b) |
|---|
| 62 | "gsl_sf_fermi_dirac_inc_0_e" ((x :double) (b :double) (ret sf-result)) |
|---|
| 63 | :documentation ; FDL |
|---|
| 64 | "The incomplete Fermi-Dirac integral with an index |
|---|
| 65 | of zero, F_0(x,b) = \ln(1 + e^{b-x}) - (b-x).") |
|---|
| 66 | |
|---|
| 67 | ;;;;**************************************************************************** |
|---|
| 68 | ;;;; Examples and unit test |
|---|
| 69 | ;;;;**************************************************************************** |
|---|
| 70 | |
|---|
| 71 | #| |
|---|
| 72 | (make-tests fermi-dirac |
|---|
| 73 | (fermi-dirac-m1 0.5d0) |
|---|
| 74 | (fermi-dirac-0 0.75d0) |
|---|
| 75 | (fermi-dirac-1 -0.75d0) |
|---|
| 76 | (fermi-dirac-2 0.25d0) |
|---|
| 77 | (fermi-dirac-integral 5 12.35d0) |
|---|
| 78 | (fermi-dirac-m1/2 2.0d0) |
|---|
| 79 | (fermi-dirac-1/2 2.0d0) |
|---|
| 80 | (fermi-dirac-3/2 2.0d0) |
|---|
| 81 | (fermi-dirac-inc-0 2.0d0 0.5d0)) |
|---|
| 82 | |# |
|---|
| 83 | |
|---|
| 84 | (LISP-UNIT:DEFINE-TEST FERMI-DIRAC |
|---|
| 85 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 86 | (LIST 0.6224593312018546d0 4.040305821324309d-16) |
|---|
| 87 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-M1 0.5d0))) |
|---|
| 88 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 89 | (LIST 1.1368710061148999d0 1.6653345369377348d-16) |
|---|
| 90 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-0 0.75d0))) |
|---|
| 91 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 92 | (LIST 0.42589430612383183d0 5.594591187346375d-16) |
|---|
| 93 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-1 -0.75d0))) |
|---|
| 94 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 95 | (LIST 1.1301630162645293d0 6.04246936785309d-16) |
|---|
| 96 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-2 0.25d0))) |
|---|
| 97 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 98 | (LIST 6668.827087650077d0 2.1696654306572242d-10) |
|---|
| 99 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-INTEGRAL 5 12.35d0))) |
|---|
| 100 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 101 | (LIST 1.4642945890876293d0 4.053118505064653d-15) |
|---|
| 102 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-M1/2 2.0d0))) |
|---|
| 103 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 104 | (LIST 2.8237212774015843d0 2.909989668869937d-15) |
|---|
| 105 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-1/2 2.0d0))) |
|---|
| 106 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 107 | (LIST 4.165414459868321d0 3.666976569654393d-15) |
|---|
| 108 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-3/2 2.0d0))) |
|---|
| 109 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 110 | (LIST 1.7014132779827524d0 8.881784197001252d-16) |
|---|
| 111 | (MULTIPLE-VALUE-LIST (FERMI-DIRAC-INC-0 2.0d0 0.5d0)))) |
|---|