Changeset 513


Ignore:
Timestamp:
Nov 9, 2004, 5:45:49 PM (19 years ago)
Author:
steve
Message:

Quantities Working

Location:
inundation/ga/storm_surge/pyvolution-1d
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution-1d/quantity.py

    r438 r513  
    410410    D1 = Domain(points1)
    411411
    412     Q1 = Quantity(D1, vertex_values)
     412    Q1 = Conserved_quantity(D1, vertex_values)
    413413
    414414    print Q1.vertex_values
     
    419419    Q1.set_values(new_vertex_values)
    420420   
    421    
    422421    print Q1.vertex_values
    423422    print Q1.centroid_values
     
    430429
    431430    def fun(x):
    432 
    433431        return x**2
    434432
     
    437435    print Q1.vertex_values
    438436    print Q1.centroid_values
     437
    439438    Xc = Q1.domain.vertices
    440439    Qc = Q1.vertex_values
     
    443442
    444443    Qc[1,0] = 3
     444
     445    Q1.extrapolate_second_order()
     446    Q1.limit()
     447   
    445448    from matplotlib.matlab import *
    446449    plot(Xc,Qc)
     
    448451    show()
    449452
    450 
    451 
    452    
    453    
    454 
    455    
    456 
    457 
    458 
    459 
     453   
     454
     455
     456
     457   
     458   
     459
     460   
     461
     462
     463
     464
  • inundation/ga/storm_surge/pyvolution-1d/test_quantity.py

    r335 r513  
    9797        assert allclose(quantity.centroid_values, [1., 2., 3., 4., 5.]) #Centroid
    9898
    99         #Test exceptionsdatamining.anu.edu.au/svn/
     99        #Test exceptions
    100100        try:
    101101            quantity.set_values([[1,2], [5,5], [0,0], [-6, 3], [-2,4]],
     
    245245                            location = 'centroids')
    246246       
    247 
    248 
    249247        quantity.extrapolate_second_order()
    250248        quantity.limit()
    251 
    252249
    253250        #Assert that central triangle is limited by neighbours
     
    276273        assert quantity.vertex_values[4,1] >= 0.0
    277274        assert quantity.vertex_values[4,1] <= 2.0
    278        
    279 
    280        
     275
    281276        #Assert that quantities are conserved
    282277        from Numeric import sum
     
    292287
    293288        #Create a deliberate overshoot (e.g. from gradient computation)
    294         quantity.set_values([[3,0,3], [2,2,6], [5,3,8], [8,3,5]])
    295 
     289        quantity.set_values([[3,4], [5,5], [0,0], [-6, 3], [-2,4]],
     290                            location = 'vertices')       
    296291
    297292        #Limit
     
    299294
    300295        #Assert that central triangle is limited by neighbours
    301         assert quantity.vertex_values[1,0] >= quantity.vertex_values[0,0]
    302         assert quantity.vertex_values[1,0] <= quantity.vertex_values[3,1]
    303        
    304         assert quantity.vertex_values[1,1] <= quantity.vertex_values[2,1]
    305         assert quantity.vertex_values[1,1] >= quantity.vertex_values[0,2]
    306        
    307         assert quantity.vertex_values[1,2] <= quantity.vertex_values[2,0]
    308         assert quantity.vertex_values[1,2] <= quantity.vertex_values[3,1]
    309 
     296        assert quantity.vertex_values[0,1] >= quantity.centroid_values[0]
     297        assert quantity.vertex_values[1,0] <= quantity.centroid_values[1]
     298       
     299        assert quantity.vertex_values[1,1] >= quantity.centroid_values[1]
    310300
    311301       
     
    314304        for k in range(quantity.centroid_values.shape[0]):
    315305            assert allclose (quantity.centroid_values[k],
    316                              sum(quantity.vertex_values[k,:])/3)
     306                             sum(quantity.vertex_values[k,:])/2)
    317307       
    318308
     
    396386if __name__ == "__main__":
    397387    suite = unittest.makeSuite(TestCase,'test')
    398     runner = unittest.TextTestRunner()
     388    runner = unittest.TextTestRunner(verbosity=2)
    399389    runner.run(suite)
    400390
Note: See TracChangeset for help on using the changeset viewer.