Skip to content

Commit 50acc01

Browse files
committed
Assignment
1 parent 8cc6918 commit 50acc01

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

numpy/heat-equation/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Two dimension hear equation
2+
3+
Heat (or diffusion) equation is
4+
5+
<!--- Equation
6+
\frac{\partial u}{\partial t} = \alpha \nabla^2 u
7+
--->
8+
9+
![img](http://quicklatex.com/cache3/d2/ql_b3f6b8bdc3a8862c73c5a97862afb9d2_l3.png)
10+
11+
where **u(x, y, t)** is the temperature field that varies in space and time, and α is thermal diffusivity constant. The two dimensional Laplacian can be discretized with finite differences as
12+
13+
<!--- Equation
14+
\begin{align*}
15+
\nabla^2 u &= \frac{u(i-1,j)-2u(i,j)+u(i+1,j)}{(\Delta x)^2} \\
16+
&+ \frac{u(i,j-1)-2u(i,j)+u(i,j+1)}{(\Delta y)^2}
17+
\end{align*}
18+
--->
19+
20+
![img](http://quicklatex.com/cache3/2d/ql_59f49ed64dbbe76704e0679b8ad7c22d_l3.png)
21+
22+
Given an initial condition (u(t=0) = u0) one can follow the time dependence of the temperature field with explicit time evolution method:
23+
24+
<!--- Equation
25+
u^{m+1}(i,j) = u^m(i,j) + \Delta t \alpha \nabla^2 u^m(i,j)
26+
--->
27+
28+
![img](http://quicklatex.com/cache3/9e/ql_9eb7ce5f3d5eccd6cfc1ff5638bf199e_l3.png)
29+
30+
Note: Algorithm is stable only when
31+
32+
<!--- Equation
33+
\Delta t < \frac{1}{2 \alpha} \frac{(\Delta x \Delta y)^2}{(\Delta x)^2 (\Delta y)^2}
34+
--->
35+
36+
![img](http://quicklatex.com/cache3/d1/ql_0e7107049c9183d11dbb1e81174280d1_l3.png)
37+
38+
Implement two dimensional heat equation with NumPy using the initial temperature field in the file [bottle.dat](bottle.dat) (the file consists of a header and 200 x 200 data array). As a boundary condition use fixed values as given in the initial field. You can start from the skeleton code in the file [skeleton.py](skeleton.py).
39+

0 commit comments

Comments
 (0)