I am unsure whether the question is still relevant, but found an analytical solution, derived with the help of Greenfunction
:
First it's necessary to transform the pde {Laplacian[u[x, y], {x, y}] + u[x, y] == 0
to homogenuous boundaryconditions
pde=Laplacian[u[x, y], {x, y}] + u[x, y] /.u -> Function[{x, y}, Sin[Pi x/6] +v[x, y]] // Collect[#, Sin[__], Simplify] &
$$v^{(0,2)}(x,y)+v^{(2,0)}(x,y)+v(x,y)+\left(1-\frac{\pi ^2}{36}\right) \sin \left(\frac{\pi x}{6}\right)=0
$$
Homogenuous boundarycondition v[x,y]==0
on the boundary of rect
In the next step we try to solve pde
using GreenFunction
. That means we are looking for a solution of $$v^{(0,2)}(x,y)+v^{(2,0)}(x,y)+v(x,y)=\delta (x-\xi ) \delta (y-\eta )$$
The documentation shows a similar example.
Unfortunately Mathematica at present is only able to solve the problem in a rectangular region with one corner {0,0}
(see GreenFunction for Helmholtz equation in arbitrary Rectangle region doesn't evaluate)
That's why we have to modify Greenfunction
for our purpose:
green = Block[{gre, rechteck = rect},
gre = GreenFunction[{Laplacian[v [x , y ], {x , y }] + v [x, y],DirichletCondition[v [x, y] == 0, True]}, v ,
Element[{x, y},TranslationTransform[{ 3, 3}][rechteck]], {\[Xi], \[Eta]}] ;
Function[{x, y, \[Xi], \[Eta]},gre[x - 3, y - 3, \[Xi] - 3, \[Eta] - 3] //
Evaluate] ]
greenfunction gre[x, y, \[Xi], \[Eta]]:
:
$$-\frac{1}{9} \underset{K[1]=1}{\overset{\infty }{\sum
}}\underset{K[2]=1}{\overset{\infty }{\sum }}\frac{\sin \left(\frac{1}{6} \pi (x-3)
K[1]\right) \sin \left(\frac{1}{6} \pi (\xi -3) K[1]\right) \sin \left(\frac{1}{6} \pi
(y-3) K[2]\right) \sin \left(\frac{1}{6} \pi (\eta -3) K[2]\right)}{\frac{1}{36} \pi ^2
K[1]^2+\frac{1}{36} \pi ^2 K[2]^2-1}$$
Function[{x,y, \[Xi], \[Eta]},-(1/9) Inactive[Sum][(Sin[1/6 \[Pi] (-3 + x)K[1]] Sin[1/6 \[Pi] (-3 + \[Xi])K[1]] Sin[1/6 \[Pi] (-3 + y) K[2]] Sin[1/6 \[Pi] (-3 + \[Eta]) K[2]])/(-1 + 1/36\[Pi]^2 K[1]^2 + 1/36 \[Pi]^2 K[2]^2), {K[1], 1, \[Infinity]}, {K[2], 1, \[Infinity]}]]
The analytical solution u[x,y]
follows to
nn=5 ;
Integrate [green[x,y, \[Xi], \[Eta]] (-(1 - 1/36 \[Pi]^2) Sin[(\[Pi] \[Xi])/6]) /.Infinity -> nn// Activate, Element[{\[Xi], \[Eta]}, rect]]
Plot3D[%% + Sin[Pi x/6], Element[{x, y}, rect]]
$$\frac{128}{25} \left(1-\frac{\pi ^2}{36}\right) \left(\frac{15 \left(\frac{5 \sin
\left(\frac{\pi x}{3}\right)}{5 \pi ^2-36}-\frac{2 \sin \left(\frac{2 \pi
x}{3}\right)}{17 \pi ^2-36}\right) \cos \left(\frac{\pi y}{6}\right)}{\pi
^2}+\left(\frac{25 \sin \left(\frac{\pi x}{3}\right)}{36 \pi ^2-13 \pi ^4}+\frac{10 \sin
\left(\frac{2 \pi x}{3}\right)}{\pi ^2 \left(25 \pi ^2-36\right)}\right) \cos
\left(\frac{\pi y}{2}\right)+\frac{3 \left(\frac{5 \sin \left(\frac{\pi x}{3}\right)}{29
\pi ^2-36}-\frac{2 \sin \left(\frac{2 \pi x}{3}\right)}{41 \pi ^2-36}\right) \cos
\left(\frac{5 \pi y}{6}\right)}{\pi ^2}\right)$$
The analytical solution agrees very well with the numerical solution
numU = NDSolveValue[{Laplacian[u[x, y], {x, y}] + u[x, y] == 0,DirichletCondition[u[x, y] == Sin[(Pi x)/6], True]}, u,Element[{x, y}, rect]]`
Plot3D[numU[x, y], Element[{x, y}, rect]]
eqn = Laplacian[u[x, y], {x, y}] + u[x, y] == 0; bc = {u[-3, y] == -1, u[3, y] == 1, u[x, -3] == Sin[(Pi*x)/6], u[x, 3] == Sin[(Pi*x)/6]}; sol = NDSolve[{eqn, bc}, u[x, y], {x, -3, 3}, {y, -3, 3}];Plot3D[u[x, y] /. sol, {x, -3, 3}, {y, -3, 3}]
works for me in 12.3.1 on Windows 10. $\endgroup$bc
, Mathematica gives an analytical solution:U = DSolveValue[{eqn(*,bc*)}, u, {x, y}] // FullSimplify
depending on five parameters .Perhaps it's possible to adapt your boundary conditions in the next step? $\endgroup$DSolveValue[eqn, u[x, y], {x, y}]
produces "DSolve::lpde: General solution is not available for the given linear partial differential equation. Trying to build a special solution.
" andE^(-x Sqrt[C[ 5]]) (E^(2 x Sqrt[C[5]]) C[1] + C[2]) (C[4] Cos[y Sqrt[1 + C[5]]] + C[3] Sin[y Sqrt[1 + C[5]]])
. $\endgroup$FullSimplify
does nothing in the above. $\endgroup$eqn
andbc
!?! $\endgroup$