Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public:static double fn(int T,double x)
- {
- if (x>=0)
- return T;
- else if(x<0)
- return 0;
- }
- public:static double qt0(double t)//Finite condition
- {
- if (t<=0)
- return 0;
- else
- return t;
- }
- My parameters is:
- hx (step on space)= 0.1
- ht (step on time) = 0.5
- Nx (quantity of steps on x axis) = 10;
- Nt (quantity of steps on t axis) = 12;
- wx[] - this is array of all steps on space;
- wt[] - this is array of all steps on time;
- wht[][]-final array when will be results;
- for(int i = 0;i<Nx;i++)
- {
- wx[i+1]=wx[i]+hx;
- wht[0][i]=fn(T,wx[i]);//funtion.
- }
- for(int j = 0;j<Nt;j++) //
- {
- wt[j+1]=wt[j]+ht;
- wht[j+1][0] = qt0(wt[j+1]);
- }
- for(int j = 0;j<Nt;j++)
- {
- for(int i = 0;i<Nx;i++)
- {
- wht[j+1][i]=-a*(ht*(wht[j][i+1] + wht[j][i])/hx) + (wht[j][i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement