Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public:static double fn(int T,double x)
  2. {
  3. if (x>=0)
  4. return T;
  5. else if(x<0)
  6. return 0;
  7. }
  8.  
  9. public:static double qt0(double t)//Finite condition
  10. {
  11. if (t<=0)
  12. return 0;
  13. else
  14. return t;
  15. }
  16.  
  17. My parameters is:
  18.  
  19. hx (step on space)= 0.1
  20.  
  21. ht (step on time) = 0.5
  22.  
  23. Nx (quantity of steps on x axis) = 10;
  24.  
  25. Nt (quantity of steps on t axis) = 12;
  26.  
  27. wx[] - this is array of all steps on space;
  28.  
  29. wt[] - this is array of all steps on time;
  30.  
  31. wht[][]-final array when will be results;
  32.  
  33. for(int i = 0;i<Nx;i++)
  34. {
  35. wx[i+1]=wx[i]+hx;
  36. wht[0][i]=fn(T,wx[i]);//funtion.
  37. }
  38.  
  39. for(int j = 0;j<Nt;j++) //
  40. {
  41. wt[j+1]=wt[j]+ht;
  42. wht[j+1][0] = qt0(wt[j+1]);
  43. }
  44.  
  45. for(int j = 0;j<Nt;j++)
  46. {
  47. for(int i = 0;i<Nx;i++)
  48. {
  49. wht[j+1][i]=-a*(ht*(wht[j][i+1] + wht[j][i])/hx) + (wht[j][i]);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement