// pdenu34_eq.java 3D non uniform grid boundary value PDE non iterative // 4th order, exponential, log step size test // known solution to test method // u(x,y,z) = exp(x*y*z) // // differential equation to solve // uxxxx(x,y,z)+2*uyyyy(x,y,z)+3*uzzzz(x,y,z)+4*uxyz(x,y,z) = f(x,y,z) // f(x,y,z) = (y*y*y*y*z*z*z*z+ // 2*x*x*x*x*z*z*z*z+ // 3*x*x*x*x*y*y*y*y+ // 4+12*z*x*y+ // 4*y*y*z*z*x*x)*exp(x*y*z) // // non uniform grid // Try log spacing nuderiv 0.0, 0.25, 0.5, 0.7, 0.85, 0.95, 1.0 // step = 0.1 then 0.01 // xg[0] = 2.0 // until xg[i-1]-step<0.0 xg[i++] = xg[i-1]-step; step=2*step // xg[i++] = 0.0 // // set up and solve system of linear equations // // create two dimensional array with // (nx-2)*(ny-2)*(nz-2) rows, one for each equation // uses nuderiv.java // uses simeq.java import java.text.*; class pdenu34_eq { double xg[] = {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0}; double yg[] = {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0}; double zg[] = {0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0}; int nx = xg.length; // includes boundary int ny = yg.length; // includes boundary int nz = zg.length; // includes boundary // nx-2 by ny-2 by nz-2 internal, non boundary cells double cx[] = new double[nx]; // nuderiv coefficients double cy[] = new double[ny]; double cz[] = new double[nz]; double cxyz[][][] = new double[nx][ny][nz]; double cxxxx[] = new double[nx]; double ccxxxx[] = new double[nx]; // for checking double cyyyy[] = new double[ny]; double czzzz[] = new double[nz]; double coefdxxxx, coefdyyyy, coefdzzzz, coefdxdydz; int nxyz = (nx-2)*(ny-2)*(nz-2); double us[] = new double[nxyz]; // solution being computed double ut[][] = new double[nxyz][nxyz+1]; // temporary equations double error; // sum of absolute exact-computed double avgerror; // average error double maxerror; // maximum cell error DecimalFormat fe = new DecimalFormat("0.00E00"); DecimalFormat f6 = new DecimalFormat("0.00000"); pdenu34_eq() { System.out.println("pdenu34_eq.java running"); System.out.println("differential equation to solve"); System.out.println("uxxxx(x,y,z)+2*uyyyy(x,y,z)+3*uzzzz(x,y,z)+4*uxyz(x,y,z) = f(x,y,z)"); System.out.println("f(x,y,z) = (y*y*y*y*z*z*z*z+"); System.out.println(" 2*x*x*x*x*z*z*z*z+"); System.out.println(" 3*x*x*x*x*y*y*y*y+"); System.out.println(" 4+12*z*x*y+"); System.out.println(" 4*y*y*z*z*x*x)*exp(x*y*z)"); System.out.println(""); System.out.println("non uniform grid"); System.out.println(""); System.out.println("known solution, U(x,y,z), to test method"); System.out.println("u(x,y,z) = exp(x*y*z)"); System.out.println("xmin="+f6.format(xg[0])+ ", xmax="+f6.format(xg[nx-1])+ ", nx="+nx); System.out.println("ymin="+f6.format(yg[0])+ ", ymax="+f6.format(yg[ny-1])+ ", ny="+ny); System.out.println("zmin="+f6.format(zg[0])+ ", zmax="+f6.format(zg[nz-1])+ ", nz="+nz); System.out.println("u(xg[0],yg[0],zg[0])="+ fe.format(u(xg[0],yg[0],zg[0]))); System.out.println("f(xg[0],yg[0],zg[0])="+ fe.format(f(xg[0],yg[0],zg[0]))); System.out.println("u(xg[nx-1],yg[ny-1],zg[nz-1])="+ fe.format(u(xg[nx-1],yg[ny-1],zg[nz-1]))); System.out.println("f(xg[nx-1],yg[ny-1],zg[nz-1])="+ fe.format(f(xg[nx-1],yg[ny-1],zg[nz-1]))); init_matrix(); System.out.println("matrix initialized"); System.out.println("initial matrix, left side, upper "); for(int i=0; i<7; i++) { for(int j=0; j<7; j++) { System.out.print(" "+fe.format(ut[i][j])); } System.out.println(" "); } System.out.println("initial matrix, right side, upper "); for(int i=0; i<7; i++) { for(int j=nxyz-5; j