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: Michael McLennan, Purdue University |
---|
9 | % AUTHOR: Derrick Kearney, Purdue University |
---|
10 | % Copyright (c) 2004-2007 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 | % invoke this script with the following command: |
---|
18 | % matlab -nodisplay -r infile=\'driver1234.xml\',fermi |
---|
19 | % the above command sets variable infile to the name 'driver1234.xml' |
---|
20 | |
---|
21 | % infile = 'driver31619.xml' |
---|
22 | |
---|
23 | % open our xml input file. |
---|
24 | lib = rpLib(infile); |
---|
25 | |
---|
26 | % retrieve user specified data out of the input file |
---|
27 | % convert values to correct units. |
---|
28 | Ef = rpLibGetString(lib,'input.number(Ef).current'); |
---|
29 | [Ef,err] = rpUnitsConvertDbl(Ef,'eV'); |
---|
30 | T = rpLibGetString(lib,'input.number(temperature).current'); |
---|
31 | [T,err] = rpUnitsConvertDbl(T,'K'); |
---|
32 | |
---|
33 | % do fermi calculations (science)... |
---|
34 | kT = 8.61734e-5 * T; |
---|
35 | Emin = Ef - 10*kT; |
---|
36 | Emax = Ef + 10*kT; |
---|
37 | |
---|
38 | E = linspace(Emin,Emax,200); |
---|
39 | f = 1.0 ./ (1.0 + exp((E - Ef)/kT)); |
---|
40 | |
---|
41 | % prepare out output section |
---|
42 | % label graphs |
---|
43 | rpLibPutString(lib,'output.curve(f12).about.label','Fermi-Dirac Factor',0); |
---|
44 | rpLibPutString(lib,'output.curve(f12).xaxis.label','Fermi-Dirac Factor',0); |
---|
45 | rpLibPutString(lib,'output.curve(f12).yaxis.label','Energy',0); |
---|
46 | rpLibPutString(lib,'output.curve(f12).yaxis.units','eV',0); |
---|
47 | |
---|
48 | for j=1:200 |
---|
49 | rpUtilsProgress((j/200*100),'Iterating'); |
---|
50 | putStr = sprintf('%12g %12g\n', f(j), E(j)); |
---|
51 | % put the data into the xml file |
---|
52 | rpLibPutString(lib,'output.curve(f12).component.xy',putStr,1); |
---|
53 | end |
---|
54 | |
---|
55 | % signal the end of processing |
---|
56 | rpLibResult(lib); |
---|
57 | |
---|
58 | quit; |
---|