Coverage for pySDC/projects/parallelSDC_reloaded/jacobiElliptic_setup.py: 100%
29 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 21:22:52 2023
6Setup script for the JacobianElliptic problem
7"""
8import numpy as np
9import matplotlib.pyplot as plt
11from pySDC.projects.parallelSDC_reloaded.utils import solutionExact, getParamsRK, getParamsSDC, solutionSDC
13script = __file__.split('/')[-1].split('.')[0]
15tEnd = 10
16nSteps = 100
18useRK = True
19if useRK:
20 rkScheme = "RK4"
21 params = getParamsRK(rkScheme)
22else: # pragma: no cover
23 nNodes = 4
24 nSweeps = 5
25 quadType = 'RADAU-RIGHT'
26 nodeType = 'LEGENDRE'
27 qDelta = "MIN-SR-S"
28 params = getParamsSDC(quadType, nNodes, qDelta, nSweeps, nodeType)
30pName = "JACELL"
31periodic = False
32pParams = {}
34tVals = np.linspace(0, tEnd, nSteps + 1)
36print("Computing ODE solution")
37uExact = solutionExact(tEnd, nSteps, pName, **pParams)
39uNum, counters, _ = solutionSDC(tEnd, nSteps, params, pName, **pParams)
41figName = f"{script}_solution"
42plt.figure(figName)
43plt.plot(tVals, uExact[:, 0], '-', label="u1-exact")
44plt.plot(tVals, uExact[:, 1], '-', label="u2-exact")
45plt.plot(tVals, uExact[:, 2], '-', label="u3-exact")
46plt.plot(tVals, uNum[:, 0], '--', label="u1-num")
47plt.plot(tVals, uNum[:, 1], '--', label="u2-num")
48plt.plot(tVals, uNum[:, 2], '--', label="u3-num")
50plt.legend()
51plt.xlabel("time")
52plt.ylabel("solution")
53plt.tight_layout()