Diffusion Equation with source term

In summary, the conversation is about solving a diffusion equation with a source term using finite differences method. The equation is dT/dt = d2T/dx2 + S(x), where S(x) is a Gaussian profile. The problem is solving the equation numerically in either MATLAB or C++. The suggested methods are the Crank-Nicolson method and the Forward Euler method. The latter is simpler but less accurate due to the non-linear source term.
  • #1
iva.mn87
1
0
I have been asked to solve a diffusion equation with a source term using finite differences method. I need to numerically integrate the following equation either in MATLAB or C++.

The equation is

dT/dt = d2T/dx2 + S(x)

The form of S(x) is some function given by a Gaussian profile.

Could anyone have a solution to the problem!

Thanks!
 
Physics news on Phys.org
  • #2
What exactly is the problem? How far have you gotten?

I've been working on the same problem, and I solved it by using the Crank-Nicolson method. Look it up on e.g. Wikipedia.

A worse, but far simpler method (especially since the source is non-linear) is to use the Forward Euler method:
[tex]\frac{T(x,t+\Delta t)-T(x,t)}{\Delta t} = \frac{T(x-\Delta x,t)-2T(x,t)+T(x+\Delta x,t)}{(\Delta x)^2} + S(x)[/tex]

Solve for [tex]T(x,t+\Delta t)[/tex] and you get
[tex]T(x,t+\Delta t) = \frac{T(x-\Delta x,t)-2T(x,t)+T(x+\Delta x,t)}{(\Delta x)^2}\Delta t + S(x)\Delta t+T(x,t)[/tex]

So if you know the value of T(x,t) for every x at some time t, you can calculate the value for a future time [tex]t+\Delta t[/tex]
 
  • #3


I understand your question and can offer some guidance on how to approach solving this diffusion equation with a source term using finite differences method. First, it is important to understand the physical meaning of the equation. The term dT/dt represents the rate of change of temperature over time, while d2T/dx2 represents the spatial variation of temperature. The source term, S(x), represents a function that adds or removes heat from the system at a given position x.

To solve this equation numerically, you will need to discretize the equation in both time and space. This means dividing the domain into a grid and approximating the derivatives using finite difference approximations. Once the equation is discretized, you can use a numerical solver in MATLAB or C++ to solve the resulting system of equations.

One approach to solving this type of problem is to use an explicit finite difference scheme, where the temperature at each grid point is updated based on the temperature at neighboring grid points and the source term. Another approach is to use an implicit scheme, where the temperature at each grid point is updated based on the temperature at the previous time step and the source term.

It is also important to consider the stability and accuracy of your numerical solution. The stability of the solution will depend on the time and space discretization parameters, while the accuracy can be improved by using a finer grid or higher-order finite difference approximations.

In conclusion, solving a diffusion equation with a source term using finite differences method can be achieved by discretizing the equation and using a numerical solver. However, it is important to carefully consider the discretization parameters and the stability and accuracy of the solution to ensure reliable results.
 

1. What is the diffusion equation with source term?

The diffusion equation with source term is a partial differential equation that describes the behavior of a diffusing substance in a medium with a source of the substance. It takes into account both the diffusion of the substance and the rate at which it is being produced or consumed at a given location.

2. How is the diffusion equation with source term derived?

The diffusion equation with source term is derived from Fick's second law of diffusion, which states that the rate of diffusion is proportional to the concentration gradient of the diffusing substance. The source term is added to account for any additional production or consumption of the substance.

3. What are the applications of the diffusion equation with source term?

The diffusion equation with source term has many applications in various fields such as physics, chemistry, biology, and engineering. It is commonly used to model diffusion processes in materials, chemical reactions, and biological systems.

4. What are the boundary conditions for the diffusion equation with source term?

The boundary conditions for the diffusion equation with source term vary depending on the specific problem being modeled. However, some common boundary conditions include specifying the concentration of the diffusing substance at the boundaries, as well as any flux or source terms at the boundaries.

5. What numerical methods are used to solve the diffusion equation with source term?

There are several numerical methods that can be used to solve the diffusion equation with source term, such as finite difference methods, finite element methods, and spectral methods. The choice of method depends on the specific problem and the desired level of accuracy.

Similar threads

Replies
0
Views
314
Replies
8
Views
2K
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
Replies
4
Views
2K
  • Differential Equations
Replies
7
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Biology and Chemistry Homework Help
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
41
Views
8K
  • Differential Equations
Replies
2
Views
2K
Back
Top