source: trunk/examples/app-fermi/python/fermi.py @ 665

Last change on this file since 665 was 665, checked in by dkearney, 17 years ago

Updates to Rappture::Utils::progress for all languages
removed the dependancy on Rappture.Units from within number.py, it should only depend on Rappture which will include Rappture.Units
added Rappture.Units as a module to load when people import Rappture in python.
added -V pbs variable to queue.py to include qsub environment variables in the submitted job.
updated setup.py.in to install Rappture.Utils
added progress bar to all app-fermi examples showing how to use the Rappture::Utils::progress function in all languages.
added destructor definitions to Node classes in src2/core

  • Property svn:keywords set to Date Rev URL
File size: 1.8 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Fermi-Dirac function in Python.
3#
4#  This simple example shows how to use Rappture within a simulator
5#  written in Python.
6# ======================================================================
7#  AUTHOR:  Michael McLennan, Purdue University
8#  Copyright (c) 2004-2005  Purdue Research Foundation
9#
10#  See the file "license.terms" for information on usage and
11#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12# ======================================================================
13import Rappture
14import sys
15from math import *
16
17# open the XML file containing the run parameters
18driver = Rappture.library(sys.argv[1])
19
20driver.put("tool.repository.application.date", "$Date: 2007-04-07 01:06:24 +0000 (Sat, 07 Apr 2007) $")
21driver.put("tool.repository.application.rev", "$Rev: 665 $")
22driver.put("tool.repository.application.url", "$URL: trunk/examples/app-fermi/python/fermi.py $")
23
24Tstr = driver.get('input.(temperature).current')
25T = Rappture.Units.convert(Tstr, to="K", units="off")
26
27Efstr = driver.get('input.(Ef).current')
28Ef = Rappture.Units.convert(Efstr, to="eV", units="off")
29
30kT = 8.61734e-5 * T
31Emin = Ef - 10*kT
32Emax = Ef + 10*kT
33
34E = Emin
35dE = 0.005*(Emax-Emin)
36
37# Label the output graph with a title, x-axis label,
38# y-axis label, and y-axis units
39driver.put('output.curve(f12).about.label','Fermi-Dirac Factor',append=0)
40driver.put('output.curve(f12).xaxis.label','Fermi-Dirac Factor',append=0)
41driver.put('output.curve(f12).yaxis.label','Energy',append=0)
42driver.put('output.curve(f12).yaxis.units','eV',append=0)
43
44while E < Emax:
45    f = 1.0/(1.0 + exp((E - Ef)/kT))
46    line = "%g %g\n" % (f, E)
47    Rappture.Utils.progress(((E-Emin)/(Emax-Emin)*100),"Iterating")
48    driver.put('output.curve(f12).component.xy', line, append=1)
49    E = E + dE
50
51Rappture.result(driver)
52sys.exit()
Note: See TracBrowser for help on using the repository browser.