source: trunk/examples/objects/app-fermi/octave/ex3/fermi.m @ 3177

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 2.8 KB
Line 
1% ----------------------------------------------------------------------
2%  EXAMPLE: Fermi-Dirac function in Octave.
3%
4%  This script represents a newly written application with rappture
5%  bindings and interface.
6%
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
15function fermi4(argv)
16
17% declare variables to interact with Rappture
18T       = 0.0;
19Ef      = 0.0;
20result  = 0;
21
22% declare program variables
23E       = 0.0;
24dE      = 0.0;
25kT      = 0.0;
26Emin    = 0.0;
27Emax    = 0.0;
28f       = 0.0;
29nPts    = 200;
30
31% initialize the global interface
32Rp_InterfaceInit(argv,@fermi_io);
33
34% check that global interface for errors
35if (Rp_InterfaceError() != 0)) {
36    % there were errors while setting up the interface
37    % dump the traceback
38    o = Rp_InterfaceOutcome();
39    fprintf(2, '%s', Rp_OutcomeContext(o));
40    fprintf(2, '%s', Rp_OutcomeRemark(o));
41    return(Rp_InterfaceError());
42}
43
44% connect variables to the interface
45% look in the global interface for an object named
46% 'temperature', convert its value to Kelvin, and
47% store the value into the variable T.
48% look in the global interface for an object named
49% 'Ef', convert its value to electron Volts and store
50% the value into the variable Ef.
51% look in the global interface for the columns to
52% store data. retrieve them for later use.
53T = Rp_InterfaceConnect('temperature','units=K');
54Ef = Rp_InterfaceConnect('Ef','units=eV');
55
56x1 = Rp_InterfaceConnect('Fermi-Dirac Factor');
57y1 = Rp_InterfaceConnect('Energy');
58x2 = Rp_InterfaceConnect('Fermi-Dirac Factor * 2');
59y2 = Rp_InterfaceConnect('Energy * 2');
60
61% check the global interface for errors
62if (Rp_InterfaceError() != 0) {
63    % there were errors while retrieving input data values
64    % dump the tracepack
65    o = Rp_InterfaceOutcome();
66    fprintf(stderr, '%s', Rp_OutcomeContext(o));
67    fprintf(stderr, '%s', Rp_OutcomeRemark(o));
68    return(Rp_InterfaceError());
69}
70
71% do fermi calculations (science)...
72kT = 8.61734e-5 * T;
73Emin = Ef - (10*kT);
74Emax = Ef + (10*kT);
75
76% store results in the results table
77% add data to the table pointed to by the variable result.
78% put the fArr data in the column named "Fermi-Dirac Factor"
79% put the EArr data in the column named "Energy"
80
81Rp_TableColumnStore(x1,fArr);
82Rp_TableColumnStore(y1,EArr);
83Rp_TableColumnStore(x2,fArr2);
84Rp_TableColumnStore(y2,EArr2);
85
86% close the global interface
87% signal to the graphical user interface that science
88% calculations are complete and to display the data
89% as described in the views
90
91Rp_InterfaceClose();
92
93return 0;
Note: See TracBrowser for help on using the repository browser.