Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

Is there public code in Matlab for solving the Laplace equation in polar coordinates in a circular domain?

I tried a lot but my level of Matlab and Mathematica is not good enough, but still not quite understand the scheme. Excuse my English but I'm from Peru.

Consider the equation of Laplace

$\frac{1}{r}\frac{\partial}{\partial r}\left(r\frac{\partial u}{\partial r}\right)+\frac{1}{r^2}\frac{\partial^2u}{\partial\theta^2}=0$

with $0\leq r\leq R$ y $0\leq \theta \leq 2\pi$. We will use a mesh $r_i=i\Delta R$ and $\theta_j=j\Delta\theta$. We approximate the equation with the squeme:

$\frac{1}{r_i}\left(r_{i+1/2}\frac{u_{i+1j}-u_{ij}}{\Delta r}-r_{j-1/2}\frac{u_{ij}-u_{i-1j}}{\Delta r}\right)\frac{1}{\Delta r}+\frac{1}{r_i^2}\frac{u_{ij+1}-2u_{ij}+u_{ij-1}}{\Delta\theta^2}=0$

where $u_{ij}M$ and $f_{ij}$ are mesh functions $(r_i,\theta_j)=(i\Delta r,j\Delta\theta)$. The functions are periodic in the angular index $j$ with period $J=2\pi/\Delta\theta$ and $u_{0j}$ is independent of the value of $j$.

To derive the condition of the source Laplace equation integrate on the disk $D$ with radius $\varepsilon$, obtaining

$\int\int_D frdrd\theta=\int\int_D\frac{1}{r}\left[\frac{\partial}{\partial r}\left(r\frac{\partial u}{\partial r}\right)\right] + \frac{1}{r^2}\frac{\partial^2u}{\partial\theta^2}rdrd\theta$

$\int_0^2\pi \frac{\partial u}{\partial r}\varepsilon d\theta$

Now, choosing $\varepsilon$ = $\Delta j/2$ and approximating this relation by

$f(0)\left(\frac{\Delta r}{2}\right)^2\pi=\sum\frac{u_{1j}-u_0}{\Delta r}\frac{\Delta r}{2}\Delta\theta$

$u_{0j}$ is independent $j$, let's call $u_0$ we have

$u_0=\frac{1}{J}\sum u_{ij}-f(0)\left(\frac{\Delta r}{2}\right)^2$ as $f(0)=0$ then $u_0=\frac{1}{J}\sum u_{ij}$

share|improve this question
    
What's your question? –  Dan Nov 15 '12 at 21:09
    
anyone have the code in matlab to solve laplace differential equation in polar coordinates in a Circular Domain? –  Alma Nov 15 '12 at 21:33
    
Hello Alma, and welcome to scicomp! Could you write out your finite difference scheme for the equation that you are solving in polar coordinates? –  Paul Nov 15 '12 at 21:46
    
Ready, I put the schema and the problem with more details –  Alma Nov 16 '12 at 3:02
    
@Alma: What part of this scheme is giving you the most difficult with your previous implementations? –  Paul Nov 16 '12 at 3:19

1 Answer 1

You could use pdepe and turn Laplace's equation into a BVP, then solve it with a multiple shooting method. This solution is not a turnkey solution, but it does use MATLAB built-in functions.

Alternately, you could set up the equations you've written in matrix form; these are algebraic and you should be able to solve them using an LU decomposition (if they're linear; use the matrix backslash operator) or a Newton-Raphson-like approach (if they're nonlinear; use fsolve).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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