sarra

270 Reputation

6 Badges

11 years, 131 days

MaplePrimes Activity


These are questions asked by sarra

Dear all,

I need your help.

I compute the exact solution u(x,y,t) os PDE.
My code : PDEs.mw

I would like to plot the exact solution of my PDE.

My method work well but  when I put a:=1; b:=1; In the next lines there is no change, always I have a and b in my equation.

If i fix the time, "t=1 or 2 " for example; In the last lines i plot( u(x,y,2)); but doesn't work also.

Then animation in "t" how....

Thanks for your help.

 

 

 

Dear all;

Please give me few minutes to correct the output of this procedure.Many thinks. 
We will solve the waves equations: diff(f(x,y,t),t$2)=c^2*( diff(f(x,y,t),x$2) +diff(f(x,y,t),y$2));  where (x,y,t) in [0,1]*[0,1]*[0,T] using finite difference.  With Initial boundary conditions: [u(0,y,t)=u(1,y,t)=0],   [u(x,0,t)=u(x,1,t)=0],  [u(x,y,0)=f(x,y),   diff(u(x,y,0),t)=g(x,y)]... The code is done and perfect but....The output of this procedure is Nothing. How can I plot the solution...

f:=(x,y)->x*(x-1)*y*(y-1);
g:=(x,y)->0;
analytical_sol:=proc(dx,dy,dt,Tf)
local Ft, Fx,Fy,x,y, c1,c2,c,j,k,i,u;
Ft := floor(Tf/dt)+1;
Fx := floor(1/dx)+1;
Fy := floor(1/dy)+1;
x:=[seq(0..1,dx)]:
y:=[seq(0..1,dy)]:
c1 := (c*dt/dx)^2;
c2 := (c*dt/dy)^2;
#Initial position
for j from  1 to Fx do  
   for k from 1 to Fy do
  u[j,k,1] := f(-dx + j*dx, -dy + k*dy) -dt*g(-dx+j*dx, -dy + k*dy);
   u[j,k,2] := f(-dx + j*dx, -dy +k*dy);
end do;
end do;

# Boundary values j=1
for i from  1 to Ft +1 do
      for k from 1 to Fy do
         u[1,k,i] := 0;
      end do;
      for k from 1 to Fy do
         u[Fx,k,i] := 0;
      end do;

     for j from 1 to Fx do
         u[j,1,i] := 0;
      end do;
   
   for j from 1 to Fx do
         u[j,Fy,i] := 0;
      end do;
end do;

for i from 3 to Ft + 1 do
  for j from 2 to Fx-1 do
    for k from 2 to Fy-1 do
u[j, k, i] := 2*u[j,k,i-1] - u[j,k,i-2] + c1*(u[j+1,k,i-1]-2*u[j,k,i-1]+u[j-1,k,i-1]) + c2*(u[j,k+1,i-1] - 2*u[j, k, i-1] + u[j,k-1, i-1]);
end do;
end do;
end do;
return Matrix([seq([seq([seq(u[i,j,k],i=1..Fx)],j=1..Fy)],k=1..Ft)]):
end proc:

## Try the test
f:=(x, y) -> x (x - 1) y (y - 1)
g:=(x, y) -> 0;
analytical_sol(0.1,0.1,0.1,2);
                      

Dear All, I need your help to plot the numerical solution. many thanks.

The variable t in [0,T], x in [0,1], b in [0,2].

Difference finie for waves equation is :

pde:=diff(u(x, y,t), t$2) = c^2*(diff(u(x, y,t),x$2)+diff(u(x,y,t),y$2));

i: according to x, j according to y, and k according to t.

u[i,j,k+1]=2*u[i,j,k]-u[i,j,k-1]+(c*dt/dx)^2*(u[i-1,j,k]-2*u[i,j,k]+u[i+1,j,k])+ (c*dt/dy)^2*(u[i,j-1,k]-2*u[i,j,k]+u[i,j+1,k])

 

Boundary condition: u(t=0)=1, diff(u(x,y,t),t=0)=0, and the normal derivative on the boundary of Omega =0.

How can solve this problem and plot the numerical solution.

 

 

 

Hi.

please, I need some code about stepsize adaptative Runge Kutta method ( any order ) or other methods.

Thanks

 


Dear the specialst in programmation, please I need to put a conditon if in this procedure with this form: Can you correct me this code please. Thank you.


aaa:=proc(x,y,f,N)
local bb,
for i= from 1 to N do

bb[i]:=f(x[i],y);

if bb[i]<=2 then y:=3*x[i] else y::=x[i]^2end if ;

end do:

end proc

 

 

First 13 14 15 16 17 18 19 Page 15 of 21