1 Public classheatconduction {2 Public Double[] Conduction (DoubleXDoubleTintIintj) {//i,j represents discrete points separated by x,t3 Double[] XT =New Double[i][j];4 Doubledx=x/(i-1), dt=t/(j-1);5 Doublec=dt/(dx*dx);6 for(intk = 0; K < I; k++) {//u (x,0) Initial value7xt[k][0]=k*dx* (X-K*DX)/x/x;8 }9 for(intk = 0; K < J; k++) {//u (0,t) Initial valueTenXt[0][k]=0; One } A for(intk = 0; K < J; k++) {//u (x,t) Initial value -Xt[i-1][k]=0; - } the for(intK = 1; K < J; k++) { - for(intL = 1; L < i-1; l++) { -xt[l][k]=c* (Xt[l-1][k-1]+xt[l+1][k-1]) + (1-2*C) *xt[l][k-1]; - } + } - returnXT; + } A at Public Static voidMain (string[] args) { -Heatconduction heatconduction=Newheatconduction (); - Double[] XT = heatconduction.conduction (1.0, 1.0, 10, 500); - for(intj = 0; J < Xt[0].length; J + +) { - for(inti = 0; i < xt.length; i++) { - if(i==xt.length-1) { in System.out.println (Xt[i][j]); -}Else { toSystem.out.print (xt[i][j]+ ""); + } - } the } * } $}
Ut=uxx (0<x<l) (0<t<)
U (0,t) =0, U (l,t) =0
U (x,0) =x (l-x)/l2
Numerical simulation of heat conduction equation