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