1 | # ---------------------------------------------------------------------- |
---|
2 | # This is a modifed version of the Tcl app-fermi example which has been |
---|
3 | # purposely broken for testing the Rappture regression testing tool. |
---|
4 | # Incorrect results are given whenever temperature is set to 300K (room |
---|
5 | # temperature), and an error is thrown when the temperature is 4.2K |
---|
6 | # AND the energy level is 1eV. |
---|
7 | # ====================================================================== |
---|
8 | # AUTHOR: Ben Rafferty, Purdue University |
---|
9 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and |
---|
12 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | # ====================================================================== |
---|
14 | package require Rappture |
---|
15 | |
---|
16 | # open the XML file containing the run parameters |
---|
17 | set driver [Rappture::library [lindex $argv 0]] |
---|
18 | |
---|
19 | set T [$driver get input.(temperature).current] |
---|
20 | set T [Rappture::Units::convert $T -to K -units off] |
---|
21 | set Ef [$driver get input.(Ef).current] |
---|
22 | set Ef [Rappture::Units::convert $Ef -to eV -units off] |
---|
23 | |
---|
24 | set kT [expr {8.61734e-5 * $T}] |
---|
25 | set Emin [expr {$Ef - 10*$kT}] |
---|
26 | set Emax [expr {$Ef + 10*$kT}] |
---|
27 | |
---|
28 | set E $Emin |
---|
29 | set dE [expr {0.005*($Emax-$Emin)}] |
---|
30 | |
---|
31 | # take a while and give some output along the way |
---|
32 | Rappture::Utils::progress 0 -mesg "Starting..." |
---|
33 | puts "Taking a while to run..." |
---|
34 | after 1000 |
---|
35 | puts "making some progress" |
---|
36 | after 2000 |
---|
37 | puts "done" |
---|
38 | Rappture::Utils::progress 10 -mesg "Starting, for real now." |
---|
39 | after 1000 |
---|
40 | |
---|
41 | # Label output graph with title, x-axis label, |
---|
42 | # y-axis lable, and y-axis units |
---|
43 | $driver put -append no output.curve(f12).about.label "Fermi-Dirac Factor" |
---|
44 | $driver put -append no output.curve(f12).xaxis.label "Fermi-Dirac Factor" |
---|
45 | $driver put -append no output.curve(f12).yaxis.label "Energy" |
---|
46 | $driver put -append no output.curve(f12).yaxis.units "eV" |
---|
47 | |
---|
48 | # Error if T = 4.2 and Ef = 1eV |
---|
49 | if {$T == 4.2 && $Ef == 1} { |
---|
50 | error "Purposely throwing an error for this input combination." |
---|
51 | } |
---|
52 | |
---|
53 | # Produce bad results whenever T = 300K |
---|
54 | if {$T == 300} { |
---|
55 | set kT [expr $kT * 2] |
---|
56 | } |
---|
57 | |
---|
58 | while {$E < $Emax} { |
---|
59 | set f [expr {1.0/(1.0 + exp(($E - $Ef)/$kT))}] |
---|
60 | set progress [expr {(($E - $Emin)/($Emax - $Emin)*100)}] |
---|
61 | Rappture::Utils::progress $progress -mesg "Iterating" |
---|
62 | $driver put -append yes output.curve(f12).component.xy "$f $E\n" |
---|
63 | set E [expr {$E + $dE}] |
---|
64 | } |
---|
65 | |
---|
66 | # save the updated XML describing the run... |
---|
67 | Rappture::result $driver |
---|
68 | exit 0 |
---|