1 | # ---------------------------------------------------------------------- |
---|
2 | # EXAMPLE: Rappture <energies> elements |
---|
3 | # ====================================================================== |
---|
4 | # AUTHOR: Michael McLennan, Purdue University |
---|
5 | # Copyright (c) 2004-2012 HUBzero Foundation, LLC |
---|
6 | # |
---|
7 | # See the file "license.terms" for information on usage and |
---|
8 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
9 | # ====================================================================== |
---|
10 | package require Rappture |
---|
11 | |
---|
12 | # open the XML file containing the run parameters |
---|
13 | set driver [Rappture::library [lindex $argv 0]] |
---|
14 | |
---|
15 | set L [$driver get input.number(L).current] |
---|
16 | set L [Rappture::Units::convert $L -to "m" -units off] |
---|
17 | |
---|
18 | set emass [$driver get input.number(emass).current] |
---|
19 | set m [expr {$emass*9.11e-31}] ;# kg |
---|
20 | |
---|
21 | set h 4.13566743e-15 ;# in eVs |
---|
22 | set J2eV 6.241506363e17 |
---|
23 | |
---|
24 | set nhomo [expr {round(rand()*19+1)}] |
---|
25 | |
---|
26 | $driver put output.table.about.label "Energy Levels" |
---|
27 | $driver put output.table.column(labels).label "Name" |
---|
28 | $driver put output.table.column(energies).label "Energy" |
---|
29 | $driver put output.table.column(energies).units "eV" |
---|
30 | for {set n 1} {$n <= 20} {incr n} { |
---|
31 | set E [expr {$n*$n*$h*$h/(8.0*$m*$L*$L*$J2eV)}] ;# in eV |
---|
32 | set label [expr {($n == $nhomo) ? "HOMO" : $n}] |
---|
33 | |
---|
34 | $driver put -append yes output.table.data [format "%s %.3g\n" $label $E] |
---|
35 | } |
---|
36 | |
---|
37 | # save the updated XML describing the run... |
---|
38 | Rappture::result $driver |
---|
39 | exit 0 |
---|