source: trunk/examples/objects/app-fermi/tcl/fermi_io.tcl @ 1623

Last change on this file since 1623 was 1623, checked in by dkearney, 11 years ago

updating objects tcl bindings example

File size: 2.4 KB
Line 
1proc fermi_io {
2
3    # assume global interface variable.
4    # newly created objects are stored in the
5    # global interface variable. if there is more
6    # than one global interface variable, the
7    # interface that should be used is specified
8    # using an alternative version of the object constructor
9    # that supports an interface argument.
10
11    # describe the inputs
12    # declare a number named "temperature",
13    # with units of Kelvin, default value 300,
14    # and specify that it is only an input
15    # the next number is named "Ef", has units of
16    # electron Volts, default value of -5.5 and
17    # is also only an input value
18    Rappture::Number "temperature" "K" 300 RP_VAR_INPUT
19    Rappture::Number "Ef" "eV" -5.5 RP_VAR_INPUT
20
21    # describe the outputs
22    # declare a table to store the outputs
23    # table is named "factorsTable" and is declared as
24    # an output only object. two new columns are added to the
25    # table "factorsTable". the first column is named
26    # "Fermi-Dirac Factor", a description is provided,
27    # and it has no units. the second column is named
28    # "Energy", a description is provided, and has units
29    # of electron Volts
30    set results [Rappture::Table "factorsTable" RP_VAR_OUTPUT]
31    $results new column "Fermi-Dirac Factor" \
32                      "Plot of Fermi-Dirac Calculation"
33    $results new column "Energy" \
34                      "Energy cooresponding to each fdf" \
35                      -hints {"units=eV"}
36
37    # describe how the outputs shoud be displayed
38    # initialize a view named "fdfView", specifying it
39    # as an output only object with a 1x1 view layout.
40    # next, add a plot named "fdfPlot" to the view fdfView".
41    # populate the plot with data from the table
42    # "fermifactors". Plot the column named
43    # "Fermi-Dirac Factor" vs the column named "Energy".
44    # place the plot, named fdfPlot, at position 1x1 within
45    # the view's layout.
46    set v [Rappture::View "fdfView" -flags RP_VAR_OUTPUT|RP_VIEW_1X1]
47    $v plot table "fdfPlot" "factorsTable" \
48                  "Fermi-Dirac Factor" "Energy" \
49                   -hints {"position=1x1"}
50
51    # add another curve to the "fdfPlot" plot.
52    # plot the column named "Fermi-Dirac Factor2" vs
53    # the column named "Energy"
54    # $v plot table "fdfPlot" "factorsTable" \
55    #               "Fermi-Dirac Factor2" "Energy" \
56    #               -hints {"position=1x1"}
57}
Note: See TracBrowser for help on using the repository browser.