-
Notifications
You must be signed in to change notification settings - Fork 29
/
lecture3_ex4.jl
58 lines (44 loc) · 2.12 KB
/
lecture3_ex4.jl
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
md"""
## Exercise 4 — **Optimal iteration parameters for pseudo-transient method**
"""
#md # 👉 See [Logistics](/logistics/#submission) for submission details.
md"""
The goal of this exercise is to confirm numerically the optimality of the pseudo-transient parameters for a 1D elliptic solver (i.e., solving the steady-state diffusion).
You will make the systematic study of the convergence rate of the pseudo-transient method solving a steady-state diffusion process, varying the numerical parameter `re` on a regular grid of values.
### Getting started
1. 👉 Start from the script we did in class, or download the `l3_steady_diffusion_1D.jl` script [here](https://github.com/eth-vaw-glaciology/course-101-0250-00/blob/main/scripts/) if needed (available after the course).
2. Create a new code `steady_diffusion_parametric_1D.jl` for this exercise and add it to the `lecture3` folder in your private GitHub repo.
3. Report the results of this exercise within a new section in the `README.md`.
"""
md"""
### Task 1
Start from the 1D elliptic solver we developed in class which implements the pseudo-transient method (damping).
Add a new variable to store the range of factors to multiply the `re` parameter with to the `# numerics` section.
Add new array to store the number of iterations per grid block for each value of this factor:
```julia
# numerics
fact = 0.5:0.1:1.5
conv = zeros(size(fact))
```
Wrap the `# array initialisation` and `# iteration loop` sections of the code in a `for`-loop over indices of `fact`:
```julia
for ifact in eachindex(fact)
# array initialisation
...
# iteration loop
while ...
end
end
```
Move the definition of `ρ` to the beginning of the new loop. Extract the value `2π` and store in the variable `re`, multiplying by the corresponding value from `fact`:
```julia
for ifact in eachindex(fact)
re = 2π*fact[ifact]
ρ = (lx/(dc*re))^2
dτ = ...
...
end
```
After every elliptic solve, store the `iter/nx` value in the `conv[ifact]`. Report the results as a figure, plotting the `conv` vs `fact`. You should get a picture like this:
![checkmark](./figures/l3_checkmark.png)
"""