Solving a partial differential equation

Hi together,
I want to solve the following partial differential equation numerically with Julia:

d/dx f(x,y) = 1/y * (y^2* f(x,y) + d/dy f(x,y) + d^2/dy^2 f(x,y))

Has anyone an idea how to do this?

1 Like

Take a look at https://github.com/gridap/Gridap.jl

This uses the finite element method. Another possibility is the package Approxfun.jl for a spectral approach.

The best approach will depend on the equation and domain and your specific needs.

Hello @Physics_Student Welcome to Julia! We are a friendly community and you will get help here.
Please continue to ask questions. As @Paulo_Jabardo says it would be interesting if you gave us more background.

There are entire graduate courses devoted to this topic, so it is not easy to answer your question in one post. You first need to transform your differential equation into a set of discretized algebraic equations using Taylor series approximations. The simplest approach for this is the Finite Difference Method. Using this method will define a grid of points (xᵢ, yᵢ) which will be the independent variables to an algebraic matrix equation (that can be solved by a computer unlike a differential equation). You then need to iterate an initial guess for f(xᵢ, yᵢ) through the matrix equation until the solution for f converges. The simplest iteration method is the Jacobi Method.

There are more complex discretization approaches like the Finite Element Method and Finite Volume Method which provide better accuracy than the Finite Difference Method for certain problems. There are also more complex iteration techniques like gradient methods and implicit methods that can increase speed or stability over Jacobi.

There are probably Julia packages that can do some of these steps for you, but I haven’t looked into that side of Julia myself yet.

Thank you very much! This was a very good idea.

For standard central/upwind difference scheme, you can use DiffEqOperator.

1 Like

It depends also on the context and other data (domain, initial/boundary conditions, …).

  1. Is x a time-like variable? Your equation looks a bit like a diffusion-advection-reaction system (time x and space y). If so, you could use a semidiscretization in y and apply an ODE solver to the resulting semidiscrete system.
  2. Do you have to deal with the possible singularity at y = 0 or are you far away from y = 0? Your choice may depend on this.
  3. What kind of initial/boundary conditions do you want to use?

Yes, you are right @ranocha : x can be understood as a time-like variable.
I have to deal with the boundary condition as I need the solution for y in (0,2.5).
I want to use the following boundary condition:

  1. d/dy f(x,y=0) = 0
    and 2) f(0, y) = MAXIMUM(0, (1-y^2)^3)

Then you need to find a good way to deal with the singularity at y = 0 (I don’t have a suggestion, sorry). The second derivative of your initial condition ((1 - y^2)^3) contains a constant term. Thus, you get a 1/y singularity of your right-hand side at y = 0. Are you sure that your problem is well-posed?

Also, the initial condition isn’t smooth (it abruptly changes slope at y = 1), so you have to pay attention to that when you select your numerical technique and/or your discretization. For example, a high resolution finite volume technique should cope with that - more care necessary with a finite difference technique.