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