def verify_acoustics_io(controller):
        """ Verifies I/O on 2d variable-coefficient acoustics application"""
        import os
        from clawpack.pyclaw.util import check_diff
        from clawpack.pyclaw import Solution

        thisdir = os.path.dirname(__file__)
        verify_dir = os.path.join(thisdir, './io_test_verification')

        # Expected solution
        sol_0_expected = Solution()
        sol_0_expected.read(0,
                            path=verify_dir,
                            file_format='ascii',
                            file_prefix=None,
                            read_aux=True)
        expected_aux = sol_0_expected.state.aux

        sol_20_expected = Solution()
        sol_20_expected.read(20,
                             path=verify_dir,
                             file_format='ascii',
                             file_prefix=None,
                             read_aux=False)
        expected_q = sol_20_expected.state.q

        # Test solution
        sol_0_test = Solution()
        sol_0_test.read(0,
                        path=controller.outdir,
                        file_format=controller.output_format,
                        file_prefix=None,
                        read_aux=True,
                        options=controller.output_options)
        test_aux = sol_0_test.state.get_aux_global()

        sol_20_test = Solution()
        sol_20_test.read(20,
                         path=controller.outdir,
                         file_format=controller.output_format,
                         file_prefix=None,
                         read_aux=False,
                         options=controller.output_options)
        test_q = sol_20_test.state.get_q_global()

        if test_q is not None:
            q_err = check_diff(expected_q, test_q, reltol=1e-6)
            if q_err is not None:
                return q_err
        else:
            return

        if test_aux is not None:
            aux_err = check_diff(expected_aux, test_aux, reltol=1e-6)
            if aux_err is not None:
                return aux_err
        else:
            return
    def verify_acoustics_io(controller):
        """ Verifies I/O on 2d variable-coefficient acoustics application"""
        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np
        from pyclaw import Solution

        thisdir = os.path.dirname(__file__)
        verify_dir = os.path.join(thisdir, "./io_test_verification")

        # Expected solution
        sol_0_expected = Solution()
        sol_0_expected.read(0, path=verify_dir, file_format="ascii", file_prefix=None, read_aux=True)
        expected_aux = sol_0_expected.state.aux

        sol_20_expected = Solution()
        sol_20_expected.read(20, path=verify_dir, file_format="ascii", file_prefix=None, read_aux=False)
        expected_q = sol_20_expected.state.q

        # Test solution
        sol_0_test = Solution()
        sol_0_test.read(
            0, path=controller.outdir, file_format=controller.output_format, file_prefix=None, read_aux=True
        )
        test_aux = sol_0_test.state.get_aux_global()

        sol_20_test = Solution()
        sol_20_test.read(
            20, path=controller.outdir, file_format=controller.output_format, file_prefix=None, read_aux=False
        )
        test_q = sol_20_test.state.get_q_global()

        test_passed = True
        if test_q is not None:
            q_err = check_diff(expected_q, test_q, reltol=1e-4)
            if q_err is not None:
                test_passed = False
        else:
            return

        if test_aux is not None:
            aux_err = check_diff(expected_aux, test_aux, reltol=1e-4)
            if aux_err is not None:
                test_passed = False
        else:
            return

        if test_passed:
            return None
        else:
            return ([q_err[0], aux_err[0]], [q_err[1], aux_err[1]], q_err[2])
    def verify_acoustics_io(controller):
        """ Verifies I/O on 2d variable-coefficient acoustics application"""
        import os
        from clawpack.pyclaw.util import check_diff
        from clawpack.pyclaw import Solution
        
        thisdir = os.path.dirname(__file__)
        verify_dir = os.path.join(thisdir,'./io_test_verification')
        
        # Expected solution
        sol_0_expected = Solution()
        sol_0_expected.read(0,path=verify_dir,file_format='ascii',
                               file_prefix=None,read_aux=True)
        expected_aux = sol_0_expected.state.aux

        sol_20_expected = Solution()
        sol_20_expected.read(20,path=verify_dir,file_format='ascii',
                               file_prefix=None,read_aux=False)
        expected_q = sol_20_expected.state.q

        # Test solution
        sol_0_test = Solution()
        sol_0_test.read(0,path=controller.outdir,
                        file_format=controller.output_format,
                        file_prefix=None,read_aux=True,
                        options=controller.output_options)
        test_aux = sol_0_test.state.get_aux_global()

        sol_20_test = Solution()
        sol_20_test.read(20,path=controller.outdir,
                        file_format=controller.output_format,
                        file_prefix=None,read_aux=False,
                        options=controller.output_options)
        test_q = sol_20_test.state.get_q_global()


        if test_q is not None:
            q_err = check_diff(expected_q, test_q, reltol=1e-6)
            if q_err is not None:
                return q_err
        else:
            return

        if test_aux is not None:
            aux_err = check_diff(expected_aux, test_aux, reltol=1e-6)
            if aux_err is not None:
                return aux_err
        else:
            return
Example #4
0
    def acoustics_verify_homogeneous(return_tuple):
        from clawpack.pyclaw.util import check_diff

        if return_tuple != None:
            test_final_difference = return_tuple[1]
            return check_diff(0.00286, test_final_difference, abstol=1e-4)
        return
Example #5
0
    def verify_sedov(controller):
        import os
        from clawpack.pyclaw.util import check_diff
        from clawpack.pyclaw import Solution
        
        thisdir = os.path.dirname(__file__)
        verify_dir = os.path.join(thisdir,'./Sedov_regression')
        
        # Expected solution
        sol_expected = Solution()
        sol_expected.read(1,path=verify_dir,file_format='hdf',read_aux=False)
        expected_q = sol_expected.state.q

        # Test solution
        sol_test = Solution()
        sol_test.read(1,path=controller.outdir,
                        file_format=controller.output_format,
                        read_aux=False,
                        options=controller.output_options)
        test_q = sol_test.state.get_q_global()


        if test_q is not None:
            q_err = check_diff(expected_q, test_q, reltol=1e-6)
            if q_err is not None:
                return q_err
        else:
            return
Example #6
0
    def acoustics_verify_homogeneous(return_tuple):
        from clawpack.pyclaw.util import check_diff

        if return_tuple != None:
            test_final_difference = return_tuple[1]
            return check_diff(0.00286, test_final_difference, abstol=1e-4)
        return
Example #7
0
    def verify_sedov(controller):
        import os
        from clawpack.pyclaw.util import check_diff
        from clawpack.pyclaw import Solution
        
        thisdir = os.path.dirname(__file__)
        verify_dir = os.path.join(thisdir,'./Sedov_regression')

        # Expected solution
        sol_expected = Solution()
        sol_expected.read(1,path=verify_dir,file_format='hdf',read_aux=False)
        assert sol_expected.t == 0.1
        expected_q = sol_expected.state.q

        # Test solution
        sol_test = Solution()
        sol_test.read(1,path=controller.outdir,
                        file_format=controller.output_format,
                        read_aux=False,
                        options=controller.output_options)
        test_q = sol_test.state.get_q_global()


        if test_q is not None:
            q_err = check_diff(expected_q, test_q, reltol=1e-6)
            if q_err is not None:
                return q_err
        else:
            return
Example #8
0
        def verify(controller):
            """ verifies gauge values generated by 2d psystem application 
            from a previously verified run """

            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff

            test_state = controller.solution.state

            gauge_files = test_state.grid.gauge_files
            test_gauge_data_mem = test_state.gauge_data
            expected_gauges = []
            thisdir = os.path.dirname(__file__)

            expected_list = []
            error_list = []
            test_passed = True
            if test_gauge_data_mem is not None:
                for i, gauge in enumerate(gauge_files):
                    test_gauge_data_io = np.loadtxt(gauge.name)
                    verify_file = os.path.join(
                        thisdir, 'verify_' + gauge.name.split('/')[-1])
                    expected_gauges.append(np.loadtxt(verify_file))
                    return_value_mem = check_diff(expected_gauges[i],
                                                  test_gauge_data_mem[i],
                                                  reltol=1e-4)
                    return_value_io = check_diff(expected_gauges[i],
                                                 test_gauge_data_io,
                                                 reltol=1e-4)

                    if (return_value_mem is not None
                            or return_value_io is not None):
                        expected_list.append(return_value_mem[0])
                        error_list.append(
                            [return_value_mem[1], return_value_io[1]])
                        test_passed = False

                if test_passed:
                    return None
                else:
                    return (expected_list, error_list, return_value_io[2], '')
            else:
                return
Example #9
0
        def verify(controller):
            """ verifies gauge values generated by 2d psystem application 
            from a previously verified run """
            
            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff

            test_state = controller.solution.state

            gauge_files = test_state.grid.gauge_files
            test_gauge_data_mem = test_state.gauge_data
            expected_gauges=[]
            thisdir = os.path.dirname(__file__)
            
            expected_list=[]
            error_list=[]
            test_passed = True
            if test_gauge_data_mem is not None:
                for i, gauge in enumerate(gauge_files):
                    test_gauge_data_io = np.loadtxt(gauge.name)
                    verify_file = os.path.join(thisdir,'verify_' +
                                               gauge.name.split('/')[-1])
                    expected_gauges.append(np.loadtxt(verify_file))
                    return_value_mem = check_diff(expected_gauges[i], 
                                                  test_gauge_data_mem[i], 
                                                  reltol=1e-4)
                    return_value_io = check_diff(expected_gauges[i], 
                                                 test_gauge_data_io, 
                                                 reltol=1e-4)
                    
                    if (return_value_mem is not None or
                        return_value_io is not None):
                        expected_list.append(return_value_mem[0])
                        error_list.append([return_value_mem[1],return_value_io[1]])
                        test_passed = False


                if test_passed:
                    return None
                else:
                    return(expected_list, error_list,return_value_io[2] ,'')
            else:
                return
    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)
Example #11
0
    def acoustics_verify_heterogeneous(return_tuple):
        import os
        import numpy as np
        from clawpack.pyclaw.util import check_diff

        if return_tuple != None:
            test_pfinal = return_tuple[0]
            thisdir = os.path.dirname(__file__)
            verify_pfinal = np.loadtxt(os.path.join(thisdir,'verify_classic_heterogeneous.txt'))
            norm_err = np.linalg.norm(test_pfinal-verify_pfinal)
            return check_diff(0, norm_err, abstol=2e-1)
        return
Example #12
0
    def acoustics_verify_homogeneous(claw):
        from clawpack.pyclaw.util import check_diff
        import numpy as np

        pinitial = claw.frames[0].state.get_q_global()
        pfinal   = claw.frames[claw.num_output_times].state.get_q_global()

        pinitial = pinitial[0,:,:,:].reshape(-1)
        pfinal   = pfinal[0,:,:,:].reshape(-1)
        grid = claw.solution.state.grid
        final_difference =np.prod(grid.delta)*np.linalg.norm(pfinal-pinitial,ord=1)

        return check_diff(0., final_difference, abstol=1e-1)
Example #13
0
    def acoustics_verify_heterogeneous(return_tuple):
        import os
        import numpy as np
        from clawpack.pyclaw.util import check_diff

        if return_tuple != None:
            test_pfinal = return_tuple[0]
            thisdir = os.path.dirname(__file__)
            verify_pfinal = np.loadtxt(
                os.path.join(thisdir, 'verify_classic_heterogeneous.txt'))
            norm_err = np.linalg.norm(test_pfinal - verify_pfinal)
            return check_diff(0, norm_err, abstol=2e-1)
        return
Example #14
0
        def advection_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            q0 = claw.frames[0].state.get_q_global()
            qfinal = claw.frames[claw.num_output_times].state.get_q_global()

            if q0 is not None and qfinal is not None:
                dx = claw.solution.domain.grid.delta[0]
                test = dx * np.linalg.norm(qfinal - q0, 1)
                return check_diff(expected, test, reltol=1e-4)
            else:
                return
Example #15
0
        def dambreak_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            thisdir = os.path.dirname(__file__)
            expected_depth = np.loadtxt(os.path.join(thisdir,'./dam_break_ref.txt'))

            test_solution = claw.frames[claw.num_output_times].state.get_q_global()

            if test_solution is not None:
                return check_diff(expected_depth, test_solution[0,:], reltol=1e-3)
            else:
                return
Example #16
0
        def sill_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            q0 = claw.frames[0].state.get_q_global()
            qfinal = claw.frames[claw.num_output_times].state.get_q_global()

            if q0 is not None and qfinal is not None:
                dx, dy = claw.solution.domain.grid.delta
                total_mass = dx * dy * np.linalg.norm(qfinal[0,:,:].reshape(-1), 1)
                return check_diff(expected, total_mass, reltol=1e-3)
            else:
                return
Example #17
0
        def dambreak_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            thisdir = os.path.dirname(__file__)
            expected_depth = np.loadtxt(os.path.join(thisdir,'./dam_break_ref.txt'))

            test_solution = claw.frames[claw.num_output_times].state.get_q_global()

            if test_solution is not None:
                return check_diff(expected_depth, test_solution[0,:], reltol=1e-3)
            else:
                return
Example #18
0
    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)
Example #19
0
    def acoustics_verify_homogeneous(claw):
        from clawpack.pyclaw.util import check_diff
        import numpy as np

        pinitial = claw.frames[0].state.get_q_global()
        pfinal   = claw.frames[claw.num_output_times].state.get_q_global()

        pinitial = pinitial[0,:,:,:].reshape(-1)
        pfinal   = pfinal[0,:,:,:].reshape(-1)
        grid = claw.solution.state.grid
        final_difference =np.prod(grid.delta)*np.linalg.norm(pfinal-pinitial,ord=1)

        return check_diff(0.00286, final_difference, abstol=1e-4)
Example #20
0
        def sill_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            q0 = claw.frames[0].state.get_q_global()
            qfinal = claw.frames[claw.num_output_times].state.get_q_global()

            if q0 != None and qfinal != None:
                dx = claw.solution.domain.grid.delta[0]
                test = dx * np.linalg.norm(qfinal - q0, 1)
                return check_diff(expected, test, reltol=1e-4)
            else:
                return
Example #21
0
 def advection_nu_verify(claw):
     q0 = claw.frames[0].state.get_q_global()
     qfinal = claw.frames[claw.num_output_times].state.get_q_global()
     if q0 is not None and qfinal is not None:
         dx = claw.solution.domain.grid.delta[0]
         grid1d = claw.frames[0].state.grid
         grid1d.mapc2p = mapc2p_nonunif
         nx = 100
         aux = np.zeros((1, nx))
         aux[0, :] = np.diff(grid1d.p_nodes) / np.diff(grid1d.x.nodes)
         test = abs(np.sum(dx * aux[0, :] * (qfinal - q0)))
         return check_diff(expected, test, reltol=1e-4)
     else:
         return
Example #22
0
    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)
Example #23
0
    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)
    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)
Example #25
0
    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)
Example #26
0
    def acoustics_verify_homogeneous(claw):
        """ Regression test for 3D homogeneous acoustics equations.
        """

        pinitial = claw.frames[0].state.get_q_global()
        pfinal = claw.frames[claw.num_output_times].state.get_q_global()

        if pinitial is not None:
            pinitial = pinitial[0, :, :, :].reshape(-1)
            pfinal = pfinal[0, :, :, :].reshape(-1)
            grid = claw.solution.state.grid
            final_difference = np.prod(grid.delta)*np.linalg.norm(pfinal-pinitial, ord=1)
            return check_diff(0., final_difference, abstol=1e-1)
        else:
            # In parallel, we check values only for the rank 0 process
            return
Example #27
0
    def acoustics_verify_heterogeneous(claw):
        """ Regression test for 3D heterogeneous acoustics equations
        """

        pinitial = claw.frames[0].state.get_q_global()
        pfinal = claw.frames[claw.num_output_times].state.get_q_global()

        if pinitial is not None:
            pfinal = pfinal[0, :, :, :].reshape(-1)
            thisdir = os.path.dirname(__file__)
            verify_pfinal = np.loadtxt(os.path.join(thisdir, 'verify_classic_heterogeneous.txt'))
            norm_err = np.linalg.norm(pfinal-verify_pfinal)
            return check_diff(0, norm_err, abstol=10.)
        else:
            # In parallel, we check values only for the rank 0 process
            return
Example #28
0
    def verify_classic_shockbubble(test_state):
        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np
        """ verifies 2d euler shockbubble from a previously verified classic run """

        test_q=test_state.get_q_global()


        if test_q != None:
            thisdir = os.path.dirname(__file__)
            expected_density = np.loadtxt(os.path.join(thisdir,'verify_shockbubble_classic.txt'))
            test_density = test_q[0,:,:]
            test_err = np.linalg.norm(expected_density-test_density)
            expected_err = 0
            return check_diff(expected_err, test_err, abstol=1e-12)
Example #29
0
    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, {})
Example #30
0
        def verify(claw):
            """ verifies 2d homogeneous acoustics from a previously verified run """
            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff

            # grabs parallel results to process 0, None to other processes
            test_q = claw.solution.state.get_q_global()

            if test_q is not None:
                test_pressure = test_q[0, :, :]
                thisdir = os.path.dirname(__file__)
                expected_pressure = np.loadtxt(os.path.join(thisdir, data_filename))
                return check_diff(expected_pressure, test_pressure, reltol=1e-3, delta=claw.solution.grid.delta)
            else:
                return
Example #31
0
        def acoustics_verify(claw):
            from clawpack.pyclaw.util import check_diff
            import numpy as np

            # tests are done across the entire domain of q normally
            q0=claw.frames[0].state.get_q_global()
            qfinal=claw.frames[claw.num_output_times].state.get_q_global()

            # and q_global is only returned on process 0
            if q0 is not None and qfinal is not None:
                q0 = q0.reshape([-1])
                qfinal = qfinal.reshape([-1])
                dx=claw.solution.domain.grid.delta[0]
                test = dx*np.sum(np.abs(qfinal-q0))
                return check_diff(expected, test, abstol=1e-4)
            else:
                return
Example #32
0
    def acoustics_verify_heterogeneous(claw):
        import os
        import numpy as np
        from clawpack.pyclaw.util import check_diff

        pinitial = claw.frames[0].state.get_q_global()
        pfinal   = claw.frames[claw.num_output_times].state.get_q_global()

        pinitial = pinitial[0,:,:,:].reshape(-1)
        pfinal   = pfinal[0,:,:,:].reshape(-1)
        grid = claw.solution.state.grid
        final_difference =np.prod(grid.delta)*np.linalg.norm(pfinal-pinitial,ord=1)

        thisdir = os.path.dirname(__file__)
        verify_pfinal = np.loadtxt(os.path.join(thisdir,'verify_classic_heterogeneous.txt'))
        norm_err = np.linalg.norm(pfinal-verify_pfinal)
        return check_diff(0, norm_err, abstol=10.)
Example #33
0
    def acoustics_verify_heterogeneous(claw):
        import os
        import numpy as np
        from clawpack.pyclaw.util import check_diff

        pinitial = claw.frames[0].state.get_q_global()
        pfinal   = claw.frames[claw.num_output_times].state.get_q_global()

        pinitial = pinitial[0,:,:,:].reshape(-1)
        pfinal   = pfinal[0,:,:,:].reshape(-1)
        grid = claw.solution.state.grid
        final_difference =np.prod(grid.delta)*np.linalg.norm(pfinal-pinitial,ord=1)

        thisdir = os.path.dirname(__file__)
        verify_pfinal = np.loadtxt(os.path.join(thisdir,'verify_classic_heterogeneous.txt'))
        norm_err = np.linalg.norm(pfinal-verify_pfinal)
        return check_diff(0, norm_err, abstol=2e-1)
Example #34
0
    def verify_classic_shockbubble(controller):
        """ verifies 2d euler shockbubble from a previously verified classic run """

        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np

        test_q = controller.solution.state.get_q_global()

        if test_q != None:
            thisdir = os.path.dirname(__file__)
            expected_density = np.loadtxt(
                os.path.join(thisdir, 'verify_shockbubble_classic.txt'))
            test_density = test_q[0, :, :]
            test_err = np.linalg.norm(expected_density - test_density)
            expected_err = 0
            return check_diff(expected_err, test_err, abstol=1e-12)
Example #35
0
    def verify_classic_rising_hot_sphere(controller):
        """ verifies 3d euler rising hot sphere from a previously verified classic run """

        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np

        test_q=controller.solution.state.get_q_global()

        if test_q != None:
            thisdir = os.path.dirname(__file__)
            expected_density = np.loadtxt(os.path.join(thisdir,'verify_rising_hot_sphere_classic_1.txt'))
            nx = np.size(test_q,1)
            test_density = np.reshape(test_q[0,nx/2,:,:],np.size(test_q[0,nx/2,:,:]),order='F')
            test_err = np.linalg.norm(expected_density-test_density)
            expected_err = 0
            return check_diff(expected_err, test_err, abstol=1e-12)
Example #36
0
    def acoustics_verify_heterogeneous(claw):
        """ Regression test for 3D heterogeneous acoustics equations
        """

        pinitial = claw.frames[0].state.get_q_global()
        pfinal = claw.frames[claw.num_output_times].state.get_q_global()

        if pinitial is not None:
            pfinal = pfinal[0, :, :, :].reshape(-1)
            thisdir = os.path.dirname(__file__)
            verify_pfinal = np.loadtxt(
                os.path.join(thisdir, 'verify_classic_heterogeneous.txt'))
            norm_err = np.linalg.norm(pfinal - verify_pfinal)
            return check_diff(0, norm_err, abstol=10.)
        else:
            # In parallel, we check values only for the rank 0 process
            return
Example #37
0
    def acoustics_verify_homogeneous(claw):
        """ Regression test for 3D homogeneous acoustics equations.
        """

        pinitial = claw.frames[0].state.get_q_global()
        pfinal = claw.frames[claw.num_output_times].state.get_q_global()

        if pinitial is not None:
            pinitial = pinitial[0, :, :, :].reshape(-1)
            pfinal = pfinal[0, :, :, :].reshape(-1)
            grid = claw.solution.state.grid
            final_difference = np.prod(grid.delta) * np.linalg.norm(
                pfinal - pinitial, ord=1)
            return check_diff(0., final_difference, abstol=1e-1)
        else:
            # In parallel, we check values only for the rank 0 process
            return
    def verify_classic_acoustics(controller):
        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np
        """ Verifies 2d variable-coefficient acoustics from a previously verified classic run """

        state = controller.frames[controller.num_output_times].state
        dx, dy = controller.solution.domain.grid.delta
        test_q=state.get_q_global()

        if test_q != None:
            thisdir = os.path.dirname(__file__)
            expected_pressure = np.loadtxt(os.path.join(thisdir,'pressure_classic.txt'))
            test_pressure = test_q[0,:,:]
            #test_err = dx*dy*np.linalg.norm(expected_pressure-test_pressure)
            test_err = np.max(np.abs(expected_pressure[:]-test_pressure[:]))
            return check_diff(0, test_err, abstol=1e-1)
Example #39
0
        def verify(claw):
            """ verifies 2d homogeneous acoustics from a previously verified run """
            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff


            #grabs parallel results to process 0, None to other processes
            test_q=claw.solution.state.get_q_global()

            if test_q is not None:
                test_pressure = test_q[0,:,:]
                thisdir = os.path.dirname(__file__)
                expected_pressure = np.loadtxt(os.path.join(thisdir,data_filename))
                return check_diff(expected_pressure, test_pressure, reltol=1e-3)
            else:
                return
Example #40
0
    def verify_classic_acoustics(controller):
        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np
        """ Verifies 2d variable-coefficient acoustics from a previously verified classic run """

        state = controller.frames[controller.num_output_times].state
        dx, dy = controller.solution.domain.grid.delta
        test_q = state.get_q_global()

        if test_q != None:
            thisdir = os.path.dirname(__file__)
            expected_pressure = np.loadtxt(
                os.path.join(thisdir, 'pressure_classic.txt'))
            test_pressure = test_q[0, :, :]
            #test_err = dx*dy*np.linalg.norm(expected_pressure-test_pressure)
            test_err = np.max(np.abs(expected_pressure[:] - test_pressure[:]))
            return check_diff(0, test_err, abstol=1e-1)
Example #41
0
    def verify_acoustics_inclusions(controller, solver_type='classic'):
        """ Regression test against data from a previous run."""
        import os
        from clawpack.pyclaw.util import check_diff
        import numpy as np

        state = controller.frames[controller.num_output_times].state
        dx, dy = controller.solution.domain.grid.delta
        test_q = state.get_q_global()

        if test_q is not None:
            thisdir = os.path.dirname(__file__)
            expected_pressure = np.load(os.path.join(thisdir,
                                        'pressure.npz'))['arr_0']
            test_pressure = test_q[0,:,:]
            test_err = np.max(np.abs(expected_pressure[:].reshape(-1) - 
                                     test_pressure[:].reshape(-1)))
            return check_diff(0, test_err, abstol=1e-7)
Example #42
0
        def verify(test_state):
            """ verifies 2d homogeneous acoustics from a previously verified run """
            import os
            import numpy as np
            from clawpack.pyclaw.util import check_diff


            #grabs parallel results to process 0, None to other processes
            test_q=test_state.get_q_global()

            if test_q is not None:
                test_pressure = test_q[0,:,:]
                thisdir = os.path.dirname(__file__)
                expected_pressure = np.loadtxt(os.path.join(thisdir,data_filename))
                test_err = np.linalg.norm(expected_pressure-test_pressure)
                expected_err = 0
                return check_diff(expected_err, test_err, abstol=1e-1)
            else:
                return