Software for crank-nicholson method

In summary, the Matlab PDE toolbox was not successful in solving this problem. I think that you must specify your equation in the form- \nabla ( c \nabla N) + a N = f. This should be the case with the matlab-f function.
  • #1
NiclasN
4
0
Hi,

I try to numerically solve the following partial differential equation for N(r,z) with a Dirichlet boundary condition.

[tex]-\frac{\partial^2N}{\partial r^2}-\frac{\partial^2N}{\partial z^2} + f(r,z) \frac{\partial N}{\partial r} + g(r,z) \frac{\partial N}{\partial z} = h(r,z)[/tex]

Mathematica is apparently not able to do it, because it is not an initial value problem. I also wasn't successful with the MATLAB pde tool. The Crank-Nicolson approximation seems to be the right way to go.

My question is which is the best software for solving this problem, so that I don't have to implement the algorithm myself.

Thanks a lot :)
 
Physics news on Phys.org
  • #2
Maybe I should have colled the thread more accurately "numerical solution to a 2nd order pde with dirchlet boundary conditions". Is there no software that can solve this without discretizing it "by hand"?
 
  • #3
By "Matlab PDE tool", do you mean the Matlab PDE toolbox? How did it fail? I was under the impression that it should be able to solve such a problem.
 
  • #4
Yes, I meant the toolbox. I failed because I could not specify this form of equation. It's not a time dependent equation in the sense that you have one variable (t) that occurs only in first derivative. There is first and second derivatives in both variables. Also I think for the toolbox you have to write the equation in "gradient form" for cartesian variables.
The problem stems from a steady state diffusion equation in cylindrical coordinates, symmetric in phi. The boundary condition is N=0 on the boundary of the cylinder.
I would of course be glad if I was wrong and it can be done with Matlab.
 
  • #5
I think that in the Matlab PDE toolbox you must specify your equation in the form

[tex] - \nabla ( c \nabla N) + a N = f [/tex]

(where f is not the same as your f). I think you can find c such that your equation can be written on that form. And the matlab-f would be c*h where h is your h... The first order derivatives on your N would come from the term where the nabla above acts on c, which would determine c.

The (r,z) domain is a rectangle. You know the Dirichlet boundary condition N=0 e.g. at r=1 and z=0 and z=1, since that is the boundary of the solid cylinder you are working with (modulo units of length...)

You also need a condition at r=0. But by your angular symmetry, isn't that just a Neumann condition at r=0, since the r-derivative of N is zero at r=0 since the 3d problem is rotationally invariant about the z-axis?

Its just something to consider, if you hadn't before, or if you hadn't seen that form of the equation to be specified in Matlab. Good luck!
 
  • #6
Thanks a lot! I did not consider that c can be a matrix with coefficients dependent on (r,z) i.e. (x,y) but apparently this is possible so maybe you are right. I'll try again.
 

Related to Software for crank-nicholson method

1. What is the crank-nicholson method?

The crank-nicholson method is a numerical algorithm used to solve partial differential equations. It is a combination of the implicit and explicit methods, making it more accurate and stable compared to other numerical methods.

2. How does the crank-nicholson method work?

The crank-nicholson method works by using a weighted average of the current and future time steps to approximate the solution of a partial differential equation. This results in a more accurate solution compared to using only one time step.

3. What is the benefit of using software for the crank-nicholson method?

Using software for the crank-nicholson method allows for faster and more accurate calculations compared to manual calculations. It also allows for the solution of more complex and large-scale problems that would be difficult to solve by hand.

4. Are there any limitations to using software for the crank-nicholson method?

One limitation of using software for the crank-nicholson method is the need for appropriate programming skills and knowledge of the method. Additionally, the accuracy of the solution may be affected by the step size and boundary conditions chosen by the user.

5. What are some common applications of the crank-nicholson method?

The crank-nicholson method is commonly used in fields such as fluid dynamics, heat transfer, and quantum mechanics to solve partial differential equations. It can also be applied to problems in finance, such as option pricing and risk management.

Similar threads

  • Differential Equations
Replies
8
Views
4K
Replies
2
Views
1K
  • Differential Equations
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
1K
  • Differential Equations
Replies
5
Views
2K
  • Differential Equations
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
1K
Replies
8
Views
2K
  • Mechanical Engineering
Replies
1
Views
696
Back
Top