0
$\begingroup$

I have the following PDE that I am able to solve using DirichletCondition with NDSolve as the following:

uu = NDSolveValue[{Laplacian[U[x, y], {x, y}] == 10*Sin[8*x*(y - 1)], 
    DirichletCondition[U[x, y] == 0, True]}, 
   U, {x, -1, 1}, {y, -1, 1}];
Plot3D[Evaluate[uu[x, y], {x, -1, 1}, {y, -1, 1}, 
  PlotRange -> {Automatic, Automatic, {-.5, .5}}, 
  PerformanceGoal -> "Quality"]]

This works for me and it matches my numerical solution from MATLAB. However, I was trying to solve a similar PDE with different BCs. A Dirichlet BC on y with interval {-1,1} and a periodic BC on x with interval {0,2*pi}. I have a numerical solution in MATLAB that I would like to reproduce with Mathematica. Is this possible? Thanks.

$\endgroup$
2
  • 2
    $\begingroup$ I have a numerical solution in MATLAB that I would like to reproduce with Mathematica. Is this possible? could you show that Matlab code? $\endgroup$
    – Nasser
    Dec 30, 2023 at 0:56
  • $\begingroup$ What means "Dirichlet BC on y with interval {-1,1} "? $\endgroup$ Dec 30, 2023 at 11:58

1 Answer 1

1
$\begingroup$

If I correctly understand the boundary conditions try

    reg = Rectangle[ {0, -1}, {2 Pi, 1}  ];
V = NDSolveValue[{Laplacian[v[x, y], {x, y}] == 10*Sin[8*x*(y - 1)], 
   DirichletCondition[v[x, y] == 0, y == 1 || y == -1],
   PeriodicBoundaryCondition[v[x, y], x == 2 Pi && -1 < y < 1, 
    TranslationTransform[{-2 Pi, 0}]],
   PeriodicBoundaryCondition[v[x, y], x == 0 && -1 < y < 1, 
    TranslationTransform[{ 2 Pi, 0}]]}, v, Element[{x, y}, reg ], 
  Method -> {"FiniteElement", 
    "MeshOptions" -> {"MeshElementType" -> "TriangleElement", 
        "MaxCellMeasure" -> 2 Pi/1000 }}]
Plot3D[V[x, y], Element[{x, y}, reg], PlotRange -> All, 
 MeshFunctions -> (#3 &)]

enter image description here

In this example Mathematica v12.2 only handles PeriodicBoundaryConditions correctly if we use "MeshElementType" -> "TriangleElement"

$\endgroup$

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