Skip to content

Commit

Permalink
Fix numerical scheme for heat equation
Browse files Browse the repository at this point in the history
1. Squares on spacial step sizes were missing in second-order  derivatives
2. Steps were dx in both x and y directions
  • Loading branch information
zhmurov committed Aug 12, 2024
1 parent 8055603 commit 662d676
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions content/2.04_HeatEquation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ With the grid defined, one can use the following explicit approximation for the

.. math::
\frac{U^{n+1}_{i,j}-U^{n}_{i,j}}{dt}=a\left(\frac{U^n_{i-1,j}-2U^{n}_{i,j}+U^n_{i+1,j}}{dx} + \frac{U^n_{i,j-1}-2U^{n}_{i,j}+U^n_{i,j+1}}{dx}\right)
\frac{U^{n+1}_{i,j}-U^{n}_{i,j}}{dt}=a\left(\frac{U^n_{i-1,j}-2U^{n}_{i,j}+U^n_{i+1,j}}{{dx}^{2}} + \frac{U^n_{i,j-1}-2U^{n}_{i,j}+U^n_{i,j+1}}{{dy}^{2}}\right)
Here we used basic approximations for the first and second derivatives :math:`\frac{df}{dx}\approx\frac{f(x+dx)-f(x)}{dx}` and :math:`\frac{d^2f}{dx^2}\approx\frac{f(x-dx)-2f(x)+f(x+dx)}{dx^2}`.
In the equation above, the values on the next time step, :math:`U^{n+1}_{i,j}` are unknown.
Expand All @@ -54,7 +54,7 @@ The numerical scheme can then be rearranged to give an explicit expression for t

.. math::
U^{n+1}_{i,j}= U^{n}_{i,j} + dh\cdot a\left(\frac{U^n_{i-1,j}-2U^{n}_{i,j}+U^n_{i+1,j}}{dx} + \frac{U^n_{i,j-1}-2U^{n}_{i,j}+U^n_{i,j+1}}{dx}\right)
U^{n+1}_{i,j}= U^{n}_{i,j} + dh\cdot a\left(\frac{U^n_{i-1,j}-2U^{n}_{i,j}+U^n_{i+1,j}}{{dx}^{2}} + \frac{U^n_{i,j-1}-2U^{n}_{i,j}+U^n_{i,j+1}}{{dy}^{2}}\right)
And this is the expression we are going to use in our code.

Expand Down

0 comments on commit 662d676

Please sign in to comment.