Peano
Loading...
Searching...
No Matches
plotSolutionErrorTwoGrid.py
Go to the documentation of this file.
1import numpy as np
2import re
3import matplotlib.pyplot as plt
4import matplotlib.animation as animation
5import time
6
7from verification.postProcess import parse_patch_file, plot_field_dg, construct_dg_function
8
9MaxNorm = []
10for i in range(0,219,1):
11 file_name = f"DGPoisson.solution-{i}.peano-patch-file"
12 dg_solution = parse_patch_file(file_name, "DG")
13
14 # Construct the exact solution for the same mesh
15 exact_solution = construct_dg_function(dg_solution, [1/9,1/9])
16
17 # Construct the difference dg_solution - exact_solution
18 # Zeros
19 diff = {key: [0] * len(value) for key, value in dg_solution.items()}
20 max_norm = 0.0
21 for key in dg_solution.keys():
22 diff[key] = [ (val_sol - val_ex) for val_sol, val_ex in zip(dg_solution[key], exact_solution[key]) ]
23 max_norm = max( np.max(np.abs(diff[key])), max_norm )
24
25 MaxNorm.append(max_norm)
26 print(max_norm)
27
28 # plot_field_dg(dg_solution, [1/9,1/9])
29 # plt.title(f'|dg_sov - exact_sol|_max = {max_norm}')
30 # plt.show()
31
32plt.plot(MaxNorm, label='|sol_dg - sol_exact|_max', marker='o')
33plt.yscale('log')
34plt.xlabel('DG Iterations')
35plt.ylabel('|sol_dg - sol_exact|_max')
36plt.show()
37
38# Plot resulting solution
39plot_field_dg(diff, [1/9,1/9])
40plt.title(f'|dg_sov - exact_sol|_max = {max_norm}')
41plt.show()
42