-
Notifications
You must be signed in to change notification settings - Fork 29
/
lecture5_ex3.jl
49 lines (36 loc) · 1.95 KB
/
lecture5_ex3.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
md"""
## Exercise 3 — **Unit tests**
"""
#md # 👉 See [Logistics](/logistics/#submission) for submission details.
md"""
The goal of this exercise is to:
- Implement basic unit tests for the diffusion and acoustic 2D scripts
- Group the tests in a test-set
"""
md"""
For this exercise, you will implement a test set of basic unit tests using Julia's built-in testing infrastructure to verify the implementation of the diffusion and acoustic 2D solvers.
"""
md"""
### Task 1
In the `Pf_diffusion_2D` folder, duplicate the `Pf_diffusion_2D_perf_loop_fun.jl` script and rename it `Pf_diffusion_2D_test.jl`.
Implement a test set using `@testset` and `@test` macros from Test.jl in order to test `Pf[xtest, ytest]` and assess that the values returned are approximatively equal to the following ones for the given values of `nx = ny`. Make sure to set `do_check = false` i.e. to ensure the code to run 500 iterations.
"""
xtest = [5, Int(cld(0.6*lx, dx)), nx-10]
ytest = Int(cld(0.5*ly, dy))
md"""
for
"""
nx = ny = 16 * 2 .^ (2:5) .- 1
maxiter = 500
md"""
should match
| `nx, ny` | `Pf[xtest, ytest]` |
|:--------:|:-----------------------------------------------------------------:|
| `63` | `[0.00785398056115133 0.007853980637555755 0.007853978592411982]` |
| `127` | `[0.00787296974549236 0.007849556884184108 0.007847181374079883]` |
| `255` | `[0.00740912103848251 0.009143711648167267 0.007419533048751209]` |
| `511` | `[0.00566813765849919 0.004348785338575644 0.005618691590498087]` |
Report the output of the test set as code block in a new section of the `README.md` in the `Pf_diffusion_2D` folder.
"""
#nb # > 💡 hint: Use triple backticks to generate code blocks in the `README.md` ([more](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks)).
#md # \note{Use triple backticks to generate code blocks in the `README.md` ([more](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks)).}