Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double [] getCalc(double t, int K, int I){
- double hx2=Math.pow(hx, 2);
- this.ht=t/K;
- this.hx=l/I;
- this.I=I;
- double a_=a2*(theta-1)*ht;
- double b_=2*(1-theta)*a2*ht+(theta-1)*ht*hx2*b;
- double c_=a_+b_;
- double a__=a2*theta*ht;
- double b__=hx2-2*a2*theta*ht+theta*ht*hx2*b;
- double [] F = new double [I-1];
- double [] U = null;
- for (int k=0; k<K; k++)
- {
- if (k==0)
- for (int i=0; i<I-1; i++)
- F[i]=a__*this.getPsi(i*hx)+b__*this.getPsi((i+1)*hx)+
- a__*this.getPsi((i+2)*hx)+ht*hx2*this.getPhi((i+1)*hx);
- else
- for (int i=0; i<I-1; i++){
- if (i==0)
- F[i]=a__*U[i]+b__*U[i]+a__*U[i+1]+
- ht*hx2*this.getPhi((i+1)*hx);
- if (i==I-2)
- F[i]=a__*U[i-1]+b__*U[i]+a__*U[i]+
- ht*hx2*this.getPhi((i+1)*hx);
- if ((i>0) && (i<I-2))
- F[i]=a__*U[i-1]+b__*U[i]+a__*U[i+1]+
- ht*hx2*this.getPhi((i+1)*hx);
- }
- double [] P = new double [I-2]; //n-1
- P[0]=a_/(a_+b_);
- F[0]=-F[0]/(a_+b_);
- for (int i=1; i<I-1; i++){
- if (i<I-2)
- P[i]=a_/(b_-P[i-1]*a_);
- F[i]=(F[i]-F[i-1]*a_)/(b_-P[i-1]*a_);
- }
- for (int i=I-2; i>0; i--){
- F[i-1]=F[i-1]-P[i-1]*F[i];
- }
- U=F.clone();
- }
- return U;
- }
Add Comment
Please, Sign In to add comment