4
$\begingroup$

As a prototypic problem

reg = Rectangle[{-1, -1}, {1, 1}];
eqn = -Laplacian[u[x, y], {x, y}] == 1;
bc = {
   DirichletCondition[u[x, y] == 0, True]
   };
sol = NDSolveValue[{eqn, bc}, u, {x, y} \[Element] reg, Method -> {"FiniteElement"}]

code above runs normally. But the result obtained sol as an InterpolatingFunction is only defined within reg, e.g., sol[2, 2] issues a reasonable "InterpolatingFunction::femdmval" error message. Also, the obtained InterpolatingFunction has shown some properties like "Domain: {{-1., 1.}, {-1., 1.}}", "Output: scalar" and "Order: 2", etc.. Especially, there is one "Periodic: False".

This visualizes the result

Plot3D[sol[x, y], {x, y} \[Element] reg, PlotRange -> All]

enter image description here

So this makes me can't help asking that is it possible to make modifications to above code to make sol a periodic function, e.g., by using PeriodicBoundaryCondition (which I have tried but I was not able to make it work)?

Were that implemented, the above hump should forms a square lattice and sol[2, 2] should have the value of sol[0, 0].

$\endgroup$
  • 1
    $\begingroup$ I'm afraid the question itself is wrong, or at least the problem doesn't have a solution in classical sense. It's easy to show that you can't make $u$ and derivative of $u$ be periodic and continuous at the same time. $\endgroup$ – xzczd Jul 25 at 7:39
  • 1
    $\begingroup$ The wording of the title is missleading : The word "condition" let think that you mean "boundary condition of the PDE". Apparently, you simply want to extrapolate the domain of sol from [-1,1][-1,1] with a periodic extrapolation (it implies that the derivative can't be continuous at the boundaries) $\endgroup$ – andre314 Jul 25 at 8:21
  • $\begingroup$ @andre314 Sorry for that. If possible, please help correct the title with more appropriate terms, thank you! $\endgroup$ – Αλέξανδρος Ζεγγ Jul 25 at 8:24
  • $\begingroup$ Done ! - Hope there no other problem $\endgroup$ – andre314 Jul 25 at 8:32
4
$\begingroup$

sol a periodic function, e.g.

I am not sure I understood the question, so I do not know if this is what you mean. If not, will be happy to delete it. Hard to show this in comment.

reg = Rectangle[{-1, -1}, {1, 1}];
eqn = -Laplacian[u[x, y], {x, y}] == 1;
bc = {DirichletCondition[u[x, y] == 0, True]};
sol = NDSolveValue[{eqn, bc}, u, {x, y} \[Element] reg, Method -> {"FiniteElement"}]
Plot3D[sol[x, y], {x, y} \[Element] reg, PlotRange -> All,  AxesLabel -> {"x", "y", "z"}]

Mathematica graphics

To make the solution "periodic"

solPeriodic[x_, y_] := Module[{x0 = x, y0 = y},
   If[x > 1, x0 = x - 2];
   If[x < -1, x0 = x + 2];
   If[y > 1, y0 = y - 2];
   If[y < -1, y0 = y + 2];
   If[Abs[x0] > 1 || Abs[y0] > 1, solPeriodic[x0, y0], sol[x0, y0]]
   ];

Check:

solPeriodic[2, 2]
(*0.294685*)
sol[0, 0]
(*0.294685*)

Plot3D[solPeriodic[x, y], {x, -3, 3}, {y, -3, 3}, 
 AxesLabel -> {"x", "y", "z"}, BoxRatios -> Automatic]

Mathematica graphics

Plot3D[solPeriodic[x, y], {x, -3, 3}, {y, -3, 3}, AxesLabel -> {"x", "y", "z"}]

Mathematica graphics

| improve this answer | |
$\endgroup$
  • $\begingroup$ Yes, this is the desired result. But is it possible to implement it in the process of PED solution? $\endgroup$ – Αλέξανδρος Ζεγγ Jul 25 at 8:07
  • 1
    $\begingroup$ @ΑλέξανδροςΖεγγ I do not know how to do the above directly by chnaging BC in the NDSolve call itself, and not sure if it is possible now. May be someone will have an idea. $\endgroup$ – Nasser Jul 25 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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