Changeset 1623 for trunk/examples/objects/app-fermi/tcl/fermi4.tcl
- Timestamp:
- Dec 7, 2009, 9:17:35 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/objects/app-fermi/tcl/fermi4.tcl
r1620 r1623 13 13 package require Rappture 14 14 15 # open the XML file containing the run parameters16 set lib [Rappture::Library] 15 # initialize the global interface 16 Rappture::Interface $argv fermi_io 17 17 18 $lib loadFile [lindex $argv 0] 19 20 if {[$lib error] != 0} { 21 # cannot open file or out of memory22 set o [ $liboutcome]18 # check the global interface for errors 19 if {[Rappture::Interface::error] != 0} { 20 # there were errors while setting up the inteface 21 # dump the traceback 22 set o [Rappture::Interface::outcome] 23 23 puts stderr [$o context] 24 24 puts stderr [$o remark] 25 exit [ $liberror]25 exit [Rappture::Interface::error] 26 26 } 27 27 28 set T [Rappture::Connect $lib "temperature"] 29 set Ef [$lib value "Ef" "units eV"] 28 # connect variables to the interface 29 # look in the global interface for an object named 30 # "temperature, convert its value to Kelvin, and 31 # store the value into the address of T. 32 # look in the global interface for an object named 33 # "Ef", convert its value to electron Volts and store 34 # the value into the address of Ef 35 # look in the global interface for an object named 36 # factorsTable and set the variable result to 37 # point to it. 38 set T [Rappture::Interface::connect "temperature" -hints {"units=K"}] 39 set Ef [Rappture::Interface::connect "Ef" -hints {"units=eV"}] 40 set result [Rappture::Interface::connect "factorsTable"] 30 41 31 if {[ $lib error!= 0]} {42 if {[Rappture::Interface::error] != 0]} { 32 43 # there were errors while retrieving input data values 33 44 # dump the tracepack 34 set o [ $liboutcome]45 set o [Rappture::Interface::outcome] 35 46 puts stderr [$o context] 36 47 puts stderr [$o remark] 37 exit [ $liberror]48 exit [Rappture::Interface::error] 38 49 } 39 50 51 # do science calculations 40 52 set nPts 200 41 53 42 set kT [expr {8.61734e-5 * [$T value "K"]}]54 set kT [expr {8.61734e-5 * $T}] 43 55 set Emin [expr {$Ef - 10*$kT}] 44 56 set Emax [expr {$Ef + 10*$kT}] … … 56 68 } 57 69 58 # do it the easy way,59 # create a plot to add to the library60 # p lot is registered with lib upon object creation61 # p 1->add(nPts,xArr,yArr,format,curveLabel,curveDesc);70 # store results in the results table 71 # add data to the table pointed to by the variable result. 72 # put the fArr data in the column named "Fermi-Dirac Factor" 73 # put the EArr data in the column named "Energy" 62 74 63 set p1 [Rappture::Plot $lib] 64 $p1 add $fArr $EArr -name "fdfactor" 65 $p1 propstr "label" "Fermi-Dirac Curve" 66 $p1 propstr "desc" "Plot of Fermi-Dirac Calculation" 67 $p1 propstr "xlabel" "Fermi-Dirac Factor" 68 $p1 propstr "ylabel" "Energy" 69 $p1 propstr "yunits" "eV" 75 $result add data "Fermi-Dirac Factor" $fArr 76 $result add data "Energy" $EArr 70 77 71 $lib result 78 Rappture::Interface::close 72 79 73 80 exit 0
Note: See TracChangeset
for help on using the changeset viewer.