3
$\begingroup$

I am new to the finite elements package in Mathematica. I have a system of equations, one of which is a Helmholtz equation with a point source in the interior of a bounded domain. The following is the code I've attempted to use:

bmesh = ToBoundaryMesh[
  "Coordinates" -> {{-0.05, -0.1}, {0.2, -0.1}, {0.2, 0.1}, {-0.05, 0.1},
    {0.1, 0}, {0.11, 0}, {0.11, 0.03}, {0.1, 0.03}, {0, 0}},
  "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 1}}]}]
%["Wireframe"]
mesh = ToElementMesh[bmesh];
Show[
 mesh["Wireframe"],
 Graphics[{Red, PointSize[Large], Point[{0, 0}]}]]
sol = NDSolve[{-D[u[x, y], x, x] - D[u[x, y], y, y] - u[x, y] == 0,
    DirichletCondition[u[x, y] == 1, x == 0 && y == 0],
    u[x, 0.1] == 0,
    Derivative[1, 0][u][-0.05, y] == 0,
    Derivative[0, 1][u][x, -0.1] == 0,
    Derivative[1, 0][u][0.2, y] == 0},
   u, {x, y} ∈ mesh];

Error messages appear stating that the first x-derivative is not a polynomial and that the dependent variable u is not linear. What is wrong here?

$\endgroup$
1
  • $\begingroup$ I think this does what you want:sol = NDSolve[{-D[u[x, y], x, x] - D[u[x, y], y, y] - u[x, y] == 0, DirichletCondition[u[x, y] == 1, x == 0 && y == 0], DirichletCondition[u[x, y] == 0, y == .1]}, u, {x, y} [Element] mesh] I have the impression your boundary conditions are redundant since the rhs of the pde is 0 $\endgroup$ Commented Jul 3, 2016 at 17:09

1 Answer 1

1
$\begingroup$

Here is a way to do it:

(*
Needs["NDSolve`FEM`"];
\[CapitalOmega]=Rectangle[{-0.05,-0.1},{0.2,0.1}];
mesh=ToElementMesh[\[CapitalOmega],"IncludePoints"\[Rule]{{0,0}}];
*)
sol = NDSolveValue[{-D[u[x, y], x, x] - D[u[x, y], y, y] - 
      u[x, y] == 0, 
    DirichletCondition[u[x, y] == 1, x == 0 && y == 0], 
    DirichletCondition[u[x, y] == 1, y == 0.1]
    }, u, {x, y} \[Element] mesh];
sol[0, 0]
0.9999999999999986`
$\endgroup$
2
  • $\begingroup$ Thanks to User 21 for the above suggestion. It works. $\endgroup$
    – RJR
    Commented Jul 5, 2016 at 23:43
  • $\begingroup$ @RJR, no worries. $\endgroup$
    – user21
    Commented Jul 6, 2016 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.