/* imhf.java Implicit heat flow equation, finite differenced. Adapted from Jon Claerbout's Imaging the Earth's Interior (1985), p. 98, by John N. Louie, 28 November 1998. */ /* Include the usual classes */ import java.util.*; import java.io.*; import java.lang.Math; /* Declare a class with a main() method to contain the finite-difference code. */ /* When you change the code in this file, make a copy to a new file with a new name like "ex6imhf.java", and be sure to make the same change to the class name below - e.g. "class ex6imhf" */ class imhf { /* The main() method compiles into a file named "imhf.class" that you run in the Java virtual machine as a stand-alone application with a command such as "java imhf"; or however you have renamed it. */ public static void main(String args[]) /* No runtime arguments needed */ { System.out.println("Starting imhf..."); /* Declare variables */ int nx, it, ix; float alpha, a, q[], d[], e[], f[]; /* Dimension arrays */ nx = 12; q = new float[nx]; d = new float[nx]; e = new float[nx]; f = new float[nx]; a = 8F; System.out.println("a = " + a); alpha = 0.5F*a; /* Initial temperature is a step in x */ for (ix=0; ix<6; ix++) q[ix] = 0F; for (ix=6; ix<12; ix++) q[ix] = 1F; /* Iterate in time */ for (it=0; it<4; it++) { /* Print current state of array */ for (ix=0; ix=0; i--) q[i] = e[i]*q[i+1] + f[i]; /* End of rtris static method of class imhf */ } /* End of methods in class imhf */ }