6
$\begingroup$

As stated, I am having trouble trying to set up a Laplacian/Poisson Equation. I have boundary conditions with this too, and I've tried using the DirichletCondition function, but I don't know what I'm doing there either. (I have almost zero Mathematica experience, and the Wolfram site's help is just as confusing to me as the program.)

Laplacian[V[x, y], {x, y} == 0; V[x, 0] == 0; V[x, 0.05] == 1; V[0, y] == 0; V[0.1, y] == 0;] Plot[{x, -0.25, 0.25}, {y, -0.15, 0.15}] 

Plot I'm getting

While I am getting that plot to appear, it's not even close to what I need. What I'm needing is the solution to appear within the region 0 ≤ x ≤ 0.1 and 0 ≤ y ≤ 0.05, as stated by the boundary conditions (rectangular). It's supposed to be a distribution type of plot, kind of like elevation contour graphs and similar.

And for now, the PDE I'm solving is equal to 0, so once I get that done, how do I set up the PDE when it's not equal to 0 (Poisson's Equation)? I would think that since Laplacian is a function, I can't use it anymore since the PDE isn't equal to 0 anymore.

Help is greatly appreciated!

$\endgroup$

2 Answers 2

8
$\begingroup$

Something like this?

PDE = D[V[x, y], x, x] + D[V[x, y], y, y]; BCs = {DirichletCondition[V[x, y] == 0, y == 0], DirichletCondition[V[x, y] == 1, y == 0.05], DirichletCondition[V[x, y] == 0, x == 0], DirichletCondition[V[x, y] == 0, x == 0.1]}; ufun = NDSolveValue[{PDE == 0, BCs}, V, {x, 0, 0.1}, {y, 0, 0.05}]; ContourPlot[ufun[x, y], {x, 0, 0.1}, {y, 0, 0.05}] 

enter image description here

For Poisson equation replace PDE == 0 by PDE == f[x,y], where f[x,y] is an arbitrary function.

$\endgroup$
5
  • $\begingroup$ Oh wow, that's exactly what I needed! Also thanks for clearing up the DirichletCondition, the way you did it was much easier than what the Wolfram site had. To make sure I understand the syntax for PDE, i.e does that mean derivative of V with respect to x, and x again (to satisfy a squared partial)? $\endgroup$ Commented Feb 22, 2019 at 4:31
  • $\begingroup$ @LtGenSpartan Yes! $\endgroup$ Commented Feb 22, 2019 at 4:33
  • $\begingroup$ I actually have another question, is there a way to add legends, axes, etc. to this plot? $\endgroup$ Commented Feb 22, 2019 at 4:37
  • $\begingroup$ @LtGenSpartan Of course you can. Check the documentations on Plot. $\endgroup$ Commented Feb 22, 2019 at 4:38
  • 1
    $\begingroup$ @LtGenSpartan - FrameLabel -> Automatic, PlotLegends -> Automatic $\endgroup$ Commented Feb 22, 2019 at 4:59
3
$\begingroup$

DSolve can handle the Laplace equation if analytic is of any interest. It doesn't do well with Poisson though.

pde = D[V[x, y], x, x] + D[V[x, y], y, y] == 0 bc = {V[x, 0] == 0, V[x, 1/20] == 1, V[0, y] == 0, V[1/10, y] == 0} DSolve[{pde, bc}, V[x, y], {x, y}] // Flatten; 

It gives K[1] as the summation variable. n looks nicer.

% /. K[1] -> n (*{V[x, y] -> Inactive[Sum][(4 Csch[(n π)/2] Sin[(n π)/2]^2 Sin[10 n π x] Sinh[10 n π y])/(n π), {n, 1, ∞}]}*) 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.