Changeset 3177 for trunk/examples/objects/app-fermi
- Timestamp:
- Sep 21, 2012 10:01:16 AM (12 years ago)
- Location:
- trunk/examples/objects/app-fermi
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/objects/app-fermi/c/ex2/fermi.c
r1655 r3177 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; … … 30 31 31 32 32 / / declare program variables33 /* declare program variables */ 33 34 double E = 0.0; 34 35 double dE = 0.0; … … 42 43 double fArr[nPts]; 43 44 44 / / initialize the global interface45 /* initialize the global interface */ 45 46 Rp_InterfaceInit(argc,argv,&fermi_io); 46 47 47 / / check the global interface for errors48 /* check the global interface for errors */ 48 49 if (Rp_InterfaceError() != 0) { 49 / / there were errors while setting up the interface50 / / dump the traceback50 /* there were errors while setting up the interface */ 51 /* dump the traceback */ 51 52 Rp_Outcome *o = Rp_InterfaceOutcome(); 52 53 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 55 56 } 56 57 57 // connect variables to the interface 58 // look in the global interface for an object named 59 // "temperature", convert its value to Kelvin, and 60 // store the value into the address of T. 61 // look in the global interface for an object named 62 // "Ef", convert its value to electron Volts and store 63 // the value into the address of Ef. 64 // look in the global interface for an object named 65 // factorsTable and set the variable result to 66 // point to it. 58 /* 59 * connect variables to the interface 60 * look in the global interface for an object named 61 * "temperature", convert its value to Kelvin, and 62 * store the value into the address of T. 63 * look in the global interface for an object named 64 * "Ef", convert its value to electron Volts and store 65 * the value into the address of Ef. 66 * look in the global interface for an object named 67 * factorsTable and set the variable result to 68 * point to it. 69 */ 67 70 Rp_InterfaceConnect("temperature",&T,"units=K",NULL); 68 71 Rp_InterfaceConnect("Ef",&Ef,"units=eV",NULL); … … 70 73 Rp_InterfaceConnect("fdfPlot2",p2,NULL); 71 74 72 / / check the global interface for errors75 /* check the global interface for errors */ 73 76 if (Rp_InterfaceError() != 0) { 74 / / there were errors while retrieving input data values75 / / dump the traceback77 /* there were errors while retrieving input data values */ 78 /* dump the traceback */ 76 79 Rp_Outcome *o = Rp_InterfaceOutcome(); 77 80 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 80 83 } 81 84 82 / / do science calculations85 /* do science calculations */ 83 86 kT = 8.61734e-5 * T; 84 87 Emin = Ef - (10*kT); … … 96 99 } 97 100 98 // set up the curves for the plot by using the add command 99 // Rp_PlotAdd(plot,name,nPts,xdata,ydata,fmt); 100 // 101 // to group curves on the same plot, just keep adding curves 102 // to save space, X array values are compared between curves. 103 // the the X arrays contain the same values, we only store 104 // one version in the internal data table, otherwise a new 105 // column is created for the array. for big arrays this may take 106 // some time, we should benchmark to see if this can be done 107 // efficiently. 108 101 /* 102 * set up the curves for the plot by using the add command 103 * Rp_PlotAdd(plot,name,nPts,xdata,ydata,fmt); 104 * 105 * to group curves on the same plot, just keep adding curves 106 * to save space, X array values are compared between curves. 107 * the the X arrays contain the same values, we only store 108 * one version in the internal data table, otherwise a new 109 * column is created for the array. for big arrays this may take 110 * some time, we should benchmark to see if this can be done 111 * efficiently. 112 */ 109 113 Rp_PlotAdd(p1,"fdfCurve1",nPts,fArr,EArr,"g:o"); 110 114 … … 112 116 Rp_PlotAdd(p2,"fdfCurve3",nPts,fArr,EArr,"p--"); 113 117 114 // close the global interface 115 // signal to the graphical user interface that science 116 // calculations are complete and to display the data 117 // as described in the views 118 /* 119 * close the global interface 120 * signal to the graphical user interface that science 121 * calculations are complete and to display the data 122 * as described in the views 123 */ 118 124 Rp_InterfaceClose(); 119 125 -
trunk/examples/objects/app-fermi/c/ex3/fermi.c
r1659 r3177 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 -
trunk/examples/objects/app-fermi/c/fermi4.c
r1620 r3177 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; … … 29 30 30 31 31 / / declare program variables32 /* declare program variables */ 32 33 double E = 0.0; 33 34 double dE = 0.0; … … 40 41 double fArr[nPts]; 41 42 42 / / initialize the global interface43 /* initialize the global interface */ 43 44 Rp_InterfaceInit(argc,argv,&fermi_io); 44 45 45 / / check the global interface for errors46 /* check the global interface for errors */ 46 47 if (Rp_InterfaceError() != 0) { 47 / / there were errors while setting up the interface48 / / dump the traceback48 /* there were errors while setting up the interface */ 49 /* dump the traceback */ 49 50 Rp_Outcome *o = Rp_InterfaceOutcome(); 50 51 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 53 54 } 54 55 55 // connect variables to the interface 56 // look in the global interface for an object named 57 // "temperature", convert its value to Kelvin, and 58 // store the value into the address of T. 59 // look in the global interface for an object named 60 // "Ef", convert its value to electron Volts and store 61 // the value into the address of Ef. 62 // look in the global interface for an object named 63 // factorsTable and set the variable result to 64 // point to it. 56 /* 57 * connect variables to the interface 58 * look in the global interface for an object named 59 * "temperature", convert its value to Kelvin, and 60 * store the value into the address of T. 61 * look in the global interface for an object named 62 * "Ef", convert its value to electron Volts and store 63 * the value into the address of Ef. 64 * look in the global interface for an object named 65 * factorsTable and set the variable result to 66 * point to it. 67 */ 65 68 Rp_InterfaceConnect("temperature",&T,"units=K",NULL); 66 69 Rp_InterfaceConnect("Ef",&Ef,"units=eV",NULL); 67 70 Rp_InterfaceConnect("factorsTable",result,NULL); 68 71 69 / / check the global interface for errors72 /* check the global interface for errors */ 70 73 if (Rp_InterfaceError() != 0) { 71 / / there were errors while retrieving input data values72 / / dump the traceback74 /* there were errors while retrieving input data values */ 75 /* dump the traceback */ 73 76 Rp_Outcome *o = Rp_InterfaceOutcome(); 74 77 fprintf(stderr, "%s", Rp_OutcomeContext(o)); … … 77 80 } 78 81 79 / / do science calculations82 /* do science calculations */ 80 83 kT = 8.61734e-5 * T; 81 84 Emin = Ef - (10*kT); … … 93 96 } 94 97 95 // store results in the results table 96 // add data to the table pointed to by the variable result. 97 // put the fArr data in the column named "Fermi-Dirac Factor" 98 // put the EArr data in the column named "Energy" 99 // 98 /* 99 * store results in the results table 100 * add data to the table pointed to by the variable result. 101 * put the fArr data in the column named "Fermi-Dirac Factor" 102 * put the EArr data in the column named "Energy" 103 */ 100 104 Rp_TableAddData(result,"Fermi-Dirac Factor",nPts,fArr); 101 105 Rp_TableAddData(result,"Energy",nPts,EArr); 102 106 103 // close the global interface 104 // signal to the graphical user interface that science 105 // calculations are complete and to display the data 106 // as described in the views 107 /* 108 * close the global interface 109 * signal to the graphical user interface that science 110 * calculations are complete and to display the data 111 * as described in the views 112 */ 107 113 Rp_InterfaceClose(); 108 114 -
trunk/examples/objects/app-fermi/cpp/fermi4.cc
r1620 r3177 6 6 // ====================================================================== 7 7 // AUTHOR: Derrick Kearney, Purdue University 8 // Copyright (c) 200 5-2009 Purdue Research Foundation8 // Copyright (c) 2004-2012 HUBzero Foundation, LLC 9 9 // 10 10 // See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/fortran/fermi4.f
r1620 r3177 8 8 c AUTHOR: Michael McLennan, Purdue University 9 9 c AUTHOR: Derrick Kearney, Purdue University 10 c Copyright (c) 2004-20 08 Purdue Research Foundation10 c Copyright (c) 2004-2012 HUBzero Foundation, LLC 11 11 c 12 12 c See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/matlab/ex2/fermi.m
r1656 r3177 7 7 % ====================================================================== 8 8 % AUTHOR: Derrick Kearney, Purdue University 9 % Copyright (c) 200 5-2009 Purdue Research Foundation9 % Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 % 11 11 % See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/matlab/ex3/fermi.m
r1656 r3177 7 7 % ====================================================================== 8 8 % AUTHOR: Derrick Kearney, Purdue University 9 % Copyright (c) 200 5-2009 Purdue Research Foundation9 % Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 % 11 11 % See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/matlab/fermi4.m
r1620 r3177 7 7 % ====================================================================== 8 8 % AUTHOR: Derrick Kearney, Purdue University 9 % Copyright (c) 200 5-2009 Purdue Research Foundation9 % Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 % 11 11 % See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/octave/ex2/fermi.m
r1656 r3177 7 7 % ====================================================================== 8 8 % AUTHOR: Derrick Kearney, Purdue University 9 % Copyright (c) 200 5-2009 Purdue Research Foundation9 % Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 % 11 11 % See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/octave/ex3/fermi.m
r1656 r3177 7 7 % ====================================================================== 8 8 % AUTHOR: Derrick Kearney, Purdue University 9 % Copyright (c) 200 5-2009 Purdue Research Foundation9 % Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 % 11 11 % See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/python/ex2/fermi.py
r1656 r3177 7 7 # ====================================================================== 8 8 # AUTHOR: Derrick Kearney, Purdue University 9 # Copyright (c) 200 5-2009 Purdue Research Foundation9 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 # 11 11 # See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/python/ex3/fermi.py
r1656 r3177 7 7 # ====================================================================== 8 8 # AUTHOR: Derrick Kearney, Purdue University 9 # Copyright (c) 200 5-2009 Purdue Research Foundation9 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 # 11 11 # See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/python/fermi4.py
r1620 r3177 7 7 # ====================================================================== 8 8 # AUTHOR: Derrick Kearney, Purdue University 9 # Copyright (c) 200 5-2009 Purdue Research Foundation9 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 10 10 # 11 11 # See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/tcl/ex2/fermi.tcl
r1656 r3177 6 6 # ====================================================================== 7 7 # AUTHOR: Derrick Kearney, Purdue University 8 # Copyright (c) 200 5-2009 Purdue Research Foundation8 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 9 9 # 10 10 # See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/tcl/ex3/fermi.tcl
r1656 r3177 6 6 # ====================================================================== 7 7 # AUTHOR: Derrick Kearney, Purdue University 8 # Copyright (c) 200 5-2009 Purdue Research Foundation8 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 9 9 # 10 10 # See the file "license.terms" for information on usage and -
trunk/examples/objects/app-fermi/tcl/fermi4.tcl
r1645 r3177 6 6 # ====================================================================== 7 7 # AUTHOR: Derrick Kearney, Purdue University 8 # Copyright (c) 200 5-2009 Purdue Research Foundation8 # Copyright (c) 2004-2012 HUBzero Foundation, LLC 9 9 # 10 10 # See the file "license.terms" for information on usage and
Note: See TracChangeset
for help on using the changeset viewer.