source: trunk/examples/app-fermi/matlab/fermi_rp.m @ 122

Last change on this file since 122 was 122, checked in by dkearney, 19 years ago

added initial version of octave language bindings.
1) no claiming language bindings work, but will happily take credit if they do.
2) bindings are untested
3) bindings happen to work with mystery example that happens to be located in examples/app-fermi/matlab/fermi_rp.m and happens to be invokable with examples/app-fermi/matlab/tool_rp.xml
4) bindings need octave2.1-headers installed (in debian: apt-get install octave2.1-headers) to get the mkoctfile program
5) binding function names might be changing to be more discriptive and more tightly bound to either the lib or units module.
6) adjusted Makefile to add octave bindings compilation.

File size: 1.7 KB
Line 
1% ----------------------------------------------------------------------
2%  EXAMPLE: Fermi-Dirac function in Matlab.
3%
4%  This script represents a legacy application that will be left
5%  intact, but wrapped with a Rappture interface.
6%
7% ======================================================================
8%  AUTHOR:  Michael McLennan, Purdue University
9%  AUTHOR:  Derrick Kearney, Purdue University
10%  Copyright (c) 2004-2005  Purdue Research Foundation
11%
12%  See the file "license.terms" for information on usage and
13%  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14% ======================================================================
15
16% get out input file from the command line
17% open our xml input file.
18infile = sprintf("%s",argv(1,:));
19lib = rpLib(infile);
20
21% retrieve user specified data out of the input file
22% convert values to correct units.
23Ef = rpGetString(lib,"input.number(Ef).current");
24[Ef,err] = rpConvertDbl(Ef,"eV");
25T = rpGetString(lib,"input.number(temperature).current");
26[T,err] = rpConvertDbl(T,"K");
27
28% do fermi calculations (science)...
29kT = 8.61734e-5 * T;
30Emin = Ef - 10*kT;
31Emax = Ef + 10*kT;
32
33E = linspace(Emin,Emax,200);
34f = 1.0 ./ (1.0 + exp((E - Ef)/kT));
35
36% prepare out output section
37% label graphs
38rpPutString(lib,"output.curve(f12).about.label","Fermi-Dirac Factor",0);
39rpPutString(lib,"output.curve(f12).xaxis.label","Fermi-Dirac Factor",0);
40rpPutString(lib,"output.curve(f12).yaxis.label","Energy",0);
41rpPutString(lib,"output.curve(f12).yaxis.units","eV",0);
42
43for j=1:200
44  putStr = sprintf('%12g  %12g\n', f(j), E(j));
45  % put the data into the xml file
46  rpPutString(lib,"output.curve(f12).component.xy",putStr,1);
47end
48
49% signal the end of processing
50rpResult(lib);
Note: See TracBrowser for help on using the repository browser.