source: branches/nanovis2/examples/app-fermi/2.0/fermi.py @ 3305

Last change on this file since 3305 was 3305, checked in by ldelgass, 12 years ago

sync with trunk

File size: 1.3 KB
Line 
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# ======================================================================
9#  AUTHOR:  Michael McLennan, Purdue University
10#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
11#
12#  See the file "license.terms" for information on usage and
13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14# ======================================================================
15
16from math import *
17import sys
18import Rappture
19
20import fermi_io
21from fermi_io import *
22
23# do this right at the start, to handle command line args
24Rappture.interface(sys.argv, fermi_io)
25
26kT = 8.61734e-5 * T
27Emin = Ef - 10*kT
28Emax = Ef + 10*kT
29
30E = Emin; dE = 0.005*(Emax-Emin)
31
32Rappture.driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor")
33Rappture.driver.put("output.curve(f12).xaxis.label", "Energy")
34Rappture.driver.put("output.curve(f12).xaxis.units", "eV")
35path = "output.curve(f12).component.xy"
36
37while E < Emax:
38    f = 1.0/(1.0 + exp((E - Ef)/kT))
39    # result.append( [E,f] )
40    value = "%s  %s\n" % (f,E)
41    Rappture.driver.put(path,value,append=1)
42    E += dE
43
Note: See TracBrowser for help on using the repository browser.