1
$\begingroup$

I have to solve a relatively simple PDE: $$\frac{\phi_{xx}(x,y)}{A}+\frac{\phi_{yy}(x,y)}{B}=-2 \theta$$ where $A$, $B$, and $\theta$ are constants. The code that I used was

pde=1/Gy D[ϕ[x,y],{x,2}]+1/Gx D[ϕ[x,y],{y,2}]==-2θ
sol=DSolve[pde,ϕ[x,y],{x,y}]
(* (ϕ^(0,2))[x,y]/Gx+(ϕ^(2,0))[x,y]/Gy==-2 θ *)
(* {{ϕ[x,y]->-Gy x^2 θ+C[1][(Sqrt[-Gx Gy] x)/Gx+y]+C[2][-((Sqrt[-Gx Gy] x)/Gx)+y]}} *)

Firstly, I would like to ask how reliable this is. I'm still new to Mathematica so I'm not completely sure how well it handles second-order PDEs.

Now I would like to solve for C[1] and C[2]. I have BCs $\phi(\pm a,y)=\phi(x,\pm b)=0$ so I type in

ϕ2[x_,y_]=ϕ[x,y]/.sol[[1]]
Solve[ϕ2[a,b]==0&&ϕ2[-a,-b]==0,{C[1],C[2]}]

and I get out

(* -Gy x^2 θ+C[1][(Sqrt[-Gx Gy] x)/Gx+y]+C[2][-((Sqrt[-Gx Gy] x)/Gx)+y] *)
(* {{}} *)

I don't understand why Mathematica is giving me {{}}. Does that mean that there are no solutions? Am I typing in the constants wrong into Solve? I tried quitting the kernel and re-running the code several times but to no avail. I also tried to type in Solve[ϕ2[a,y]==0&&ϕ2[-a,y]==0,{C[1],C[2]}] and other combinations but nothing happened.

It would be simple to solve for C[1] and C[2] by hand but later I will need to deal with more complicated equations so I want to learn what mistake I made.

EDIT: I tried to type in the following

g[x_,y_]=-Gy x^2 \[Theta]+A[(Sqrt[-Gx Gy] x)/Gx+y]+B[(Gy x)/Sqrt[-Gx Gy]+y]
Solve[{g[a,y]==0},A]

but it still won't solve even for just A.

$\endgroup$
7
  • $\begingroup$ I realized that I didn't put {} in Solve[\[Phi]2[a,b]==0&&\[Phi]2[-a,-b]==0,{C[1],C[2]}] but even after adding the parenthesis around \[Phi]2[a,b]==0&&\[Phi]2[-a,-b]==0 I still don't get a solution. $\endgroup$
    – enea19
    Commented Mar 13, 2019 at 8:48
  • 2
    $\begingroup$ The return value {{}} of Solve signifies that "the solution set is full dimensional" (see documentation of Solve). The problem is that the solution of your PDE contains two functions C[1] and C[2], and Solve can't solve for functions. You would need to supply your boundary conditions directly to DSolve, but I couldn't get it to work for now (you might have to use NDSolve). Note also that the way you've written the boundary conditions in code does not match what you've written in the text. $\endgroup$
    – Lukas Lang
    Commented Mar 13, 2019 at 9:03
  • $\begingroup$ @Nasser My apologies, I got confused and changed the question appropriately. $\endgroup$
    – enea19
    Commented Mar 13, 2019 at 9:38
  • $\begingroup$ @LukasLang I wrote those BCs because since the boundary is a rectangle, I thought it would be reasonable to assume that ϕ2[a,b]==0. I tried limits like I wrote in the question but got no answer. How can I enter the BCs in DSolve? $\endgroup$
    – enea19
    Commented Mar 13, 2019 at 9:43
  • 1
    $\begingroup$ You may get a numerical solution of such an equation. It may be, further, reduced to an equation with one control parameter, then you could easily tabulate the solution. If not, I only see the way to use Fourier-transform. $\endgroup$ Commented Mar 13, 2019 at 12:09

1 Answer 1

4
$\begingroup$

Yes, there is an analytical solution. The min/max only applies to Laplace PDE, not Poisson.

Here is the analytical solution. I verified it using Mathematica's NDSolve and it agrees. So I do not know why Mathematica DSolve could not solve it. May be in version 12 it will.

Analytical solution

solve \begin{align*} \frac{u_{xx}}{A}+\frac{u_{yy}}{B} & =-2\theta\\ Bu_{xx}+Au_{yy} & =-2\theta AB\\ & =C \end{align*}

Where $C=-2\theta AB$ is a new constant. With boundary conditions

\begin{align*} u\left( x,-b\right) & =0\\ u\left( x,b\right) & =0\\ u\left( -a,y\right) & =0\\ u\left( a,y\right) & =0 \end{align*}

To simplify solution, shift the rectangle so its lower left corner on the origin. Let $\tilde{x}=x+a$, and $\tilde{y}=y+b$. The boundary conditions becomes

\begin{align*} u\left( \tilde{x},0\right) & =0\\ u\left( \tilde{x},2b\right) & =0\\ u\left( 0,\tilde{y}\right) & =0\\ u\left( 2a,\tilde{y}\right) & =0 \end{align*}

And the pde becomes $Bu_{\tilde{x}\tilde{x}}+Au_{\tilde{y}\tilde{y}}=C$. Instead of keep writing $\tilde{x},\tilde{y}$, will use $x,y$, but remember that these are shifted version. At the end, we shift back.

Hence the PDE to solve is $Bu_{xx}+Au_{yy}=C$ with BC

\begin{align*} u\left( x,0\right) & =0\\ u\left( x,2b\right) & =0\\ u\left( 0,y\right) & =0\\ u\left( 2a,y\right) & =0 \end{align*}

Using eigenfunction expansion method. Let \begin{equation} u\left( x,y\right) =\sum_{n=1}^{\infty}b_{n}\left( y\right) X_{n}\left( x\right) \tag{1} \end{equation}

Where $X_{n}\left( x\right) $ is eigenfunctions for $X^{\prime\prime}\left( x\right) +\lambda_{n}X\left( x\right) =0$ with boundary conditions $X\left( 0\right) =X\left( 2a\right) =0$. This has eigenfunctions as $X_{n}\left( x\right) =\sin\left( \sqrt{\lambda_{n}}x\right) $ with eigenvalues $\lambda_{n}=\left( \frac{n\pi}{2a}\right) ^{2}$ \ for $n=1,2,\cdots$.

Substituting (1) into the PDE $Bu_{xx}+Au_{yy}=C$ gives

$$ B\sum_{n=1}^{\infty}b_{n}\left( y\right) X_{n}^{\prime\prime}\left( x\right) +A\sum_{n=1}^{\infty}b_{n}^{\prime\prime}\left( y\right) X_{n}\left( x\right) =C $$

Expanding $C$ (a constant) as Fourier sine series the above becomes

$$ B\sum_{n=1}^{\infty}b_{n}\left( y\right) X_{n}^{\prime\prime}\left( x\right) +A\sum_{n=1}^{\infty}b_{n}^{\prime\prime}\left( y\right) X_{n}\left( x\right) =\sum_{n=1}^{\infty}q_{n}X_{n}\left( x\right) $$

But $X_{n}^{\prime\prime}\left( x\right) =-\lambda_{n}X_{n}\left( x\right) $, hence the above becomes

\begin{align} -B\sum_{n=1}^{\infty}\lambda_{n}b_{n}\left( y\right) X_{n}\left( x\right) +A\sum_{n=1}^{\infty}b_{n}^{\prime\prime}\left( y\right) X_{n}\left( x\right) & =\sum_{n=1}^{\infty}q_{n}X_{n}\left( x\right) \nonumber\\ Ab_{n}^{\prime\prime}\left( y\right) -B\lambda_{n}b_{n}\left( y\right) & =q_{n}\tag{1A} \end{align}

But

\begin{align*} C & =\sum_{n=1}^{\infty}q_{n}X_{n}\left( x\right) \\ \int_{0}^{2a}CX_{n}\left( x\right) dx & =q_{n}\int_{0}^{2a}X_{n}^{2}\left( x\right) dx\\ \int_{0}^{2a}C\sin\left( \sqrt{\lambda_{n}}x\right) dx & =q_{n}\int _{0}^{2a}\sin^{2}\left( \sqrt{\lambda_{n}}x\right) dx\\ \frac{-C}{\sqrt{\lambda_{n}}}\left( \left( -1\right) ^{n}-1\right) & =q_{n}a\\ q_{n} & =\frac{-C}{a\sqrt{\lambda_{n}}}\left( \left( -1\right) ^{n}-1\right) \end{align*}

Hence (1A) becomes

$$ Ab_{n}^{\prime\prime}\left( y\right) -B\lambda_{n}b_{n}\left( y\right) =\frac{-C}{a\sqrt{\lambda_{n}}}\left( \left( -1\right) ^{n}-1\right) $$

This is standard second order linear ODE. The solution is

$$ b_{n}\left( y\right) =D_{n}e^{\sqrt{\frac{B}{A}\lambda_{n}}y}+E_{n} e^{-\sqrt{\frac{B}{A}\lambda_{n}}y}+\frac{C}{aB\lambda_{n}^{\frac{3}{2}} }\left( \left( -1\right) ^{n}-1\right) $$

Using the above in (1) gives the solution

\begin{equation} u\left( x,y\right) =\sum_{n=1}^{\infty}\left( D_{n}e^{\sqrt{\frac{B} {A}\lambda_{n}}y}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}}y}+\frac{C} {aB\lambda_{n}^{\frac{3}{2}}}\left( \left( -1\right) ^{n}-1\right) \right) X_{n}\left( x\right) \tag{1A} \end{equation}

We now need to find $D_{n},E_{n}$.

Case $n$ even

When $n$ is even $\left( \left( -1\right) ^{n}-1\right) =0$ and the solution (1A) becomes

$$ u\left( x,y\right) =\sum_{n=1}^{\infty}\left( D_{n}e^{\sqrt{\frac{B} {A}\lambda_{n}}y}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}}y}\right) X_{n}\left( x\right) $$

At $y=0$ the above gives

$$ 0=\sum_{n=1}^{\infty}\left( D_{n}+E_{n}\right) \sin\left( \sqrt{\lambda _{n}}x\right) $$

Therefore

\begin{equation} D_{n}+E_{n}=0 \tag{2} \end{equation}

And at $y=2b$

$$ 0=\sum_{n=1}^{\infty}\left( D_{n}e^{\sqrt{\frac{B}{A}\lambda_{n}}2b} +E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}}2b}\right) \sin\left( \sqrt {\lambda_{n}}x\right) $$

Therefore

\begin{equation} D_{n}e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda _{n}}2b}=0 \tag{3} \end{equation}

From (2,3) we see that $D_{n}=E_{n}=0$, Hence $u\left( x,y\right) =0$ when $n$ even.

Case $n$ odd

When $n$ is odd $\left( \left( -1\right) ^{n}-1\right) =-2$ and the solution (1A) becomes

$$ u\left( x,y\right) =\sum_{n=1}^{\infty}\left( D_{n}e^{\sqrt{\frac{B} {A}\lambda_{n}}y}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}}y}-\frac{2C} {aB\lambda_{n}^{\frac{3}{2}}}\right) X_{n}\left( x\right) $$

At $y=0$ the above gives

$$ 0=\sum_{n=1}^{\infty}\left( D_{n}+E_{n}-\frac{2C}{aB\lambda_{n}^{\frac{3}{2} }}\right) \sin\left( \sqrt{\lambda_{n}}x\right) $$

Therefore

\begin{equation} D_{n}+E_{n}-\frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}=0\tag{4} \end{equation}

And at $y=2b$

$$ 0=\sum_{n=1}^{\infty}\left( D_{n}e^{\sqrt{\frac{B}{A}\lambda_{n}}2b} +E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}}2b}-\frac{2C}{aB\lambda_{n}^{\frac {3}{2}}}\right) \sin\left( \sqrt{\lambda_{n}}x\right) $$

Therefore

\begin{equation} D_{n}e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda _{n}}2b}-\frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}=0\tag{5} \end{equation}

Solving (4,5) for $D_{n},E_{n}$ gives

\begin{align*} D_{n} & =\frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}\frac{1}{1+e^{\sqrt{\frac {B}{A}\lambda_{n}}2b}}\\ E_{n} & =\frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}\frac{e^{\sqrt{\frac{B} {A}\lambda_{n}}2b}}{1+e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}} \end{align*}

Therefore the final solution from (1A) becomes

\begin{align*} u\left( x,y\right) & =\sum_{n=1,3,5,\cdots}^{\infty}\left( D_{n} e^{\sqrt{\frac{B}{A}\lambda_{n}}y}+E_{n}e^{-\sqrt{\frac{B}{A}\lambda_{n}} y}-\frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}\right) X_{n}\left( x\right) \\ & =\sum_{n=1,3,5,\cdots}^{\infty}\left( \left( \frac{2C}{aB\lambda _{n}^{\frac{3}{2}}}\frac{1}{1+e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}}\right) e^{\sqrt{\frac{B}{A}\lambda_{n}}y}+\left( \frac{2C}{aB\lambda_{n}^{\frac {3}{2}}}\frac{e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}}{1+e^{\sqrt{\frac{B} {A}\lambda_{n}}2b}}\right) e^{-\sqrt{\frac{B}{A}\lambda_{n}}y}-\frac {2C}{aB\lambda_{n}^{\frac{3}{2}}}\right) \sin\left( \sqrt{\lambda_{n} }x\right) \end{align*}

Where $\lambda_{n}=\left( \frac{n\pi}{2a}\right) ^{2}$. Switching back to original coordinates using $\tilde{x}=x+a$, and $\tilde{y}=y+b$, then the above is

$$ u\left( x,y\right) =\sum_{n=1,3,5,\cdots}^{\infty}\left( \left( \frac {2C}{aB\lambda_{n}^{\frac{3}{2}}}\frac{1}{1+e^{\sqrt{\frac{B}{A}\lambda_{n} }2b}}\right) e^{\sqrt{\frac{B}{A}\lambda_{n}}\left( y+b\right) }+\left( \frac{2C}{aB\lambda_{n}^{\frac{3}{2}}}\frac{e^{\sqrt{\frac{B}{A}\lambda_{n} }2b}}{1+e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}}\right) e\left( ^{-\sqrt {\frac{B}{A}\lambda_{n}}y+b}\right) -\frac{2C}{aB\lambda_{n}^{\frac{3}{2}} }\right) \sin\left( \sqrt{\lambda_{n}}\left( x+a\right) \right) $$

Where $C=-2\theta AB$, hence

\begin{align*} u\left( x,y\right) & =\sum_{n=1,3,5,\cdots}^{\infty}\left( \left( \frac{-4\theta AB}{aB\lambda_{n}^{\frac{3}{2}}}\frac{1}{1+e^{\sqrt{\frac{B} {A}\lambda_{n}}2b}}\right) e^{\sqrt{\frac{B}{A}\lambda_{n}}\left( y+b\right) }+\left( \frac{-4\theta AB}{aB\lambda_{n}^{\frac{3}{2}}} \frac{e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}}{1+e^{\sqrt{\frac{B}{A}\lambda_{n} }2b}}\right) e^{-\sqrt{\frac{B}{A}\lambda_{n}}\left( y+b\right) } +\frac{4\theta AB}{aB\lambda_{n}^{\frac{3}{2}}}\right) \sin\left( \sqrt{\lambda_{n}}\left( x+a\right) \right) \\ & =\sum_{n=1,3,5,\cdots}^{\infty}\left( \left( \frac{-4\theta A} {a\lambda_{n}^{\frac{3}{2}}}\frac{1}{1+e^{\sqrt{\frac{B}{A}\lambda_{n}}2b} }\right) e^{\sqrt{\frac{B}{A}\lambda_{n}}\left( y+b\right) }+\left( \frac{-4\theta A}{a\lambda_{n}^{\frac{3}{2}}}\frac{e^{\sqrt{\frac{B}{A} \lambda_{n}}2b}}{1+e^{\sqrt{\frac{B}{A}\lambda_{n}}2b}}\right) e^{-\sqrt {\frac{B}{A}\lambda_{n}}\left( y+b\right) }+\frac{4\theta A}{a\lambda _{n}^{\frac{3}{2}}}\right) \sin\left( \sqrt{\lambda_{n}}\left( x+a\right) \right) \end{align*}

Verification against NDsolve

Test 1

ClearAll[a, b, A, B, z, n, x, y, u, lam]; 
a = 1; b = 5; A = 1; B = 2; theta = 3; 
(*analytic*)
lam = ((n*Pi)/(2*a))^2; 
term1 = 1/(1 + Exp[Sqrt[(B/A)*lam]*2*b]); 
term2 = (4*theta*A)/(a*lam^(3/2)); 
mysol[maxTerms_, x_, y_] := 
  Sum[(((-term2)*term1)*
       Exp[Sqrt[(B/A)*lam]*(y + b)] + ((-term2)*term1*
         Exp[Sqrt[(B/A)*lam]*(2*b)])*
       Exp[(-Sqrt[(B/A)*lam])*(y + b)] + term2)*
         Sin[Sqrt[lam]*(x + a)], {n, 1, maxTerms, 2}]; 
(*numeric*)
pde = D[u[x, y], {x, 2}]/A + D[u[x, y], {y, 2}]/B == -2*theta; 
bc = {u[x, -b] == 0, u[x, b] == 0, u[-a, y] == 0, u[a, y] == 0}; 
sol = NDSolve[{pde, bc}, u, {x, -a, a}, {y, -b, b}]; 

Compare 3D

Grid[{{Plot3D[Evaluate[u[x, y] /. sol], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Numerical"], 
   Plot3D[mysol[15, x, y], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Analytical"]}}]

Mathematica graphics

compare contour

Grid[{{ContourPlot[Evaluate[u[x, y] /. sol], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "NDSolve"], 
   ContourPlot[mysol[25, x, y], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Analytical"]}}]

Mathematica graphics

Test 2

ClearAll[a, b, A, B, z, n, x, y, u, lam]; 
a = 3; b = 18; A = 7; B = -2; theta = -10; 
lam = ((n*Pi)/(2*a))^2; 
term1 = 1/(1 + Exp[Sqrt[(B/A)*lam]*2*b]); 
term2 = (4*theta*A)/(a*lam^(3/2)); 
mysol[maxTerms_, x_, y_] := 
  Sum[(((-term2)*term1)*
       Exp[Sqrt[(B/A)*lam]*(y + b)] + ((-term2)*term1*
         Exp[Sqrt[(B/A)*lam]*(2*b)])*
       Exp[(-Sqrt[(B/A)*lam])*(y + b)] + term2)*
         Sin[Sqrt[lam]*(x + a)], {n, 1, maxTerms, 2}]; 

pde = D[u[x, y], {x, 2}]/A + D[u[x, y], {y, 2}]/B == -2*theta; 
bc = {u[x, -b] == 0, u[x, b] == 0, u[-a, y] == 0, u[a, y] == 0}; 
sol = NDSolve[{pde, bc}, u, {x, -a, a}, {y, -b, b}]; 

Compare 3D

Grid[{{Plot3D[Evaluate[u[x, y] /. sol], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Numerical"], 
   Plot3D[mysol[15, x, y], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Analytical"]}}]

Mathematica graphics

Compare contour

Grid[{{ContourPlot[Evaluate[u[x, y] /. sol], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "NDSolve"], 
   ContourPlot[mysol[25, x, y], {x, -a, a}, {y, -b, b}, 
    PlotLabel -> "Analytical"]}}]

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Thank you so much for the solution! It gave me a serious lesson in maths! I tried to check the analytical solution against the solution that I have and there is a problem but I don't understand where. The next step is to calculate $GJ=2\int_{-b}^b \left(\int_{-a}^a u(x,y) \, dx\right) \, dy$ then $\beta=\frac{GJ}{Ab^{3}a}$. Setting $A=B$, $b=a$ and $z=1$ should produce $\beta=0.1405$ but the analytical solution above does not unfortunately. $\endgroup$
    – enea19
    Commented Mar 14, 2019 at 3:40
  • $\begingroup$ @enea19 No problem, it is was an interesting PDE. I verified the analytical solution using different values for the parameters and they all agree with Mathematica's NDSolve. So it is possible the other solution you have has some typo in it. $\endgroup$
    – Nasser
    Commented Mar 14, 2019 at 3:43
  • $\begingroup$ @enea19 may be you are doing something wrong with the integration code. I do not know. $\endgroup$
    – Nasser
    Commented Mar 14, 2019 at 3:50

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.