Coverage for pySDC/projects/parallelSDC_reloaded/kaps_setup.py: 100%
23 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Created on Thu Dec 7 19:29:46 2023
6Setup script for the Kaps problem
7"""
8import numpy as np
9import matplotlib.pyplot as plt
11from pySDC.projects.parallelSDC_reloaded.utils import solutionExact, getParamsRK, solutionSDC
13script = __file__.split('/')[-1].split('.')[0]
15tEnd = 1
16nSteps = 100
17epsilon = 1e-3
18rkScheme = "DIRK43"
20tVals = np.linspace(0, tEnd, nSteps + 1)
22print("Computing ODE solution")
23uExact = solutionExact(tEnd, nSteps, "KAPS", epsilon=epsilon)
25params = getParamsRK(rkScheme)
26uNum, counters, parallel = solutionSDC(tEnd, nSteps, params, 'KAPS', epsilon=epsilon)
28figName = f"{script}_solution"
29plt.figure(figName)
30plt.plot(tVals, uExact[:, 0], '-', label="x-exact")
31plt.plot(tVals, uExact[:, 1], '-', label="y-exact")
32plt.plot(tVals, uNum[:, 0], '--', label="x-num")
33plt.plot(tVals, uNum[:, 1], '--', label="y-num")
35plt.legend()
36plt.xlabel("time")
37plt.ylabel("solution")
38plt.tight_layout()