Ignore:
Timestamp:
May 20, 2010, 2:13:17 PM (14 years ago)
Author:
braffert
Message:

Last fix for building java bindings. Also added license info and more comments.

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 */
    114
    215class Fermi{
     
    417  public static void main(String args[]){
    518
     19    // create a rappture library from the file path
    620    rappture.Library driver = new rappture.Library(args[0]);
    721
     22    // read the input values and convert to correct units
    823    String Tstr = driver.get("input.number(temperature).current");
    924    double T = Double.valueOf(rappture.Units.convert(Tstr, "K", false));
    10    
    1125    String Efstr = driver.get("input.number(Ef).current");
    1226    double Ef = Double.valueOf(rappture.Units.convert(Efstr, "eV", false));
    1327
     28    // Set the energy range and step size
    1429    double kT = 8.61734E-5 * T;
    1530    double Emin = Ef - 10*kT;
    1631    double Emax = Ef + 10*kT;
    17 
    1832    double E = Emin;
    1933    double dE = 0.005*(Emax-Emin);
    2034
    21     double f;
    22     String line;
    23 
     35    // Add relevant information to the output curve
    2436    driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor");
    2537    driver.put("output.curve(f12).xaxis.label", "Fermi-Dirac Factor");
     
    2739    driver.put("output.curve(f12).yaxis.units", "eV");
    2840
     41    // Calculate the Fermi-Dirac function over the energy range
     42    // Add the results to the output curve
     43    double f;
     44    String line;
    2945    while (E < Emax){
    3046      f = 1.0/(1.0 + Math.exp((E - Ef)/kT));
     
    3551    }
    3652
     53    // Finalize the results and inform rappture that the simulation has ended
    3754    driver.result();
    3855  }
  • trunk/examples/app-fermi/java/Makefile.in

    r1722 r1727  
    3636
    3737clean:
    38         $(RM)Fermi.class
     38        $(RM) Fermi.class
    3939
    4040distclean: clean
Note: See TracChangeset for help on using the changeset viewer.