source: trunk/examples/app-fermi/tcl/fermi.tcl @ 66

Last change on this file since 66 was 66, checked in by mmc, 19 years ago

Cleaned up the app-fermi example so that it works the same way
across all of the various languages.

Added rpResult() function for reporting results. All programs
should all this to save out the XML before they exit. Also added
the fortran version rp_result().

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Fermi-Dirac function in Tcl.
3#
4#  This simple example shows how to use Rappture within a simulator
5#  written in Tcl.
6# ======================================================================
7#  AUTHOR:  Michael McLennan, Purdue University
8#  Copyright (c) 2004-2005
9#  Purdue Research Foundation, West Lafayette, IN
10# ======================================================================
11package require Rappture
12
13# open the XML file containing the run parameters
14set driver [Rappture::library [lindex $argv 0]]
15
16set T [$driver get input.(temperature).current]
17set T [Rappture::Units::convert $T -to K -units off]
18set Ef [$driver get input.(Ef).current]
19set Ef [Rappture::Units::convert $Ef -to eV -units off]
20
21set kT [expr {8.61734e-5 * $T}]
22set Emin [expr {$Ef - 10*$kT}]
23set Emax [expr {$Ef + 10*$kT}]
24
25set E $Emin
26set dE [expr {0.005*($Emax-$Emin)}]
27while {$E < $Emax} {
28    set f [expr {1.0/(1.0 + exp(($E - $Ef)/$kT))}]
29    $driver put -append yes output.curve(f12).component.xy "$f $E\n"
30    set E [expr {$E + $dE}]
31}
32
33# save the updated XML describing the run...
34Rappture::result $driver
35exit 0
Note: See TracBrowser for help on using the repository browser.