Message Boards Message Boards

Use Neumann Boundary in solving Finite Difference Method ?

GROUPS:

Hi , I want to solve an Laplace Equation by 3 Neumann Boundary (bottom , left , right) and a Dirichlet Boundary (top), i write a code but i dont know how to complete it by repalce Boundaries , please help me.

Best regards Saleh

generateSystemEquations[n_, U_, F_, 
      h_, \[Alpha]_, \[Beta]_, \[Gamma]_, \[Eta]_] := 
     Module[{m, f, i, j, eqs, unknowns, b, A, u},
      u = Array[Subscript[U, ##] &, {n, n}, {0, 0}];
      f = Array[Subscript[F, ##] &, {n, n}, {0, 0}];
      eqs = Flatten@
        Table[eq[u, i, j, h] == Subscript[f, i, j], {j, n - 2}, {i, 
          n - 2}];
      unknowns = Flatten@Table[Subscript[u, i, j], {j, n - 2}, {i, n - 2}];
      {b, A} = Normal@CoefficientArrays[eqs, unknowns];
      b = b /. Subscript[U, 0, any_] -> \[Alpha]; (*left*)
      b = b /. Subscript[U, any_, n - 1] -> \[Beta]; (*right*)
      b = b /. Subscript[U, any_, 0] -> \[Gamma]; (*bottom*)
      b = b /. Subscript[U, n - 1, any_] -> \[Eta];(*top*)
      Print[makeGrid[n, n, u]]
       Print[Style[
         Row[{1/h^2, MatrixForm[h^2 A], MatrixForm@unknowns, "=", 
           MatrixForm@b}, Alignment -> Left, ImageSize -> Full], 18]]
      ]
    Clear[U, F, h, \[Alpha], \[Beta], \[Gamma], \[Eta]];
    Do[{generateSystemEquations[i, U, F, 
       h, \[Alpha], \[Beta], \[Gamma], \[Eta]], 
      Print@Graphics[{Thick, Line[{{0, 0}, {10, 0}}]}]}, {i, 4, 4}]
POSTED BY: Saleh Baradaran
Answer
1 month ago

Group Abstract Group Abstract