1 | #!/bin/sh |
---|
2 | # ---------------------------------------------------------------------- |
---|
3 | # Energy Levels WRAPPER |
---|
4 | # |
---|
5 | # This wrapper computes the energy levels of an isolated molecule. |
---|
6 | # ====================================================================== |
---|
7 | # AUTHOR: Michael McLennan, Purdue University |
---|
8 | # Copyright (c) 2004 Purdue Research Foundation, West Lafayette, IN |
---|
9 | # ====================================================================== |
---|
10 | #\ |
---|
11 | exec tclsh "$0" "$*" |
---|
12 | # ---------------------------------------------------------------------- |
---|
13 | # tclsh executes everything from here on... |
---|
14 | |
---|
15 | package require Rappture |
---|
16 | |
---|
17 | # open the XML file containing the run parameters |
---|
18 | set driver [Rappture::library [lindex $argv 0]] |
---|
19 | |
---|
20 | set T [$driver get input.(temperature).current] |
---|
21 | set T [Rappture::Units::convert $T -to K -units off] |
---|
22 | set Ef [$driver get input.(Ef).current] |
---|
23 | set Ef [Rappture::Units::convert $Ef -to eV -units off] |
---|
24 | |
---|
25 | set kT [expr {8.61734e-5 * $T}] |
---|
26 | set Emin [expr {$Ef - 10*$kT}] |
---|
27 | set Emax [expr {$Ef + 10*$kT}] |
---|
28 | |
---|
29 | set xy "" |
---|
30 | set E $Emin |
---|
31 | set dE [expr {0.005*($Emax-$Emin)}] |
---|
32 | while {$E < $Emax} { |
---|
33 | set f [expr {1.0/(1.0 + exp(($E - $Ef)/$kT))}] |
---|
34 | append xy "$f $E\n" |
---|
35 | set E [expr {$E + $dE}] |
---|
36 | } |
---|
37 | |
---|
38 | $driver put output.curve(f12).about.label "Fermi-Dirac Factor" |
---|
39 | $driver put output.curve(f12).xaxis.label "Energy" |
---|
40 | $driver put output.curve(f12).xaxis.units "eV" |
---|
41 | $driver put output.curve(f12).component.xy $xy |
---|
42 | |
---|
43 | # |
---|
44 | # Save the updated XML describing the run... |
---|
45 | # Be sure to do this back in the original directory |
---|
46 | # |
---|
47 | set rfile "run[clock seconds].xml" |
---|
48 | set fid [open $rfile w] |
---|
49 | puts $fid "<?xml version=\"1.0\"?>" |
---|
50 | puts $fid [$driver xml] |
---|
51 | close $fid |
---|
52 | |
---|
53 | puts "=RAPPTURE-RUN=>$rfile" |
---|