source: trunk/examples/app-fermi/perl/fermi.pl @ 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

File size: 1.6 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Fermi-Dirac function in Perl.
3#         
4#  This simple example shows how to use Rappture within a simulator
5#  written in Perl.
6# ======================================================================
7#  AUTHOR:  Nicholas J. Kisseberth, Purdue University
8#  Copyright (c) 2006  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# ======================================================================
13
14use Rappture;
15
16# open the XML file containing the run parameters
17
18$driver = Rappture::RpLibrary->new($ARGV[0]);
19
20$Tstr = $driver->get("input.(temperature).current");
21$T = Rappture::RpUnits::convert($Tstr, "K", "off");
22
23$Efstr = $driver->get("input.(Ef).current");
24$Ef = Rappture::RpUnits::convert($Efstr, "eV", "off");
25
26$kT = 8.61734e-5 * $T;
27$Emin = $Ef - 10 * $kT;
28$Emax = $Ef + 10 * $kT;
29
30$E = $Emin;
31$dE = 0.005*($Emax - $Emin);
32
33# Label the output graph with a title, x-axis label,
34# y-axis label, y-axis units.
35
36$driver->put("output.curve(f12).about.label","Fermi-Dirac Factor",0);
37$driver->put("output.curve(f12).xaxis.label","Fermi-Dirac Factor",0);
38$driver->put("output.curve(f12).yaxis.label","Energy",0);
39$driver->put("output.curve(f12).yaxis.units","eV",0);
40
41while( $E < $Emax ) {
42        $f = 1.0 / ( 1.0 + exp(($E - $Ef) / $kT));
43    Rappture::Utils::progress((($E-$Emin)/($Emax-$Emin)*100),"Iterating");
44        $driver->put("output.curve(f12).component.xy", "$f $E\n", 1);
45        $E = $E + $dE;
46}
47
48$driver->result();
Note: See TracBrowser for help on using the repository browser.