Changeset 7824


Ignore:
Timestamp:
Jun 11, 2010, 7:45:03 PM (10 years ago)
Author:
steve
Message:

test_sww_vel_domain is nowworking with numpy

Location:
anuga_work/development/pipeflow
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • anuga_work/development/pipeflow/test_sww_domain.py

    r7823 r7824  
    4040        domain.distribute_to_vertices_and_edges()
    4141        domain.compute_fluxes()
    42 
    43         print domain.quantities['stage'].explicit_update
    44         print domain.quantities['xmomentum'].explicit_update
    45 
    46         print stage_ud
    47         print xmom_ud
    4842
    4943        assert numpy.allclose( domain.quantities['stage'].explicit_update, stage_ud )
     
    125119
    126120        for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime):
    127             #pass
     121            pass
    128122       
    129             print domain.quantities['stage'].vertex_values
    130             print domain.quantities['elevation'].vertex_values
    131             print domain.quantities['xmomentum'].vertex_values
    132          
    133        
    134             print domain.quantities['stage'].centroid_values 
    135             print domain.quantities['elevation'].centroid_values
    136             print domain.quantities['xmomentum'].centroid_values   
    137123
    138124        assert numpy.allclose( 10.0*numpy.ones(10), domain.quantities['stage'].centroid_values )
     
    161147            pass
    162148       
    163         assert numpy.allclose( 10.0*ones(10), domain.quantities['stage'].centroid_values )
    164         assert numpy.allclose( zeros(10), domain.quantities['xmomentum'].centroid_values )
     149        assert numpy.allclose( 10.0*numpy.ones(10), domain.quantities['stage'].centroid_values )
     150        assert numpy.allclose( numpy.zeros(10), domain.quantities['xmomentum'].centroid_values )
    165151
    166152    def test_evolve_second_order_space_time(self):
     
    186172            pass
    187173       
    188         assert numpy.allclose( 10.0*ones(10), domain.quantities['stage'].centroid_values )
    189         assert numpy.allclose( zeros(10), domain.quantities['xmomentum'].centroid_values )
     174        assert numpy.allclose( 10.0*numpy.ones(10), domain.quantities['stage'].centroid_values )
     175        assert numpy.allclose( numpy.zeros(10), domain.quantities['xmomentum'].centroid_values )
    190176
    191177
  • anuga_work/development/pipeflow/test_sww_vel_domain.py

    r7823 r7824  
    55
    66
    7 from shallow_water_vel_domain import *
    8 
    9 
    10 from Numeric import allclose, array, ones, Float, maximum, zeros
     7from sww_vel_domain import *
     8
     9
     10from numpy import allclose, array, ones, maximum, zeros
     11import numpy
    1112
    1213
     
    110111        domain.update_boundary()
    111112
    112         stage_ud, xmom_ud = local_compute_fluxes(domain)
     113        import sww_python
     114        stage_ud, xmom_ud = sww_python.compute_fluxes(domain)
    113115
    114116        domain.compute_fluxes()
     
    126128#        print domain.quantities['velocity'].boundary_values
    127129       
    128         print domain.quantities['stage'].explicit_update
    129         print domain.quantities['xmomentum'].explicit_update
    130 
    131         print stage_ud
    132         print xmom_ud
    133130
    134131        assert allclose( domain.quantities['stage'].explicit_update, stage_ud )
     
    138135    def test_local_flux_function(self):
    139136        normal = 1.0
    140         ql = array([1.0, 2.0],Float)
    141         qr = array([1.0, 2.0],Float)
     137        ql = array([1.0, 2.0],numpy.float)
     138        qr = array([1.0, 2.0],numpy.float)
    142139        zl = 0.0
    143140        zr = 0.0
    144141
    145142        #This assumes h0 = 1.0e-3!!
    146         edgeflux, maxspeed = local_flux_function(normal, ql,qr,zl,zr)
     143        import sww_python
     144        edgeflux, maxspeed = sww_python.flux_function(normal, ql,qr,zl,zr)
    147145        #print maxspeed
    148146        #print edgeflux
    149147       
    150         assert allclose(array([2.0, 8.9],Float), edgeflux, rtol=1.0e-005)
     148        assert allclose([2.0, 8.9], edgeflux, rtol=1.0e-005)
    151149        assert allclose(5.1305, maxspeed, rtol=1.0e-005)
    152150
    153151        normal = -1.0
    154         ql = array([1.0, 2.0],Float)
    155         qr = array([1.0, 2.0],Float)
     152        ql = array([1.0, 2.0],numpy.float)
     153        qr = array([1.0, 2.0],numpy.float)
    156154        zl = 0.0
    157155        zr = 0.0
    158156
    159         edgeflux, maxspeed = local_flux_function(normal, ql,qr,zl,zr)
     157        edgeflux, maxspeed = sww_python.flux_function(normal, ql,qr,zl,zr)
    160158
    161159
     
    163161        #print edgeflux       
    164162       
    165         assert allclose(array([-2.0, -8.9],Float), edgeflux, rtol=1.0e-005)
     163        assert allclose([-2.0, -8.9], edgeflux, rtol=1.0e-005)
    166164        assert allclose(5.1305, maxspeed, rtol=1.0e-005)
    167165
     
    189187        #print domain.quantities['xmomentum'].explicit_update       
    190188
    191         assert allclose( array([-34.3, -24.5, -14.7], Float), domain.quantities['xmomentum'].explicit_update )
     189        assert allclose( [-34.3, -24.5, -14.7], domain.quantities['xmomentum'].explicit_update )
    192190
    193191
Note: See TracChangeset for help on using the changeset viewer.