def test(self): labels = ['L2u', 'L2v', 'L2p'] df1 = run_spatial('plane-poiseuille-flow.i', 7, "velocity_interp_method='average'", 'two_term_boundary_expansion=false', "--error", "--error-unused", y_pp=labels, mpi=16) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('plane-poiseuille-average-first.png') for key, value in fig.label_to_slope.items(): if key == 'L2p': self.assertTrue(fuzzyAbsoluteEqual(value, 1., .1)) else: self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def secondary_and_primary_plots(self, fine, num_refinements, additional_cli_args, name, plots_to_do=None, mpi=1): if not plots_to_do: if (fine == 2): plots_to_do = ['same'] else: plots_to_do = ['coarse_secondary', 'coarse_primary'] fig = mms.ConvergencePlot('Element Size ($h$)', ylabel='$L_2$ Error') second_order = False for cli_arg in additional_cli_args: if "SECOND" in cli_arg: second_order = True if second_order: deltas = [0, 0.1] else: deltas = [0, 0.4] for delta in deltas: if 'coarse_primary' in plots_to_do: self.do_plot('continuity.i', num_refinements, ["Mesh/left_block/ny="+str(fine), "Mesh/left_block/nx="+str(fine), "Constraints/mortar/delta="+str(delta)] + \ additional_cli_args, fig, "coarse_primary_"+str(delta), mpi) if 'coarse_secondary' in plots_to_do: self.do_plot('continuity.i', num_refinements, ["Mesh/right_block/ny="+str(fine), "Mesh/right_block/nx="+str(fine), "Constraints/mortar/delta="+str(delta)] + \ additional_cli_args, fig, "coarse_secondary_"+str(delta), mpi) if 'same' in plots_to_do: self.do_plot('continuity.i', num_refinements, ["Constraints/mortar/delta="+str(delta)] + additional_cli_args, fig, "same_"+str(delta), mpi) fig.set_title(name) fig.save(name+'.png') return fig
def test(self): df1 = run_spatial('2d-rc.i', 6, y_pp=['L2u', 'L2v', 'L2p'], mpi=16) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u', 'L2v', 'L2p'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('rc-2d.png') for key,value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 2., .15))
def test(self): labels = ['L2u', 'L2v', 'L2p', 'L2t'] df1 = mms.run_spatial('2d-average-with-temp.i', 7, "velocity_interp_method='rc'", y_pp=labels, mpi=16) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('2d-rc-with-temp.png') for key,value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def test(self): labels = ['L2u', 'L2v', 'L2p'] df1 = run_spatial('rotated-pp-flow.i', 6, "velocity_interp_method='rc'", "--error", y_pp=labels, mpi=8) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('plane-poiseuille-rc.png') for key,value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def test(self): labels = ['L2rho', 'L2rho_u', 'L2rho_et'] df1 = run_spatial('hllc-mms.i', list(range(6,12)), "--allow-test-objects", "--error", y_pp=labels, mpi=6) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('hllc.png') for key,value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 1., .05))
def test(self): labels = ['L2u', 'L2v', 'L2p'] df1 = mms.run_spatial('2d-average.i', 6, y_pp=labels) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('2d-average.png') for key,value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) if key == 'L2p': self.assertTrue(fuzzyAbsoluteEqual(value, 1., .1)) else: self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def test(self): df1 = mms.run_spatial('advection-diffusion-reaction.i', 7, mpi=2) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label='compact-adr', marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('compact-adr.png') for _,value in fig.label_to_slope.items(): self.assertTrue(fuzzyEqual(value, 2., .05))
def test(self): df1 = mms.run_spatial('steady-adapt.i', 7, mpi=8) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label='steady-adapt', marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('steady-adapt.png') for _,value in fig.label_to_slope.items(): self.assertTrue(fuzzyEqual(value, 1., .05))
def test(self): df1 = mms.run_spatial('advection-outflow.i', 7, y_pp=['L2u', 'L2v']) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u', 'L2v'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('outflow.png') for label, value in fig.label_to_slope.items(): if label == 'L2u': self.assertTrue(fuzzyAbsoluteEqual(value, 1., .05)) else: self.assertTrue(fuzzyAbsoluteEqual(value, 2., .05))
def test(self): df1 = mms.run_spatial('limited-advection.i', 9, "FVKernels/advection_u/limiter='vanLeer'", y_pp=['L2u']) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('vanLeer-limiter.png') for label, value in fig.label_to_slope.items(): self.assertTrue(fuzzyAbsoluteEqual(value, 2., .05))
def test(self): df1 = mms.run_spatial('skewed.i', 5, 'Variables/v/face_interp_method=average', mpi=1) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label='average', marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('average.png') for _, value in fig.label_to_slope.items(): self.assertTrue(fuzzyEqual(value, 1., .15))
def test(self): df1 = mms.run_spatial( 'kt-limited-advection.i', 11, "FVKernels/advection_u/limiter='central_difference'", y_pp=['L2u']) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('kt-cd-limiter.png') for key, value in fig.label_to_slope.items(): self.assertTrue(fuzzyAbsoluteEqual(value, 2., .05)) print("%s slope, %f" % (key, value))
def test(self): df1 = mms.run_spatial( 'skewed.i', 5, 'Variables/v/face_interp_method=skewness-corrected FVKernels/advection/advected_interp_method=skewness-corrected', mpi=1) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label='corrected-advection', marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('corrected-advection.png') for _, value in fig.label_to_slope.items(): self.assertTrue(fuzzyEqual(value, 2.0, .1))
def secondary_and_primary_plots(self, fine, num_refinements, additional_cli_args, name, plots_to_do=None, mpi=1): if not plots_to_do: if (fine == 2): plots_to_do = ['same'] else: plots_to_do = ['coarse_secondary', 'coarse_primary'] fig = mms.ConvergencePlot('Element Size ($h$)', ylabel='$L_2$ Error') if 'coarse_primary' in plots_to_do: self.do_plot('gap-conductance.i', num_refinements, ["Mesh/left_block/ny="+str(fine), "Mesh/left_block/nx="+str(fine)] + \ additional_cli_args, fig, "coarse_primary", mpi) if 'coarse_secondary' in plots_to_do: self.do_plot('gap-conductance.i', num_refinements, ["Mesh/right_block/ny="+str(fine), "Mesh/right_block/nx="+str(fine)] + \ additional_cli_args, fig, "coarse_secondary", mpi) if 'same' in plots_to_do: self.do_plot('gap-conductance.i', num_refinements, additional_cli_args, fig, "same", mpi) fig.set_title(name) fig.save(name + '.png') return fig
def test(self): labels = ['L2u', 'L2v', 'L2p'] df1 = run_spatial('2d-rc-rz-symmetry.i', list(range(1, 6)), "--error", y_pp=labels, mpi=8) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('2d-rc-rz-symmetry.png') for key, value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def test(self): df1 = run_spatial('pressure-interpolation-corrected.i', 7, "--error", "--error-unused", "--error-deprecated", y_pp=['L2u', 'L2v', 'L2p'], mpi=8) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u', 'L2v', 'L2p'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('pressure-interpolation-corrected.png') for key, value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) self.assertTrue(fuzzyAbsoluteEqual(value, 2., .1))
def test(self): velocity_labels = ['L2u', 'L2v'] pressure_labels = ['L2p'] labels = velocity_labels + pressure_labels df1 = run_spatial('skewed-vortex.i', 5, y_pp=labels, mpi=2) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=labels, marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('skewed.png') for key, value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) if key in velocity_labels: self.assertTrue(fuzzyAbsoluteEqual(value, 2., .2)) else: self.assertTrue(fuzzyAbsoluteEqual(value, 1., .2))
def secondary_and_primary_plots(self, num_refinements, additional_cli_args, name, plots_to_do=None, mpi=1): fig = mms.ConvergencePlot('Element Size ($h$)', ylabel='$L_2$ Error') has_tets = True for cli_arg in additional_cli_args: if "hex" in cli_arg: has_tets = False if has_tets: deltas = [0.1] else: deltas = [0.1] for delta in deltas: self.do_plot('continuity.i', num_refinements, ["Constraints/mortar/delta=" + str(delta)] + additional_cli_args, fig, str(delta), mpi) fig.set_title(name) fig.save(name + '.png') return fig
def test(self): df1 = run_spatial('1d-rc-no-diffusion.i', 5, "--error", "--error-unused", "--error-deprecated", y_pp=['L2u', 'L2p']) fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=['L2u', 'L2p'], marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('1d-rc-no-diffusion.png') for key, value in fig.label_to_slope.items(): print("%s, %f" % (key, value)) if (key == 'L2u'): self.assertTrue(fuzzyAbsoluteEqual(value, 1.5, .1)) else: self.assertTrue(fuzzyAbsoluteEqual(value, 1., .1))
def run_each_test(testName, hyperConvergent=False, refinementNo=5): df1 = mms.run_spatial(testName + '.i', refinementNo, console=False, executable='../../../heat_conduction-opt') if (not hyperConvergent): df2 = mms.run_spatial(testName + '.i', refinementNo, 'Mesh/second_order=true', 'Variables/u/order=SECOND', console=False, executable='../../../heat_conduction-opt') fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label=r'EDGE2 (1$^{st}$-order) $\hat{p}_O$', marker='o') if (not hyperConvergent): fig.plot(df2, label='EDGE3 (2$^{nd}$-order) $\hat{p}_O$', marker='D') fig.save(testName + '_spatial.png') df1.to_csv(testName + '_first_order.csv') if (not hyperConvergent): df2.to_csv(testName + '_second_order.csv')
#!/usr/bin/env python3 import mms df1 = mms.run_spatial('advection-diffusion.i', 7, "GlobalParams/advected_interp_method='upwind'") fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error') fig.plot(df1, label='upwind-adv-diff', marker='o', markersize=8, num_fitted_points=3, slope_precision=1) fig.save('upwind-advection-diffusion.png')
def runConvergenceTest(input_file, additional_cli_args, dt, image_filename): df1 = mms.run_temporal(input_file, N, 'Executioner/TimeIntegrator/type=ExplicitEuler ' + additional_cli_args, file_base='ee_{}', console=False, dt=dt, y_pp='l2_err', executable=EXE) df2 = mms.run_temporal( input_file, N, 'Executioner/TimeIntegrator/type=ActuallyExplicitEuler ' + additional_cli_args, file_base='aee_{}', console=False, dt=dt, y_pp='l2_err', executable=EXE) df3 = mms.run_temporal( input_file, N, 'Executioner/TimeIntegrator/type=ExplicitSSPRungeKutta Executioner/TimeIntegrator/order=1 ' + additional_cli_args, file_base='ssprk1_{}', console=False, dt=dt, y_pp='l2_err', executable=EXE) df4 = mms.run_temporal( input_file, N, 'Executioner/TimeIntegrator/type=ExplicitSSPRungeKutta Executioner/TimeIntegrator/order=2 ' + additional_cli_args, file_base='ssprk2_{}', console=False, dt=dt, y_pp='l2_err', executable=EXE) df5 = mms.run_temporal( input_file, N, 'Executioner/TimeIntegrator/type=ExplicitSSPRungeKutta Executioner/TimeIntegrator/order=3 ' + additional_cli_args, file_base='ssprk3_{}', console=False, dt=dt, y_pp='l2_err', executable=EXE) fig = mms.ConvergencePlot(xlabel='$\Delta t$', ylabel='$L_2$ Error') fig.plot(df1, label='ExplicitEuler', marker='+', markersize=8) fig.plot(df2, label='ActuallyExplicitEuler', marker='x', markersize=8) fig.plot(df3, label='SSP Runge-Kutta 1', marker='o', markersize=8, markerfacecolor='none') fig.plot(df4, label='SSP Runge-Kutta 2', marker='v', markersize=8) fig.plot(df5, label='SSP Runge-Kutta 3', marker='s', markersize=8) fig.save(image_filename)
#!/usr/bin/env python3 #* This file is part of the MOOSE framework #* https://www.mooseframework.org #* #* All rights reserved, see COPYRIGHT for full restrictions #* https://github.com/idaholab/moose/blob/master/COPYRIGHT #* #* Licensed under LGPL 2.1, please see LICENSE for details #* https://www.gnu.org/licenses/lgpl-2.1.html import mms df1 = mms.run_temporal('mms_temporal.i', 4, console=False, executable='../../../test') df2 = mms.run_temporal('mms_temporal.i', 4, 'Executioner/scheme=bdf2', console=False, executable='../../../test') fig = mms.ConvergencePlot(xlabel='$\Delta t$', ylabel='$L_2$ Error') fig.plot(df1, label='1st Order (Implicit Euler)', marker='o', markersize=8) fig.plot(df2, label='2nd Order (Backward Difference)', marker='o', markersize=8) fig.save('mms_temporal.png') #TESTING (leave this comment, it is used in doco to remove the following from a demo) df1.to_csv('mms_temporal_first.csv') df2.to_csv('mms_temporal_second.csv')