Coverage for pySDC/projects/parallelSDC_reloaded/scripts/fig02_stab.py: 100%
40 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 14:51 +0000
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Created on Wed Jan 10 12:02:55 2024
6Stability plots (on Dahlquist) for the article
7"""
8import os
9import numpy as np
11from pySDC.projects.parallelSDC_reloaded.utils import getParamsSDC, solutionSDC, plotStabContour, plt
12from pySDC.helpers.testing import DataChecker
14data = DataChecker(__file__)
16PATH = '/' + os.path.join(*__file__.split('/')[:-1])
17SCRIPT = __file__.split('/')[-1].split('.')[0]
19# Script parameters
20zoom = 2
21reLims = -4.5 * zoom, 0.5 * zoom
22imLims = -3.5 * zoom, 3.5 * zoom
23nVals = 251
25# Collocation parameters
26nNodes = 4
27nodeType = "LEGENDRE"
28quadType = "RADAU-RIGHT"
30# Configuration
31# (qDeltaType)
32config = [
33 "PIC",
34 "MIN-SR-NS",
35 "MIN-SR-S",
36 "MIN-SR-FLEX",
37 "LU",
38 "VDHS",
39]
42# -----------------------------------------------------------------------------
43# Script execution
44# -----------------------------------------------------------------------------
46# Problem instanciation
47reVals = np.linspace(*reLims, num=nVals)
48imVals = np.linspace(*imLims, num=nVals)
49lambdas = reVals[None, :] + 1j * imVals[:, None]
51# Scheme instanciation
52for qDeltaType in config:
53 if qDeltaType == "MIN-SR-S":
54 fac = 5
55 reVals *= fac
56 imVals *= fac
57 lambdas *= fac
59 for nSweeps in [1, 2, 3, 4]:
60 params = getParamsSDC(quadType, nNodes, qDeltaType, nSweeps, nodeType)
62 uNum, counters, parallel = solutionSDC(1, 1, params, 'DAHLQUIST', lambdas=lambdas.ravel())
64 uEnd = uNum[-1, :].reshape(lambdas.shape)
65 stab = np.abs(uEnd)
67 figName = f"{qDeltaType}_K{nSweeps}"
68 plt.figure(figName)
70 plotStabContour(reVals, imVals, stab)
71 data.storeAndCheck(f"{SCRIPT}_{figName}", stab[::5, -50])
73 plt.xticks(fontsize=8)
74 plt.yticks(fontsize=8)
75 plt.title(f"$K={nSweeps}$", fontsize=10)
76 plt.gcf().set_size_inches(2.5, 2.5)
77 plt.tight_layout()
78 plt.savefig(f"{PATH}/{SCRIPT}_{figName}.pdf")
80data.writeToJSON()