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

Last change on this file since 555 was 555, checked in by dkearney, 15 years ago

updated examples removing output sections from tool.xml files and making the example code generate the output section using the rappture library put command. this change is made in the example files to help curb people from defining output sections in their tool.xml files. the output sections should really be created inside the program when the output data is ready to be entered.

  • Property svn:executable set to *
File size: 1.6 KB
1# ----------------------------------------------------------------------
2#  EXAMPLE: Fermi-Dirac function in Tcl.
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  Purdue Research Foundation
10#  See the file "license.terms" for information on usage and
11#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12# ======================================================================
13package require Rappture
15# open the XML file containing the run parameters
16set driver [Rappture::library [lindex $argv 0]]
18set T [$driver get input.(temperature).current]
19set T [Rappture::Units::convert $T -to K -units off]
20set Ef [$driver get input.(Ef).current]
21set Ef [Rappture::Units::convert $Ef -to eV -units off]
23set kT [expr {8.61734e-5 * $T}]
24set Emin [expr {$Ef - 10*$kT}]
25set Emax [expr {$Ef + 10*$kT}]
27set E $Emin
28set dE [expr {0.005*($Emax-$Emin)}]
30# Label output graph with title, x-axis label,
31# y-axis lable, and y-axis units
32$driver put -append no output.curve(f12).about.label "Fermi-Dirac Factor"
33$driver put -append no output.curve(f12).xaxis.label "Fermi-Dirac Factor"
34$driver put -append no output.curve(f12).yaxis.label "Energy"
35$driver put -append no output.curve(f12).yaxis.units "eV"
37while {$E < $Emax} {
38    set f [expr {1.0/(1.0 + exp(($E - $Ef)/$kT))}]
39    $driver put -append yes output.curve(f12).component.xy "$f $E\n"
40    set E [expr {$E + $dE}]
43# save the updated XML describing the run...
44Rappture::result $driver
45exit 0
Note: See TracBrowser for help on using the repository browser.