コード例 #1
0
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)
コード例 #2
0
ファイル: implicit_plot.py プロジェクト: zachhardy/moose
#!/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('implicit_convergence.i', 4, file_base='implicitmidpoint_{}'
                       'Executioner/TimeIntegrator/type=ImplicitMidpoint',
                       console=False, dt=0.0625, y_pp='l2_err', executable='../../../../test')

fig = mms.ConvergencePlot(xlabel='$\Delta t$', ylabel='$L_2$ Error')
fig.plot(df1, label='Midpoint (1nd order)', marker='o', markersize=8)
fig.save('implicit_convergence.pdf')

df1.to_csv('implicit_convergence_midpoint.csv')

"""
import matplotlib.pyplot as plt
import numpy as np

# Use fonts that match LaTeX
from matplotlib import rcParams
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 17
rcParams['font.serif'] = ['Computer Modern Roman']
rcParams['text.usetex'] = True
コード例 #3
0
#!/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')
コード例 #4
0
#* 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

N = 5
EXE = '../../../../test'

df1 = mms.run_temporal('implicit_convergence.i',
                       N,
                       'Executioner/TimeIntegrator/type=ImplicitMidpoint',
                       file_base='implicitmidpoint_{}',
                       console=False,
                       dt=0.0625,
                       y_pp='l2_err',
                       executable=EXE)

df2 = mms.run_temporal('implicit_convergence.i',
                       N,
                       'Executioner/TimeIntegrator/type=LStableDirk3',
                       file_base='lstabledirk3_{}',
                       console=False,
                       dt=0.0625,
                       y_pp='l2_err',
                       executable=EXE)

df3 = mms.run_temporal('implicit_convergence.i',
                       N,
コード例 #5
0
#!/usr/bin/env python3

# MooseDocs:start:spatial
import mms

df = mms.run_spatial('1d_analytical.i', 6, 'Mesh/gen/nx=10', console=False)
fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error')
fig.plot(df, label='1st Order', marker='o', markersize=8)
fig.save('1d_analytical_spatial.png')
# MooseDocs:end:spatial

# MooseDocs:start:temporal
import mms

df = mms.run_temporal('1d_analytical.i', 6, dt=0.5, console=False)
fig = mms.ConvergencePlot(xlabel='$\Delta t$', ylabel='$L_2$ Error')
fig.plot(df, label='2nd Order (Backward Difference)', marker='o', markersize=8)
fig.save('1d_analytical_temporal.png')
# MooseDocs:end:temporal
コード例 #6
0
ファイル: mms_temporal.py プロジェクト: jwpeterson/moose
#!/usr/bin/env python
import mms
df1 = mms.run_temporal('mms_temporal.i', 4, console=False)
df2 = mms.run_temporal('mms_temporal.i', 4, 'Executioner/scheme=bdf2', console=False)

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')
コード例 #7
0
                      4,
                      'Mesh/second_order=true',
                      'Variables/T/order=SECOND',
                      console=False)

fig = mms.ConvergencePlot(xlabel='Element Size ($h$)', ylabel='$L_2$ Error')
fig.plot(df1, label='1st Order', marker='o', markersize=8)
fig.plot(df2, label='2nd Order', marker='o', markersize=8)
fig.save('2d_mms_spatial.png')
# MooseDocs:end:spatial

# MooseDocs:start:temporal
import mms

df1 = mms.run_temporal(['2d_main.i', '2d_mms_temporal.i'],
                       4,
                       dt=1200,
                       mpi=4,
                       console=False)
df2 = mms.run_temporal(['2d_main.i', '2d_mms_temporal.i'],
                       4,
                       'Executioner/scheme=bdf2',
                       dt=1200,
                       mpi=4,
                       console=False)
fig = mms.ConvergencePlot(xlabel='$\Delta t$', ylabel='$L_2$ Error')
fig.plot(df1, label='1st Order', marker='o', markersize=8)
fig.plot(df2, label='2nd Order', marker='o', markersize=8)
fig.save('2d_mms_temporal.png')
# MooseDocs:end:temporal
コード例 #8
0
#* 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

N = 6
EXE = '../../../../test'

df1 = mms.run_temporal('explicit_convergence.i',
                       N,
                       'Executioner/TimeIntegrator/type=Heun',
                       file_base='heun_{}',
                       console=False,
                       dt=0.00390625,
                       y_pp='l2_err',
                       executable=EXE)

df2 = mms.run_temporal('explicit_convergence.i',
                       N,
                       'Executioner/TimeIntegrator/type=Ralston',
                       file_base='ralston_{}',
                       console=False,
                       dt=0.00390625,
                       y_pp='l2_err',
                       executable=EXE)

df3 = mms.run_temporal('explicit_convergence.i',
                       N,