source: trunk/examples/app-fermi/cee/original.c

Last change on this file was 5673, checked in by ldelgass, 9 years ago

Fix line endings, set eol-style to native on all C/C++ sources.

  • Property svn:eol-style set to native
File size: 1016 bytes
Line 
1/* ----------------------------------------------------------------------
2 *  EXAMPLE: Fermi-Dirac function in C.
3 * ======================================================================
4 *  AUTHOR:  Michael McLennan, Purdue University
5 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6 *
7 *  See the file "license.terms" for information on usage and
8 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 * ======================================================================
10 */
11#include <stdio.h>
12#include <math.h>
13
14int main(int argc, char *argv[]) {
15    double T, Ef, E, dE, kT, Emin, Emax, f;
16
17    printf("Enter the Fermi energy in eV:\n");
18    scanf("%lg", &Ef);
19    printf("Enter the Temperature in K:\n");
20    scanf("%lg", &T);
21
22    kT = 8.61734e-5 * T;
23    Emin = Ef - 10*kT;
24    Emax = Ef + 10*kT;
25
26    E = Emin;
27    dE = 0.005*(Emax-Emin);
28
29    while (E < Emax) {
30        f = 1.0/(1.0 + exp((E - Ef)/kT));
31        printf("%f %f\n",f, E);
32        E = E + dE;
33    }
34    return 0;
35}
Note: See TracBrowser for help on using the repository browser.