// $AISD_VERSION:RKDemo.java@1.2/home/coei/arc/archive%shell3.ba.best.com$ //COPYRIGHT: Copyright (c) 1997 by Christopher K. Oei, Incorporated. //COPYRIGHT: //COPYRIGHT: http://www.chrisoei.com //COPYRIGHT: info@chrisoei.com //COPYRIGHT: //COPYRIGHT: Permission to use, display, and modify this code //COPYRIGHT: is hereby granted provided that: //COPYRIGHT: //COPYRIGHT: 1) this notice is included in its entirety //COPYRIGHT: 2) we are notified of the usage // RKDemo is a class that demonstrates the use of the RKInt class // by integrating an ODE of the form // // dx[0]/dt = -x[1] - 0.05 x[0] // dx[1]/dt = x[0] // import RKInt; import NumDemo; public class RKDemo extends RKInt { public RKDemo(double i_t,double[] i_x,double i_dt) { super(i_t,i_x,i_dt); } protected double[] derivative(double i_t,double[] i_x) { double q = lev_mag.qvalue; double beta = lev_mag.betavalue; double yst = lev_mag.ystat; int sign = lev_mag.sig; double yst1; double yst2 = 120.; double[] y = new double[3]; yst1=30.+70.*(3.-i_x[0]); y[0]=i_x[2]; y[1]=0.; if( yst1 > yst - 30. && sign > 0) { y[2] = 0.; y[0] = 0.; } else { y[2]=-1.-((double)sign)*6.*Math.pow(yst2,4)/Math.pow(Math.pow(yst-yst1,2)+Math.pow(yst2,2),2.0)-q*i_x[2]/10.; } // System.out.println("x1= " + i_x[0] + "v1= " + i_x[2] + "a1= " + y[2]); return y; } }