Changeset 1727 for trunk/examples/app-fermi/java
- Timestamp:
- May 20, 2010, 2:13:17 PM (14 years ago)
- Location:
- trunk/examples/app-fermi/java
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/app-fermi/java/Fermi.java
r1722 r1727 1 /* 2 * EXAMPLE: Fermi-Dirac function in Java. 3 * 4 * This simple example shows how to use Rappture within a simulator 5 * written in Java. 6 * ====================================================================== 7 * AUTHOR: Ben Rafferty, Purdue University 8 * Copyright (c) 2010 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 14 2 15 class Fermi{ … … 4 17 public static void main(String args[]){ 5 18 19 // create a rappture library from the file path 6 20 rappture.Library driver = new rappture.Library(args[0]); 7 21 22 // read the input values and convert to correct units 8 23 String Tstr = driver.get("input.number(temperature).current"); 9 24 double T = Double.valueOf(rappture.Units.convert(Tstr, "K", false)); 10 11 25 String Efstr = driver.get("input.number(Ef).current"); 12 26 double Ef = Double.valueOf(rappture.Units.convert(Efstr, "eV", false)); 13 27 28 // Set the energy range and step size 14 29 double kT = 8.61734E-5 * T; 15 30 double Emin = Ef - 10*kT; 16 31 double Emax = Ef + 10*kT; 17 18 32 double E = Emin; 19 33 double dE = 0.005*(Emax-Emin); 20 34 21 double f; 22 String line; 23 35 // Add relevant information to the output curve 24 36 driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor"); 25 37 driver.put("output.curve(f12).xaxis.label", "Fermi-Dirac Factor"); … … 27 39 driver.put("output.curve(f12).yaxis.units", "eV"); 28 40 41 // Calculate the Fermi-Dirac function over the energy range 42 // Add the results to the output curve 43 double f; 44 String line; 29 45 while (E < Emax){ 30 46 f = 1.0/(1.0 + Math.exp((E - Ef)/kT)); … … 35 51 } 36 52 53 // Finalize the results and inform rappture that the simulation has ended 37 54 driver.result(); 38 55 } -
trunk/examples/app-fermi/java/Makefile.in
r1722 r1727 36 36 37 37 clean: 38 $(RM) Fermi.class38 $(RM) Fermi.class 39 39 40 40 distclean: clean
Note: See TracChangeset
for help on using the changeset viewer.