source: trunk/examples/app-fermi/fermi.py @ 10

Last change on this file since 10 was 10, checked in by mmc, 16 years ago

Added an "examples" directory with the bits and pieces that
make up app-fermi. This is very much a work in progress.

File size: 894 bytes
RevLine 
[10]1# ----------------------------------------------------------------------
2#  FERMI STATISTICS
3#
4#  This simple example shows how you can use the Rappture toolkit
5#  to handle I/O for a simple simulator--in this case, one that
6#  computes Fermi-Dirac statistics.
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2005  Purdue Research Foundation, West Lafayette, IN
10# ======================================================================
11
12from math import *
13import sys
14import Rappture
15
16import fermi_io
17from fermi_io import *
18
19# do this right at the start, to handle command line args
20Rappture.interface(sys.argv, fermi_io)
21
22kT = 8.61734e-5 * T
23Emin = Ef - 10*kT
24Emax = Ef + 10*kT
25
26E = Emin; dE = 0.005*(Emax-Emin)
27
28while E < Emax:
29    f = 1.0/(1.0 + exp((E - Ef)/kT))
30    result.append( [E,f] )
31    E += dE
Note: See TracBrowser for help on using the repository browser.