-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumGy_LV07E.qmd
127 lines (99 loc) · 3.74 KB
/
NumGy_LV07E.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
title: "Numerical Simulation Methods in Geophysics, Exercise 7:<br> Timestepping with FE"
subtitle: "1. MGPY+MGIN"
author: "[email protected]"
title-slide-attributes:
data-background-image: pics/tubaf-logo.png
data-background-size: 20%
data-background-position: 10% 95%
format:
tubaf-revealjs:
html-math-method: mathjax
chalkboard: true
include-in-header:
- text: |
<script>
window.MathJax = {
loader: {
load: ['[tex]/physics']
},
tex: {
packages: {'[+]': ['physics']}
}
};
</script>
slide-number: c/t
transition: slide
transition-speed: fast
menu:
side: left
# jupyter: python3
---
# Recap Poisson and heat equations
## Recap
* [x] solve the Poisson equation for arbitrary $x$ and $a$
* [x] sources and $a$ contrasts cause curvature in $u$<br>
* positive source or $a$ increase $\Rightarrow$ negative u" $\Rightarrow$ maximum
* single $f$ $\Rightarrow$ piecewise linear, full $f$ $\Rightarrow$ parabola
* [x] Dirichlet BC determine shift (& slope if double)
* [x] Neumann BC determine slope of $u$
* [x] accuracy (compare analytical) depends on discretization
* [x] now go for instationary (parabolic) problem by time stepping
* curvature in $u$ causes negative change of $u$
# Time stepping
## Time stepping - explicit method
$$ \pdv{T}{t} - a \pdv[2]{T}{z} = 0 $$
Finite-difference approximation
$$ \pdv{T}{t}^n \approx \frac{T^{n+1}-T^n}{\Delta t} = a \pdv[2]{T^n}{z} $$
## Explicit
:::: {.columns}
::: {.column}
Start $T^0$ with initial condition (e.g. 0)
Update field by
$$ T^{n+1} = T^n + a \pdv[2]{T^n}{z} \cdot \Delta t$$
E.g. by using the matrix $A$
:::
::: {.column}
![Forward stencil](pics/dtforward.svg)
:::
::::
## Implicit methods
:::: {.columns}
::: {.column}
$$ \pdv{T}{t}^{n+1} \approx \frac{T^{n+1}-T^n}{\Delta t} = a \pdv[2]{T}{z} ^{n+1} $$
$$ \frac{1}{\Delta t} T^{n+1} - a \pdv[2]{T}{z} ^{n+1} = \frac{1}{\Delta t} T^n $$
$$ (\vb M - \vb A) \vb u^{n+1} = \vb M \vb u^n $$
$\vb M$ - mass matrix
:::
::: {.column}
![Backward stencil](pics/dtbackward.svg)
:::
::::
## Mixed - Crank-Nicholson method
$$ \pdv{T}{t}^{n+1/2} \approx \frac{T^{n+1}-T^n}{\Delta t} = \frac12 a \pdv[2]{T}{z} ^n + \frac12 a \pdv[2]{T}{z} ^{n+1} $$
:::: {.columns}
::: {.column width="60%"}
$$ \frac{2}{\Delta t} T^{n+1} - a \pdv[2]{T^{n+1}}{z} =
\frac{2}{\Delta t} T^n + a \pdv[2]{T^n}{z} $$
$$ (2\vb M - \vb A) \vb u^{n+1} = (2\vb M + \vb A) \vb u^n $$
<!-- $$ \pdv{T}{t}^n \approx \frac{T^{n+1}-T^n}{\Delta t} = \frac12 a \pdv[2]{T}{z} ^n + \frac12 a \pdv[2]{T}{z} ^{n+1} $$ -->
:::
::: {.column width="40%"}
![Mixed forward/backward stencil](pics/dtmixed.svg)
:::
::::
# Report
## Task
1. Complete functions delivering both stiffness matrix and right-hand-side vector using FE discretizations
1. Use a non-equidistant discretization of the Earth with increasing layer thicknesses (choose and substantiate).
1. Solve instationary heat equation with periodic boundary condition (yearly cycle) for the Earth using a constant but meaningfull thermal diffusivity.
1. Compare the solutions using explicit, implicit and mixed timestepping methods with the analytical solution.
## Questions
* Interpret the results in terms of physical behaviour. How does a change in the diffusivity affect the result.
* Is there a difference between FD and FE discretizations? Why (not)?
* Make a statement about the stability and accuracy of the methods.
* After which time approaches the numeric solution the analytical one?
* How can you evaluate the numerical accuracy if there is not analytical solution?
## Deliverables
Format can be Jupyter Notebook and/or PDF
Complete codes to run the results