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

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

examples of using a view in tcl and c, update tcl and c view apis

File size: 3.0 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    #
15    # the next number is named "Ef", has units of
16    # electron Volts, default value of -5.5
17    #
18    # Rappture::Number are assumed to be an input
19    Rappture::Number "temperature" "K" 300
20    Rappture::Number "Ef" "eV" -5.5
21
22    # describe the outputs
23    # declare a table to store the outputs
24    # table is named "factorsTable".
25    # two new columns are added to the
26    # table "factorsTable". the first column is named
27    # "Fermi-Dirac Factor", a description is provided,
28    # and it has no units. the second column is named
29    # "Energy", a description is provided, and has units
30    # of electron Volts
31    # Rappture::Table is assumed to be an output
32    set results [Rappture::Table "factorsTable"]
33    $results column "Fermi-Dirac Factor" \
34                    "Plot of Fermi-Dirac Calculation"
35    $results column "Energy" \
36                    "Energy cooresponding to each fdf" \
37                    -hints {"units=eV"}
38    $results column "Fermi-Dirac Factor * 2" \
39                    "Plot of Fermi-Dirac Calculation multiplied by 2"
40    $results column "Energy * 2" \
41                    "Energy cooresponding to each fdf multiplied by 2" \
42                    -hints {"units=eV"}
43
44    # describe how the outputs should be displayed
45    # initialize a view named "fdfView", with a 1x1 layout.
46    # next, add a plot named "fdfPlot" to the view "fdfView".
47    # populate the plot with data from the table
48    # "factorsTable". Plot the column named
49    # "Fermi-Dirac Factor" vs the column named "Energy".
50    # place the plot, named fdfPlot, at position 1,1 (by default)
51    # within the view's layout.
52    # Rappture::View is assumed to be an output
53    set v [Rappture::View "fdfView"]
54    $v plot "fdfPlot" -table "factorsTable" \
55        {"Fermi-Dirac Factor" "Energy" "g:o"}
56
57    # two stacked plots in the same view
58    set v2 [Rappture::View "fdfView2"]
59    $v2 plot "fdfPlot2" -at "1,1" -table "factorsTable" \
60        {"Fermi-Dirac Factor" "Energy" "g:o"}
61    $v2 plot "fdfPlot3" -at "2,1" -table "factorsTable" \
62        {"Fermi-Dirac Factor * 2" "Energy * 2" "b-o"}
63
64    # two side by side plots in the same view
65    set v3 [Rappture::View "fdfView3"]
66    $v3 plot "fdfPlot4" -at "1,1" -table "factorsTable" \
67        {"Fermi-Dirac Factor" "Energy" "g:o"}
68    $v3 plot "fdfPlot5" -at "1,2" -table "factorsTable" \
69        {"Fermi-Dirac Factor * 2" "Energy * 2" "b-o"}
70
71    # grouped curves in one plot in a view
72    set v4 [Rappture::View "fdfView1"]
73    $v4 plot "fdfPlot6" -table "factorsTable" \
74        {"Fermi-Dirac Factor" "Energy" "g:o" \
75         "Fermi-Dirac Factor * 2" "Energy * 2" "b-o"}
Note: See TracBrowser for help on using the repository browser.