Changeset 9737 for trunk/anuga_core/anuga/operators/tests
- Timestamp:
- Oct 4, 2016, 4:13:00 PM (9 years ago)
- 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 23 23 24 24 try: 25 os.remove('anuga.log') 25 pass 26 #os.remove('anuga.log') 26 27 except: 27 28 pass … … 184 185 operator.set_triangle_areas(False) 185 186 186 print operator.apply_triangle_areas187 #print operator.apply_triangle_areas 187 188 188 189 a = Quantity(operator.domain) … … 231 232 operator.set_triangle_areas(False) 232 233 233 print operator.apply_triangle_areas234 #print operator.apply_triangle_areas 234 235 #n = operator.n 235 236 … … 717 718 domain.set_quantity('elevation', expression='x') 718 719 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)') 720 721 domain.set_quantity('xmomentum', expression='2*x+3*y') 721 722 domain.set_quantity('ymomentum', expression='5*x+7*y') … … 746 747 747 748 h = domain.quantities['height'] 749 750 h.centroid_values[:] = num.where(h.centroid_values < 1.0e-12, 0.0, h.centroid_values) 748 751 749 752 #print 'h' … … 780 783 kv.parabolic_solve(v, v, h, u_out=v, update_matrix=False, iprint=1, use_dt_tol=False) 781 784 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) 783 812 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) 786 839 assert num.allclose(v.boundary_values, 2.0*num.ones_like(v.boundary_values)) 787 840 … … 1483 1536 1484 1537 if __name__ == "__main__": 1485 suite = unittest.makeSuite(Test_kinematic_viscosity, 'test_') 1538 suite = unittest.makeSuite(Test_kinematic_viscosity, 'test_') #test_') 1486 1539 runner = unittest.TextTestRunner() 1487 1540 runner.run(suite) -
trunk/anuga_core/anuga/operators/tests/test_rate_operators.py
r9551 r9737 323 323 324 324 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 327 331 factor = 1000.0 328 332 default_rate= 17.7 … … 333 337 334 338 # Apply Operator 335 domain.set_ starttime(360.0)339 domain.set_time(360.0) 336 340 domain.timestep = 1.0 337 341 338 342 operator() 343 339 344 340 345 … … 355 360 356 361 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) 369 364 domain.timestep = 1.0 370 365 … … 374 369 stage_ex1 = [ d, d, 1., d] 375 370 376 # print domain.quantities['elevation'].centroid_values377 # print domain.quantities['stage'].centroid_values378 # print domain.quantities['xmomentum'].centroid_values379 # print domain.quantities['ymomentum'].centroid_values371 # 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 380 375 381 376 assert num.allclose(domain.quantities['stage'].centroid_values, stage_ex1) … … 383 378 assert num.allclose(domain.quantities['ymomentum'].centroid_values, 0.0) 384 379 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 385 400 386 401
Note: See TracChangeset
for help on using the changeset viewer.