-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_pintError.py
executable file
·45 lines (34 loc) · 1.03 KB
/
02_pintError.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 22 09:25:12 2022
@author: tlunet
"""
import numpy as np
from blockops import BlockProblem
import blockops.plots as plt
plt = plt.Plotly
zoom = 1
reLam = np.linspace(-4/zoom, 0.5/zoom, 256)
imLam = np.linspace(-3/zoom, 3/zoom, 256)
nBlocks = 10
nPoints = 1
scheme = 'RK4'
nStepsF = 10
nStepsG = 1
algoName = 'Parareal'
lam = reLam[:, None] + 1j*imLam[None, :]
prob = BlockProblem(
lam.ravel(), tEnd=nBlocks, nBlocks=nBlocks, nPoints=nPoints,
scheme='RungeKutta', rkScheme=scheme, nStepsPerPoint=nStepsF)
prob.setApprox('RungeKutta', rkScheme=scheme, nStepsPerPoint=nStepsG)
algo = prob.getBlockIteration(algoName)
uNum = prob.getSolution('fine')
uPar = algo(nIter=2)
err = np.abs(uNum-uPar)
stab = np.abs(uPar)[-1, -1, :, -1].reshape(lam.shape)
errEnd = err[-1, -1, :, -1].reshape(lam.shape)
errMax = np.max(err[-1], axis=(0, -1)).reshape(lam.shape)
err = errMax
# Plot discretization error on complex plane
plt.plotAccuracyContour(reLam, imLam, err, stab).show()