Changeset 476 for inundation/ga/storm_surge/pyvolution/test_quantity.py
- Timestamp:
- Nov 1, 2004, 3:49:47 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_quantity.py
r461 r476 7 7 from quantity import * 8 8 from config import epsilon 9 from Numeric import allclose, array 9 from Numeric import allclose, array, ones, Float 10 10 11 11 … … 412 412 assert allclose( quantity.centroid_values, x) 413 413 414 #FIXME: Update these tests once I understand the semi_implicit scheme 415 # def test_update_semi_implicit(self): 416 # quantity = Conserved_quantity(self.mesh4) 417 418 # #Test centroids 419 # quantity.set_values([1.,2.,3.,4.], location = 'centroids') 420 # assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid 421 422 # #Set semi implicit update 423 # quantity.semi_implicit_update = array( [1.,1.,1.,1.] ) 424 425 # #Update with given timestep 426 # quantity.update(0.1) 427 428 # x = array([1, 2, 3, 4])/array( [.9,.9,.9,.9] ) 429 # assert allclose( quantity.centroid_values, x) 430 431 # def test_both_updates(self): 432 # quantity = Conserved_quantity(self.mesh4) 433 434 # #Test centroids 435 # quantity.set_values([1.,2.,3.,4.], location = 'centroids') 436 # assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid 437 438 # #Set explicit_update 439 # quantity.explicit_update = array( [4.,3.,2.,1.] ) 440 441 # #Set semi implicit update 442 # quantity.semi_implicit_update = array( [1.,1.,1.,1.] ) 443 444 # #Update with given timestep 445 # quantity.update(0.1) 446 447 # x = array([1, 2, 3, 4]) + array( [.4,.3,.2,.1] ) 448 # x /= array( [.9,.9,.9,.9] ) 449 # assert allclose( quantity.centroid_values, x) 414 def test_update_semi_implicit(self): 415 quantity = Conserved_quantity(self.mesh4) 416 417 #Test centroids 418 quantity.set_values([1.,2.,3.,4.], location = 'centroids') 419 assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid 420 421 #Set semi implicit update 422 quantity.semi_implicit_update = array([1.,1.,1.,1.]) 423 424 #Update with given timestep 425 timestep = 0.1 426 quantity.update(timestep) 427 428 sem = array([1.,1.,1.,1.])/array([1, 2, 3, 4]) 429 denom = ones(4, Float)-timestep*sem 430 431 x = array([1, 2, 3, 4])/denom 432 assert allclose( quantity.centroid_values, x) 433 434 435 def test_both_updates(self): 436 quantity = Conserved_quantity(self.mesh4) 437 438 #Test centroids 439 quantity.set_values([1.,2.,3.,4.], location = 'centroids') 440 assert allclose(quantity.centroid_values, [1, 2, 3, 4]) #Centroid 441 442 #Set explicit_update 443 quantity.explicit_update = array( [4.,3.,2.,1.] ) 444 445 #Set semi implicit update 446 quantity.semi_implicit_update = array( [1.,1.,1.,1.] ) 447 448 #Update with given timestep 449 timestep = 0.1 450 quantity.update(0.1) 451 452 sem = array([1.,1.,1.,1.])/array([1, 2, 3, 4]) 453 denom = ones(4, Float)-timestep*sem 454 455 x = array([1, 2, 3, 4]) + array( [.4,.3,.2,.1] ) 456 x /= denom 457 assert allclose( quantity.centroid_values, x) 450 458 451 459
Note: See TracChangeset
for help on using the changeset viewer.