source: trunk/examples/objects/app-fermi/c/ex3/fermi_io.c

Last change on this file was 5673, checked in by ldelgass, 9 years ago

Fix line endings, set eol-style to native on all C/C++ sources.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1#include "rappture.h"
2
3void fermi_io() {
4
5    Rp_Table *result = NULL;
6    Rp_TableColumn *x1 = NULL;
7    Rp_TableColumn *y1 = NULL;
8    Rp_TableColumn *x2 = NULL;
9    Rp_TableColumn *y2 = NULL;
10    Rp_View *v1 = NULL;
11    Rp_View *v2 = NULL;
12    Rp_View *v3 = NULL;
13
14    // assume global interface variable.
15    // newly created objects are stored in the
16    // global interface variable. if there is more
17    // than one global interface variable, the
18    // interface that should be used is specified
19    // using the Rp_???InitX version of the funtion
20    // where ??? represents the type of object the
21    // user is trying to create.
22
23    // describe the inputs
24    // declare a number named "temperature",
25    // with units of Kelvin, default value 300,
26    //
27    // the next number is named "Ef", has units of
28    // electron Volts, default value of -5.5
29    //
30    // Rp_Number is assumed to be an input
31    Rp_NumberInit("temperature","K",300);
32    Rp_NumberInit("Ef","eV",-5.5);
33
34    // describe the outputs
35    // declare a table to store the outputs
36    // table is named "factorsTable".
37    // two new columns are added to the default table
38    // the first column is named "Fermi-Dirac Factor",
39    // a description is provided, and it has no units.
40    // the second column is named "Energy", a description
41    // is provided, and has units of electron Volts
42    x1 = Rp_TableColumnInit("Fermi-Dirac Factor",
43            "Plot of Fermi-Dirac Calculation");
44    y1 = Rp_TableColumnInit("Energy",
45            "Energy cooresponding to each fdf");
46    Rp_TableColumnHint(y1,"units","eV");
47
48    x2 = Rp_TableColumnInit("Fermi-Dirac Factor * 2",
49            "Plot of Fermi-Dirac Calculation multiplied by 2");
50    y2 = Rp_TableColumnInit("Energy * 2",
51            "Energy cooresponding to each fdf multiplied by 2");
52    Rp_TableColumnHint(y2,"units","eV");
53
54    // describe how the outputs should be displayed
55    // initialize a view named "fdfView", with a 1x1 layout.
56    // next, add a plot named "fdfPlot" to the view "fdfView".
57    // populate the plot with data from the table
58    // "factorsTable". Plot the column named
59    // "Fermi-Dirac Factor" vs the column named "Energy".
60    // place the plot, named fdfPlot, at position 1x1 (by default)
61    // within the view's layout.
62    // Rp_View is assumed to be an output
63    v1 = Rp_ViewInit("fdfView");
64    Rp_ViewPlot(v1,"fdfPlot",1,1,x1,y1,"g:o");
65
66    // two stacked plots in the same view
67    v2 = Rp_ViewInit("fdfView2");
68    Rp_ViewPlot(v2,"fdfPlot2",1,1,x1,y1,"g:o");
69    Rp_ViewPlot(v2,"fdfPlot3",2,1,x2,y2,"b-o");
70
71    // two side by side plots in the same view
72    v3 = Rp_ViewInit("fdfView3");
73    Rp_ViewPlot(v3,"fdfPlot4",1,1,x1,y1,"g:o");
74    Rp_ViewPlot(v3,"fdfPlot5",1,2,x2,y2,"b-o");
75
76    // grouped curves in one plot in a view
77    // plots hold same location in the view
78    v4 = Rp_ViewInit("fdfView4");
79    Rp_ViewPlot(v4,"fdfPlot6",1,1,x1,y1,"g:o");
80    Rp_ViewPlot(v4,"fdfPlot7",1,1,x2,y2,"b-o");
81}
Note: See TracBrowser for help on using the repository browser.