Changeset 3957 for branches/blt4/examples/objects/app-fermi/c/ex3/fermi.c
- Timestamp:
- Sep 24, 2013 4:40:58 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/examples/objects/app-fermi/c/ex3/fermi.c
r1824 r3957 1 // ---------------------------------------------------------------------- 2 // EXAMPLE: Fermi-Dirac function in C 3 // 4 // This simple example shows how to use Rappture within a simulator 5 // written in C. 6 // ====================================================================== 7 // AUTHOR: Derrick Kearney, Purdue University 8 // Copyright (c) 2005-2009 Purdue Research Foundation 9 // 10 // See the file "license.terms" for information on usage and 11 // redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. 12 // ====================================================================== 13 1 /* 2 * ---------------------------------------------------------------------- 3 * EXAMPLE: Fermi-Dirac function in C 4 * 5 * This simple example shows how to use Rappture within a simulator 6 * written in C. 7 * ====================================================================== 8 * AUTHOR: Derrick Kearney, Purdue University 9 * Copyright (c) 2004-2012 HUBzero Foundation, LLC 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 * ====================================================================== 14 */ 14 15 #include "rappture.h" 15 16 … … 23 24 int main(int argc, char * argv[]) { 24 25 25 / / declare variables to interact with Rappture26 /* declare variables to interact with Rappture */ 26 27 double T = 0.0; 27 28 double Ef = 0.0; … … 32 33 33 34 34 / / declare program variables35 /* declare program variables */ 35 36 double E = 0.0; 36 37 double dE = 0.0; … … 45 46 double fArr2[nPts]; 46 47 47 / / initialize the global interface48 /* initialize the global interface */ 48 49 Rp_InterfaceInit(argc,argv,&fermi_io); 49 50 50 / / check the global interface for errors51 /* check the global interface for errors */ 51 52 if (Rp_InterfaceError() != 0) { 52 / / there were errors while setting up the interface53 / / dump the traceback53 /* there were errors while setting up the interface */ 54 /* dump the traceback */ 54 55 Rp_Outcome *o = Rp_InterfaceOutcome(); 55 56 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 58 59 } 59 60 60 // connect variables to the interface 61 // look in the global interface for an object named 62 // "temperature", convert its value to Kelvin, and 63 // store the value into the address of T. 64 // look in the global interface for an object named 65 // "Ef", convert its value to electron Volts and store 66 // the value into the address of Ef. 67 // look in the global interface for the columns to 68 // store data. retrieve them for later use. 61 /* 62 * connect variables to the interface 63 * look in the global interface for an object named 64 * "temperature", convert its value to Kelvin, and 65 * store the value into the address of T. 66 * look in the global interface for an object named 67 * "Ef", convert its value to electron Volts and store 68 * the value into the address of Ef. 69 * look in the global interface for the columns to 70 * store data. retrieve them for later use. 71 */ 69 72 Rp_InterfaceConnect("temperature",&T,"units=K",NULL); 70 73 Rp_InterfaceConnect("Ef",&Ef,"units=eV",NULL); … … 75 78 Rp_InterfaceConnect("Energy * 2",y2,NULL); 76 79 77 / / check the global interface for errors80 /* check the global interface for errors */ 78 81 if (Rp_InterfaceError() != 0) { 79 / / there were errors while retrieving input data values80 / / dump the traceback82 /* there were errors while retrieving input data values */ 83 /* dump the traceback */ 81 84 Rp_Outcome *o = Rp_InterfaceOutcome(); 82 85 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 85 88 } 86 89 87 / / do science calculations90 /* do science calculations */ 88 91 kT = 8.61734e-5 * T; 89 92 Emin = Ef - (10*kT); … … 103 106 } 104 107 105 // store results in the results table 106 // add data to the table pointed to by the variable result. 107 // put the fArr data in the column named "Fermi-Dirac Factor" 108 // put the EArr data in the column named "Energy" 109 // 108 /* 109 * store results in the results table 110 * add data to the table pointed to by the variable result. 111 * put the fArr data in the column named "Fermi-Dirac Factor" 112 * put the EArr data in the column named "Energy" 113 */ 110 114 Rp_TableColumnStoreDouble(x1,nPts,fArr); 111 115 Rp_TableColumnStoreDouble(y1,nPts,EArr); … … 113 117 Rp_TableColumnStoreDouble(y2,nPts,EArr2); 114 118 115 // close the global interface 116 // signal to the graphical user interface that science 117 // calculations are complete and to display the data 118 // as described in the views 119 /* 120 * close the global interface 121 * signal to the graphical user interface that science 122 * calculations are complete and to display the data 123 * as described in the views 124 */ 119 125 Rp_InterfaceClose(); 120 126
Note: See TracChangeset
for help on using the changeset viewer.