# Changeset 1727

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

Location:
trunk
Files:
9 edited

Unmodified
Removed
• ## trunk/examples/app-fermi/java/Fermi.java

 r1722 /* * EXAMPLE: Fermi-Dirac function in Java. * * This simple example shows how to use Rappture within a simulator * written in Java. * ====================================================================== * AUTHOR:  Ben Rafferty, Purdue University * Copyright (c) 2010  Purdue Research Foundation * * See the file "license.terms" for information on usage and * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ class Fermi{ public static void main(String args[]){ // create a rappture library from the file path rappture.Library driver = new rappture.Library(args[0]); // read the input values and convert to correct units String Tstr = driver.get("input.number(temperature).current"); double T = Double.valueOf(rappture.Units.convert(Tstr, "K", false)); String Efstr = driver.get("input.number(Ef).current"); double Ef = Double.valueOf(rappture.Units.convert(Efstr, "eV", false)); // Set the energy range and step size double kT = 8.61734E-5 * T; double Emin = Ef - 10*kT; double Emax = Ef + 10*kT; double E = Emin; double dE = 0.005*(Emax-Emin); double f; String line; // Add relevant information to the output curve driver.put("output.curve(f12).about.label", "Fermi-Dirac Factor"); driver.put("output.curve(f12).xaxis.label", "Fermi-Dirac Factor"); driver.put("output.curve(f12).yaxis.units", "eV"); // Calculate the Fermi-Dirac function over the energy range // Add the results to the output curve double f; String line; while (E < Emax){ f = 1.0/(1.0 + Math.exp((E - Ef)/kT)); } // Finalize the results and inform rappture that the simulation has ended driver.result(); }
• ## trunk/examples/app-fermi/java/Makefile.in

 r1722 clean: \$(RM)Fermi.class \$(RM) Fermi.class distclean: clean
• ## trunk/lang/java/Library.java

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines a Java class that implemements the rappture XML library. * The class methods call the corresponding native code through c++ glue code * located in jRpLibrary.cc. */ package rappture; } // Pseudo-Destructor--------------------------------------------------------- // Pseudo-Destructor.  Called when the object is garbage collected.---------- protected void finalize() throws Throwable { try { private native String jRpGetString(long libPtr, String path); private native void jRpPut(long libPtr, String path, String value, boolean append); private native void jRpPut(long libPtr, String path, String value, boolean append); private native void jRpResult(long libPtr, int exitStatus); // Private Attributes-------------------------------------------------------- private long libPtr;  //pointer to c rpLibrary private long libPtr;  //pointer to c++ RpLibrary }
• ## trunk/lang/java/Makefile.in

 r1724 RM              = rm -f INCLUDES = \$(JAVA_INCLUDES) -I \$(includedir) -I . LIBS = -L \$(LIB_SEARCH_DIRS) -lrappture INCLUDES = \$(JAVA_INCLUDES) -I \$(srcdir)/../../src/core -I . LIBS = -L ../../src/core -lrappture CXX_O_SWITCHES = -fpic -c \$(INCLUDES) \$(LIBS) CXX_O_SWITCHES = -fpic -c \$(INCLUDES) CXX_SO_SWITCHES = --shared \$(LIBS) CXX_SO_SWITCHES = --shared \$(INCLUDES) \$(LIBS) OBJS    = \
• ## trunk/lang/java/Units.java

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines a java class that implemements the rappture units module. * The class methods call the corresponding native code through c++ glue code * located in jRpUnits.cc. */ package rappture;
• ## trunk/lang/java/Utils.java

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines a java class that implemements the rappture utils module. * The class methods call the corresponding native code through c++ glue code * located in jRpUtils.cc. */ package rappture;
• ## trunk/lang/java/jRpLibrary.cc

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines the native functions which are called by the java Library * class methods, and in turn call the corresponding rappture RpLibrary methods. */ #include "jRpLibrary.h" #include "rappture.h" // constructor /* * Constructor.  Returns the address of the newly created RpLibrary object to * java as a long int. */ JNIEXPORT jlong JNICALL Java_rappture_Library_jRpLibrary (JNIEnv *env, jobject obj, jstring javaPath){ } // Pseudo-destructor /* * Pseudo-destructor.  This function is called by the java Library class's * finalizer. */ JNIEXPORT void JNICALL Java_rappture_Library_jRpDeleteLibrary (JNIEnv *env, jobject obj, jlong libPtr){
• ## trunk/lang/java/jRpUnits.cc

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines the native functions which are called by the java Units * class methods, and in turn call the corresponding rappture RpUnits methods. */ #include "jRpUnits.h" #include "rappture.h" // convert JNIEXPORT jstring JNICALL Java_rappture_Units_jRpUnitsConvert (JNIEnv *env, jclass cls, jstring javaFromVal, jstring javaTo, jboolean units){
• ## trunk/lang/java/jRpUtils.cc

 r1722 /* * ====================================================================== *  AUTHOR:  Ben Rafferty, Purdue University *  Copyright (c) 2010  Purdue Research Foundation * *  See the file "license.terms" for information on usage and *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. * ====================================================================== */ /* * This file defines the native functions which are called by the java Utils * class methods, and in turn call the corresponding rappture RpUtils methods. */ #include "jRpUtils.h" #include "rappture.h" // progress JNIEXPORT void JNICALL Java_rappture_Utils_jRpUtilsProgress (JNIEnv *env, jclass cls, jint percent, jstring javaText){ const char* nativeText = env->GetStringUTFChars(javaText, 0); const char* nativeText = env->GetStringUTFChars(javaText, 0); Rappture::Utils::progress(percent, nativeText); env->ReleaseStringUTFChars(javaText, nativeText);
Note: See TracChangeset for help on using the changeset viewer.