sarra

270 Reputation

6 Badges

11 years, 129 days

MaplePrimes Activity


These are questions asked by sarra

Hi,

When I run two times my code, the results change.

Have you any idea, why???

 

 

Hi, please a Need a help.
I have an error in my code: Error, (in collect) cannot collect 0
Here, is the code:
Question8X.mw

Many thinks.

 

Hi,

Please I need help in this subject. I would like to compare the numerical solution obtained by finite difference and pdsolve/numeric.

The equation considred is  diffusion Equation using Forward-time centered-space (FTCS) stencil
The code work well with Dirichlet boundary condition, but I want to let  x=-1  Dirichlet boundary condition but on x=1, we put a Neumann condition likeeval( diff(u(t,x),x),x=1)=1. Thank you very much to put the necessary in the attached code the changment.      
Many thinks.

Change_boundary_condition_in_procedure.mw    

Hi,

Please I need you to add in the output of my code the order of error defined in the procedure.

Thanks for helping me.

Here, the code.

QuestionNumber2.mw

Hi,

I solve laplace equation in a square. All the lines of my code is okay.

Please just look to the last part of my code titled procedure:

When I run my code without (last funciton f #f := (x,y) -> 0;) see last lines to find "f". It's runing, there is no problem. But when I put add f, there is an error. Many think  for any help.

Procedure
Using the previous suty in section stencil we can write the procedure to solve the Laplace equation in [0,1]*[0,1] with the boundary condition Neumann conditions on the vertical boundary and Dirichlet boundary condition on the horizontal baoundary. In our study we will use the same stepsize h in x and y direction.

PoissonSolve:=proc(N,_f)
local Z,i,h,y,x,sys,w,f,sol,j,u,Data;
# define basic grid parameters
Z := i -> (1/(N+1))*i;
x[0] = Z(0),x[N+1] = Z(N+1),y[0] = Z(0),y[N+1] = Z(N+1);
 h := evalf(Z(1)-Z(0));
# Fix the boundary data and the source matrix
for i from 0 to N+1 do:
    # Neumann boundary condition
     u[N+1,i] :=  u[N,i] ;    
     u[0,i] := u[1,i];
     # Dirichlet boundary condition
     u[i,0] := 0;
     u[i,N+1] := 0;
   od:
   f := Array(0..N+1,0..N+1,[seq([seq(evalf(_f(Z(i),Z(j))),i=0..N+1)],j=0..N+1)],datatype=float);
# Write down the system of equations to solve and solve them
     sys := [seq(seq(Stencil(h,i,j,u,f),i=1..N),j=1..N)];
  w := [seq(seq(u[i,j],i=1..N),j=1..N)];
  sol := LinearSolve(GenerateMatrix(sys,w));
   # parse the solution vector sol back into "matrix" form
   for i from 1 to N do:
     for j from 1 to N do:
        u[i,j] := sol[(j-1)*N+i]:
     od:
   od:
# generate a 3D plot of the solution using the surfdata command
   Data := [seq([seq([Z(i),Z(j),u[i,j]],i=0..N+1)],j=0..N+1)]:
surfdata(Data,axes=boxed,labels=[`x`,`y`,`u(x,y)`],shading=zhue,style=patchcontour);
end proc:



Here is an example of the output when the source function is set to zero
                                 f(x, y) = 0
; i.e., when  reduces down to Laplace's equation:
#f := (x,y) -> 0;
#PoissonSolve(10,f);

 

 

Question8.mw

First 8 9 10 11 12 13 14 Last Page 10 of 21