source: trunk/examples/app-fermi/matlab/fermi.tcl @ 115

Last change on this file since 115 was 115, checked in by mmc, 18 years ago

Updated all copyright notices.

File size: 1.5 KB
Line 
1# ----------------------------------------------------------------------
2#  EXAMPLE: Fermi-Dirac function in Tcl.
3#
4#  This simple example shows how to use Rappture to wrap up a
5#  simulator written in Matlab or some other language.
6#
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2005  Purdue Research Foundation
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# ======================================================================
14package require Rappture
15
16# open the XML file containing the run parameters
17set driver [Rappture::library [lindex $argv 0]]
18
19set Ef [$driver get input.(Ef).current]
20set Ef [Rappture::Units::convert $Ef -to eV -units off]
21set T [$driver get input.(temperature).current]
22set T [Rappture::Units::convert $T -to K -units off]
23
24set fid [open "indeck" w]
25puts $fid $Ef
26puts $fid $T
27close $fid
28
29set status [catch {Rappture::exec octave --silent fermi.m < indeck} out]
30$driver put output.log $out
31
32if {$status == 0} {
33    set fid [open out.dat r]
34    set info [read $fid]
35    close $fid
36
37    # skip over the first 4 header lines
38    foreach line [lrange [split $info \n] 5 end] {
39        if {[scan $line {%g %g} f E] == 2} {
40            $driver put -append yes output.curve(f12).component.xy "$f $E\n"
41        }
42    }
43}
44
45file delete -force indeck out.dat
46
47# save the updated XML describing the run...
48Rappture::result $driver $status
49exit 0
Note: See TracBrowser for help on using the repository browser.