Coverage for pySDC / projects / parallelSDC_reloaded / jacobiElliptic_setup.py: 100%

29 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-27 07:06 +0000

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3""" 

4Created on Thu Dec 7 21:22:52 2023 

5 

6Setup script for the JacobianElliptic problem 

7""" 

8 

9import numpy as np 

10import matplotlib.pyplot as plt 

11 

12from pySDC.projects.parallelSDC_reloaded.utils import solutionExact, getParamsRK, getParamsSDC, solutionSDC 

13 

14script = __file__.split('/')[-1].split('.')[0] 

15 

16tEnd = 10 

17nSteps = 100 

18 

19useRK = True 

20if useRK: 

21 rkScheme = "RK4" 

22 params = getParamsRK(rkScheme) 

23else: # pragma: no cover 

24 nNodes = 4 

25 nSweeps = 5 

26 quadType = 'RADAU-RIGHT' 

27 nodeType = 'LEGENDRE' 

28 qDelta = "MIN-SR-S" 

29 params = getParamsSDC(quadType, nNodes, qDelta, nSweeps, nodeType) 

30 

31pName = "JACELL" 

32periodic = False 

33pParams = {} 

34 

35tVals = np.linspace(0, tEnd, nSteps + 1) 

36 

37print("Computing ODE solution") 

38uExact = solutionExact(tEnd, nSteps, pName, **pParams) 

39 

40uNum, counters, _ = solutionSDC(tEnd, nSteps, params, pName, **pParams) 

41 

42figName = f"{script}_solution" 

43plt.figure(figName) 

44plt.plot(tVals, uExact[:, 0], '-', label="u1-exact") 

45plt.plot(tVals, uExact[:, 1], '-', label="u2-exact") 

46plt.plot(tVals, uExact[:, 2], '-', label="u3-exact") 

47plt.plot(tVals, uNum[:, 0], '--', label="u1-num") 

48plt.plot(tVals, uNum[:, 1], '--', label="u2-num") 

49plt.plot(tVals, uNum[:, 2], '--', label="u3-num") 

50 

51plt.legend() 

52plt.xlabel("time") 

53plt.ylabel("solution") 

54plt.tight_layout()