1#!/usr/bin/env python3 2# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 3# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 4# All Rights reserved. See files LICENSE and NOTICE for details. 5# 6# This file is part of CEED, a collection of benchmarks, miniapps, software 7# libraries and APIs for efficient high-order finite element and spectral 8# element discretizations for exascale applications. For more information and 9# source code availability see http://github.com/ceed. 10# 11# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 12# a collaborative effort of two U.S. Department of Energy organizations (Office 13# of Science and the National Nuclear Security Administration) responsible for 14# the planning and preparation of a capable exascale ecosystem, including 15# software, applications, hardware, advanced system engineering and early 16# testbed platforms, in support of the nation's exascale computing imperative. 17 18import numpy as np 19import pandas as pd 20from pylab import * 21from matplotlib import use 22 23 24def plot(): 25 # Load the data 26 runs = pd.read_csv("conv_test_result.csv") 27 colors = ['orange', 'red', 'navy', 'green', 'magenta', 28 'gray', 'blue', 'purple', 'pink', 'black'] 29 res = 'mesh_res' 30 fig, ax = plt.subplots() 31 # Arbitrary coefficients 32 C = [2.2e-2, .24e0, .22e0, .7e0, 2.5e0, 33 3e0, 3.5e0, 4e0, 4.5e0, 5e0] 34 i = 0 35 for group in runs.groupby('degree'): 36 data = group[1] 37 data = data.sort_values('rel_error') 38 p = data['degree'].values[0] 39 h = 1/data[res] 40 H = C[i] * h**p # H = C h^p 41 E = data['rel_error'] 42 log_h = np.log10(h) 43 log_H = np.log10(H) 44 ax.loglog(h, E, 'o', color=colors[i]) 45 m, b = np.polyfit(log_h, log_H, 1) 46 ax.loglog(h, 10**b * h**m, '--', color=colors[i], label='O(h^' + str(p) + ')') 47 i = i + 1 48 49 ax.legend(loc='best') 50 ax.set_xlabel('h') 51 ax.set_ylabel('Relative Error') 52 ax.set_title('Convergence by h Refinement') 53 xlim(.03, .3) 54 fig.tight_layout() 55 plt.savefig('conv_plt_h.png', bbox_inches='tight') 56 57 58if __name__ == "__main__": 59 plot() 60