Ignore:
Timestamp:
Oct 4, 2016, 4:13:00 PM (9 years ago)
Author:
steve
Message:

Commit svn after a lot of git updates

Location:
trunk/anuga_core/anuga/operators/tests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/anuga/operators/tests/test_kinematic_viscosity_operator.py

    r9733 r9737  
    2323
    2424        try:
    25             os.remove('anuga.log')
     25            pass
     26            #os.remove('anuga.log')
    2627        except:
    2728            pass
     
    184185        operator.set_triangle_areas(False)
    185186
    186         print operator.apply_triangle_areas
     187        #print operator.apply_triangle_areas
    187188
    188189        a = Quantity(operator.domain)
     
    231232        operator.set_triangle_areas(False)
    232233
    233         print operator.apply_triangle_areas
     234        #print operator.apply_triangle_areas
    234235        #n = operator.n
    235236
     
    717718        domain.set_quantity('elevation', expression='x')
    718719        domain.set_quantity('friction', 0.03)
    719         domain.set_quantity('stage',expression='elevation + 2*(x-0.5)')
     720        domain.set_quantity('stage',expression='elevation + 2*(x-0.45)')
    720721        domain.set_quantity('xmomentum', expression='2*x+3*y')
    721722        domain.set_quantity('ymomentum', expression='5*x+7*y')
     
    746747
    747748        h = domain.quantities['height']
     749
     750        h.centroid_values[:] = num.where(h.centroid_values < 1.0e-12, 0.0, h.centroid_values)
    748751
    749752        #print 'h'
     
    780783        kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False)
    781784
    782         assert num.allclose(u.centroid_values, num.where(h.centroid_values > 0.0, 1.0, 0.0), rtol=1.0e-1)
     785
     786       
     787        u_expected = \
     788        num.array([ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     789        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     790        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     791        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     792        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     793        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     794        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     795        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     796        0.        ,  0.88049303,  0.85774725,  0.63198513,  0.        ,
     797        0.60127309,  0.74335638,  0.56726693,  0.        ,  0.5619257 ,
     798        0.72367268,  0.56292098,  0.        ,  0.56846364,  0.74395284,
     799        0.60155678,  0.        ,  0.63250083,  0.8583354 ,  0.88103078,
     800        0.91424291,  0.98161599,  0.9681383 ,  0.92489827,  0.83150189,
     801        0.90499771,  0.92610594,  0.88016105,  0.81330027,  0.87520116,
     802        0.9137613 ,  0.87524587,  0.83194825,  0.88028462,  0.92624037,
     803        0.90532118,  0.91457731,  0.92521631,  0.96831727,  0.98169171,
     804        0.98017988,  0.99638864,  0.99691038,  0.98420946,  0.95322667,
     805        0.97923645,  0.99234935,  0.97272033,  0.94496518,  0.97116962,
     806        0.99081552,  0.97116479,  0.95330259,  0.97272909,  0.99236019,
     807        0.979296  ,  0.9803074 ,  0.98428114,  0.99692939,  0.9964171 ])
     808
     809       
     810       
     811        assert num.allclose(u.centroid_values, u_expected, rtol=1.0e-4)
    783812        assert num.allclose(u.boundary_values, num.ones_like(u.boundary_values))
    784 
    785         assert num.allclose(v.centroid_values, num.where(h.centroid_values > 0.0, 2.0, 0.0), rtol=1.0e-1)
     813       
     814       
     815        v_expected = \
     816        num.array([ 0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     817        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     818        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     819        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     820        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     821        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     822        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     823        0.        ,  0.        ,  0.        ,  0.        ,  0.        ,
     824        0.        ,  1.76107875,  1.71571872,  1.26450977,  0.        ,
     825        1.20323049,  1.48723907,  1.13511687,  0.        ,  1.12443699,
     826        1.44790348,  1.12678546,  0.        ,  1.1379396 ,  1.488628  ,
     827        1.20388888,  0.        ,  1.26569807,  1.71709086,  1.76232374,
     828        1.82867872,  1.96328928,  1.93637645,  1.84998653,  1.66337269,
     829        1.81022916,  1.85243013,  1.76063685,  1.62705824,  1.75073279,
     830        1.82775908,  1.75083189,  1.66440859,  1.76091792,  1.85274102,
     831        1.81097589,  1.82944675,  1.85071618,  1.93678282,  1.96345914,
     832        1.96043069,  1.99279212,  1.99383543,  1.96848768,  1.90661323,
     833        1.95855951,  1.98473153,  1.94554555,  1.89009256,  1.9424436 ,
     834        1.98166495,  1.94242902,  1.90678928,  1.94556252,  1.98475631,
     835        1.95869882,  1.96072166,  1.96865435,  1.99387965,  1.99285742])
     836       
     837
     838        assert num.allclose(v.centroid_values, v_expected, rtol=1.0e-4)
    786839        assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values))
    787840
     
    14831536
    14841537if __name__ == "__main__":
    1485     suite = unittest.makeSuite(Test_kinematic_viscosity, 'test_')
     1538    suite = unittest.makeSuite(Test_kinematic_viscosity, 'test_') #test_')
    14861539    runner = unittest.TextTestRunner()
    14871540    runner.run(suite)
  • trunk/anuga_core/anuga/operators/tests/test_rate_operators.py

    r9551 r9737  
    323323
    324324
    325         rate = file_function('test_file_function.tms', quantities=['Attribute1'])
    326 
     325        rate = file_function(filename + '.tms', quantities=['Attribute1'])
     326       
     327
     328        # Make starttime of domain consistent with tms file starttime
     329        domain.set_starttime(rate.starttime)
     330                   
    327331        factor = 1000.0
    328332        default_rate= 17.7
     
    333337
    334338        # Apply Operator
    335         domain.set_starttime(360.0)
     339        domain.set_time(360.0)
    336340        domain.timestep = 1.0
    337341
    338342        operator()
     343
    339344
    340345
     
    355360
    356361
    357         domain.set_starttime(-10.0)
    358         domain.timestep = 1.0
    359 
    360         try:
    361             operator()
    362         except:
    363             pass
    364         else:
    365             raise Exception('Should have raised an exception, time too early')
    366 
    367 
    368         domain.set_starttime(1300.0)
     362
     363        domain.set_time(1300.0)
    369364        domain.timestep = 1.0
    370365
     
    374369        stage_ex1 = [ d,  d,   1.,  d]
    375370
    376 #        print domain.quantities['elevation'].centroid_values
    377 #        print domain.quantities['stage'].centroid_values
    378 #        print domain.quantities['xmomentum'].centroid_values
    379 #        print domain.quantities['ymomentum'].centroid_values
     371#         print domain.quantities['elevation'].centroid_values
     372#         print domain.quantities['stage'].centroid_values
     373#         print domain.quantities['xmomentum'].centroid_values
     374#         print domain.quantities['ymomentum'].centroid_values
    380375
    381376        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1)
     
    383378        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
    384379        assert num.allclose(domain.fractional_step_volume_integral, ((d-1.)*domain.areas[indices]).sum())
     380
     381
     382        tmp = numpy.zeros_like(domain.quantities['stage'].centroid_values)
     383        tmp[:] = domain.quantities['stage'].centroid_values
     384       
     385        d0 = domain.fractional_step_volume_integral
     386       
     387        domain.set_time(-10.0)
     388        domain.timestep = 1.0
     389       
     390        operator()
     391       
     392        d = default_rate*factor
     393        stage_ex2 = numpy.array([ d,  d,   0.,  d]) + numpy.array(stage_ex1)
     394   
     395        assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex2)
     396        assert num.allclose(domain.quantities['xmomentum'].centroid_values, 0.0)
     397        assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0)
     398        assert num.allclose(domain.fractional_step_volume_integral, d0+(d*domain.areas[indices]).sum())
     399
    385400
    386401
Note: See TracChangeset for help on using the changeset viewer.