def test_shallow_sphere(): """Test solution of shallow water equations on the sphere.""" import Rossby_wave def verify_shallow_sphere(claw): import os import numpy as np from clawpack.pyclaw.util import check_diff test_q = claw.frames[-1].state.get_q_global() test_height = test_q[0,:,:] thisdir = os.path.dirname(__file__) data_filename='swsphere_height.txt' expected_height = np.loadtxt(os.path.join(thisdir,data_filename)) test_err = np.linalg.norm(expected_height-test_height) expected_err = 0 return check_diff(expected_err, test_err, abstol=1e-4) from clawpack.pyclaw.util import test_app kwargs = {} kwargs['disable_output']= True return test_app(Rossby_wave.setup, verify_shallow_sphere, kwargs)
def verify_shocksine(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt(os.path.join(thisdir, "shocksine_regression_density.txt")) test_density = test_solution[0, :] test_err = np.linalg.norm(expected_density - test_density) return check_diff(0, test_err, abstol=1.0e-4) return test_app(shocksine.setup, verify_shocksine, {})
def verify_shocksine(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt( os.path.join(thisdir, 'shocksine_regression_density.txt')) test_density = test_solution[0, :] test_err = np.linalg.norm(expected_density - test_density) return check_diff(0, test_err, abstol=1.e-4) return test_app(shocksine.setup, verify_shocksine, {})
def test_woodward_colella_blast(): """ tests against expected sharpclaw results """ import woodward_colella_blast from clawpack.pyclaw.util import test_app, check_diff def verify_woodward_colella_blast(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt(os.path.join(thisdir,'blast_regression_density.txt')) test_density = test_solution[0,:] return check_diff(expected_density, test_density, reltol=1.e-5,delta=controller.solution.grid.delta) return test_app(woodward_colella_blast.setup, verify_woodward_colella_blast, {})
def test_advection_reaction(): """ tests against expected sharpclaw results """ from clawpack.pyclaw.examples.advection_reaction_2d import advection_reaction from clawpack.pyclaw.util import test_app, check_diff def verify_advection_reaction(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt(os.path.join(thisdir,'advection_reaction.txt')) test_density = test_solution[0,:,:] return check_diff(expected_density, test_density, reltol=1.e-5,delta=controller.solution.grid.delta) return test_app(advection_reaction.setup, verify_advection_reaction, {})
def test_shocksine(): """ tests against expected sharpclaw results """ from . import shocksine from clawpack.pyclaw.util import test_app, check_diff def verify_shocksine(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt(os.path.join(thisdir,'shocksine_regression_density.txt')) test_density = test_solution[0,:] test_err = np.linalg.norm(expected_density-test_density) return check_diff(0, test_err, abstol=1.e-4) return test_app(shocksine.setup, verify_shocksine, {})
def test_woodward_colella_blast(): """ tests against expected sharpclaw results """ import woodward_colella_blast from clawpack.pyclaw.util import test_app, check_diff def verify_woodward_colella_blast(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution != None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt( os.path.join(thisdir, 'blast_regression_density.txt')) test_density = test_solution[0, :] test_err = np.linalg.norm(expected_density - test_density) return check_diff(0, test_err, abstol=1.e-4) return test_app(woodward_colella_blast.setup, verify_woodward_colella_blast, {})
def test_shallow_sphere(): """ test shallow sphere """ try: import problem import classic2 except ImportError: import warnings warnings.warn( "missing extension modules, running python setup.py build_ext -i") import subprocess import os thisdir = os.path.dirname(__file__) subprocess.check_call('python setup.py build_ext -i', shell=True, cwd=thisdir) from shallow_4_Rossby_Haurwitz_wave import shallow_4_Rossby_Haurwitz def verify_shallow_sphere(claw): import os import numpy as np from clawpack.pyclaw.util import check_diff test_q = claw.frames[-1].state.get_q_global() test_height = test_q[0, :, :] thisdir = os.path.dirname(__file__) data_filename = 'swsphere_height.txt' expected_height = np.loadtxt(os.path.join(thisdir, data_filename)) test_err = np.linalg.norm(expected_height - test_height) expected_err = 0 return check_diff(expected_err, test_err, abstol=1e-4) from clawpack.pyclaw.util import test_app kwargs = {} kwargs['disable_output'] = True return test_app(shallow_4_Rossby_Haurwitz, verify_shallow_sphere, kwargs)
def test_shallow_sphere(): """Test solution of shallow water equations on the sphere.""" from . import Rossby_wave def verify_shallow_sphere(claw): import os import numpy as np from clawpack.pyclaw.util import check_diff test_q = claw.frames[-1].state.get_q_global() test_height = test_q[0, :, :] thisdir = os.path.dirname(__file__) data_filename = 'swsphere_height.txt' expected_height = np.loadtxt(os.path.join(thisdir, data_filename)) test_err = np.linalg.norm(expected_height - test_height) expected_err = 0 return check_diff(expected_err, test_err, abstol=1e-4) from clawpack.pyclaw.util import test_app kwargs = {} kwargs['disable_output'] = True return test_app(Rossby_wave.setup, verify_shallow_sphere, kwargs)
def test_advection_reaction(): """ tests against expected sharpclaw results """ from clawpack.pyclaw.examples.advection_reaction_2d import advection_reaction from clawpack.pyclaw.util import test_app, check_diff def verify_advection_reaction(controller): """ given an expected value, returns a verification function """ import numpy as np import os test_solution = controller.solution.state.get_q_global() if test_solution is not None: thisdir = os.path.dirname(__file__) expected_density = np.loadtxt( os.path.join(thisdir, 'advection_reaction.txt')) test_density = test_solution[0, :, :] return check_diff(expected_density, test_density, reltol=1.e-5, delta=controller.solution.grid.delta) return test_app(advection_reaction.setup, verify_advection_reaction, {})
def test_shallow_sphere(): """ test shallow sphere """ try: import problem import classic2 except ImportError: import warnings warnings.warn("missing extension modules, running python setup.py build_ext -i") import subprocess import os thisdir = os.path.dirname(__file__) subprocess.check_call('python setup.py build_ext -i', shell=True, cwd=thisdir) from shallow_4_Rossby_Haurwitz_wave import shallow_4_Rossby_Haurwitz def verify_shallow_sphere(claw): import os import numpy as np from clawpack.pyclaw.util import check_diff test_q = claw.frames[-1].state.get_q_global() test_height = test_q[0,:,:] thisdir = os.path.dirname(__file__) data_filename='swsphere_height.txt' expected_height = np.loadtxt(os.path.join(thisdir,data_filename)) test_err = np.linalg.norm(expected_height-test_height) expected_err = 0 return check_diff(expected_err, test_err, abstol=1e-4) from clawpack.pyclaw.util import test_app kwargs = {} kwargs['disable_output']= True return test_app(shallow_4_Rossby_Haurwitz, verify_shallow_sphere, kwargs)