// pde_nl22.java non linear PDE, second order, second degree, two dimension // // The PDE to be solved is: // a1(x,y)*uxx(x,y)*uyy(x,y) + b1(x,y)*u(x,y)*uxx(x,y) + // c1(x,y)*u(x,y)uyy(x,y) = f(x,y) // // f(x,y) = 0.5*exp(x/2.0)*exp(y)*(6.0*x+6.0*y)* // (12.0*y+8.0*x)+0.7/(x*x*y*y+0.5)* // (x*x*x+2.0*y*y*y+3.0*x*x*y+4.0*x*y*y+ // 5.0*x*y+6.0*x+7.0*y+8.0)*(6.0*x+6.0*y)+ // (8.0-2.0*exp(x)-2.0*exp(0.5*y))* // (x*x*x+2.0*y*y*y+3.0*x*x*y+4.0*x*y*y+ // 5.0*x*y+6.0*x+7.0*y+8.0)*(12.0*y+8.0*x) // // a1(x,y) = exp(x/2)*exp(y)/2 // b1(x,y) = 0.7/(x^2*y^2+0.5) // c1(x,y) = 2*(4-exp(x)-exp(y/2)) // // Boundary conditions computed from // ub(x,y) = x^4 + 2 y^4 + 3 x^3 y + 4 x y^3 + // 5 x^2 y^2 + 6 x^2 + 7 y^2 + 8 // import java.io.*; import java.text.*; class pde_nl22 { // number of points for discretization int nx = 5; int ny = 5; int dof = (nx-2)*(ny-2); // Degrees of Freedom int nlin = dof*dof; // all possible, non boundary combinations int ntot = dof+nlin; // total number of terms, linear and nonlinear double hx, hy; double xg[] = new double[nx]; double yg[] = new double[ny]; double ug[][] = new double[nx][ny]; // computed solution, incl boundary double uA[][] = new double[nx][ny]; // actual solution double us[] = new double[ntot]; // single subscript solution int var1[] = new int[ntot]; int var2[] = new int[ntot]; int var3[] = new int[ntot]; int vari1[] = new int[ntot]; int vari2[] = new int[ntot]; simeq_newton5 SN = new simeq_newton5(1.0e-3, 1.0, 24, false); // Define the region for the solution: // xmin <= x <= xmax, ymin <= y <= ymax using nx by ny points double xmin = -1.0; double xmax = 1.0; double ymin = -1.0; double ymax = 1.0; // coefficients of derivatives double cx[][] = new double[nx][nx]; double cxx[][] = new double[nx][nx]; double cy[][] = new double[ny][ny]; double cyy[][] = new double[ny][ny]; int k = 0; DecimalFormat f4 = new DecimalFormat("0.000"); double start_time, end_time; boolean debug = false; String Xname[]; pde_nl22() // construct and run { double x, y; System.out.println("pde_nl22.java running"); System.out.println("nonlinear second order, second degree, two dimension"); System.out.println("a1(x,y)*uxx(x,y)*uyy(x,y) + b1(x,y)*u(x,y)*uxx(x,y) +"); System.out.println("c1(x,y)*u(x,y)uyy(x,y) = f(x,y) "); System.out.println(" "); System.out.println("f(x,y)=0.5*exp(x/2.0)*exp(y)*(6.0*x+6.0*y)*"); System.out.println(" (12.0*y+8.0*x)+0.7/(x*x*y*y+0.5)*"); System.out.println(" (x*x*x+2.0*y*y*y+3.0*x*x*y+4.0*x*y*y+"); System.out.println(" 5.0*x*y+6.0*x+7.0*y+8.0)*(6.0*x+6.0*y)+"); System.out.println(" (8.0-2.0*exp(x)-2.0*exp(0.5*y))*"); System.out.println(" (x*x*x+2.0*y*y*y+3.0*x*x*y+4.0*x*y*y+"); System.out.println(" 5.0*x*y+6.0*x+7.0*y+8.0)*(12.0*y+8.0*x);"); System.out.println("a1(x,y) = exp(x/2.0)*exp(y)/2.0"); System.out.println("b1(x,y) = 0.7/(x*x*y*y+0.5)"); System.out.println("c1(x,y) = (4.0 - exp(x) - exp(y/2.0))*2.0"); System.out.println(" "); System.out.println("Boundary values "); System.out.println("ub(x,y)= x^4 + 2 y^4 + 3 x^3 y + 4 x y^3 +"); System.out.println(" 5 x^2 y^2 + 6 x^2 + 7 y^2 + 8"); System.out.println(" "); start_time = System.currentTimeMillis()/1000.0; // initialize hx, hy, xg, yg hx = (xmax-xmin)/(double)(nx-1); hy = (ymax-ymin)/(double)(ny-1); System.out.println("xmin="+xmin+", xmax="+xmax+", hx="+hx+", nx="+nx); System.out.println("ymin="+ymin+", ymax="+ymax+", hy="+hy+", ny="+ny); for(int i=0; i=n || var2[i]>=n || var3[i]>=n || vari1[i]>=n || vari2[i]>=n) System.out.println("var error "+var1[i]+" "+var2[i]+" "+var3[i]+ " "+vari1[i]+" "+vari2[i]); System.out.print("A[i]["+i+"]"); if(var1[i]>=0) System.out.print("*"+Xname[var1[i]]); if(var2[i]>=0) System.out.print("*"+Xname[var2[i]]); if(var3[i]>=0) System.out.print("*"+Xname[var3[i]]); if(vari1[i]>=0 || vari2[i]>=0) System.out.print("/("); if(vari1[i]>=0) System.out.print(Xname[vari1[i]]); if(vari2[i]>=0) System.out.print("*"+Xname[vari2[i]]); if(vari1[i]>=0 || vari2[i]>=0) System.out.print(")"); if(i==n+nlin-1) System.out.println(" "); else System.out.println("+"); } System.out.println(" = Y[i]"); System.out.println(" "); } // end print_eqn public static void main(String args[]) { new pde_nl22(); } // end main } // end class pde_nl22