Changeset 6103


Ignore:
Timestamp:
Dec 24, 2008, 12:40:42 PM (15 years ago)
Author:
ole
Message:

Fixed situation where delta_w is larger than what is specified in
rating curve.

Location:
anuga_core/source/anuga/culvert_flows
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/culvert_flows/culvert_class.py

    r6102 r6103  
    1818# FIXME(Ole): Write in C and reuse this function by similar code in interpolate.py
    1919def interpolate_linearly(x, xvec, yvec):
    20          
    21     # Find appropriate slot           
     20
     21    # Check bounds
     22    if x < xvec[0]:
     23        msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])
     24        raise Below_interval, msg
     25       
     26    if x > xvec[-1]:
     27        msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])
     28        raise Above_interval, msg       
     29       
     30       
     31    # Find appropriate slot within bounds           
    2232    i = 0
    2333    while x > xvec[i]: i += 1
    2434
    25     if i == 0:
    26         msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])
    27         raise Below_interval, msg
    28        
    29     if i == len(xvec):
    30         msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])
    31         raise Above_interval, msg       
    32        
    3335   
    3436    x0 = xvec[i-1]
     
    305307                stage = dq['stage'].get_values(location='centroids',
    306308                                               indices=[self.enquiry_indices[i]])
    307 
    308                    
     309               
    309310                # Store current average stage and depth with each opening object
    310311                opening.depth = stage - opening.elevation
     
    332333            else:
    333334                # Calculate discharge for one barrel and set inlet.rate and outlet.rate
     335               
    334336                try:
    335337                    Q = interpolate_linearly(delta_w, self.rating_curve[:,0], self.rating_curve[:,1])
  • anuga_core/source/anuga/culvert_flows/test_culvert_class.py

    r6102 r6103  
    1919     
    2020from math import pi,pow,sqrt
    21 from Numeric import choose, greater, ones, sin, exp, cosh, allclose
     21from Numeric import choose, greater, ones, sin, cos, exp, cosh, allclose
    2222
    2323
     
    3131
    3232
    33     def test_that_culvert_runs(self):
    34         """test_that_culvert_runs
    35        
    36         This test only exercises the culvert - there is no quantitative
    37         diagnostics yet
     33    def test_that_culvert_runs_rating(self):
     34        """test_that_culvert_runs_rating
     35       
     36        This test exercises the culvert and checks values outside rating curve
     37        are dealt with       
    3838        """
    3939
     
    112112        Br = Reflective_boundary(domain)              # Solid reflective wall
    113113        Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
    114         Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+sin(2*pi*(t-4)/10)), 0.0, 0.0])
    115         Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+sin(2*pi*(t-4)/20)), 0.0, 0.0])
     114       
     115        # Upstream and downstream conditions that will exceed the rating curve
     116        # I.e produce delta_h outside the range [0, 10] specified in the the
     117        # file example_rating_curve.csv
     118        Btus = Time_boundary(domain, lambda t: [100*sin(2*pi*(t-4)/10), 0.0, 0.0])
     119        Btds = Time_boundary(domain, lambda t: [-5*(cos(2*pi*(t-4)/20)), 0.0, 0.0])
    116120        domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br})
    117121
     
    427431#-------------------------------------------------------------
    428432if __name__ == "__main__":
    429     #suite = unittest.makeSuite(Test_Culvert, 'test_predicted_flow')
     433    #suite = unittest.makeSuite(Test_Culvert, 'test_that_culvert_runs_rating')
    430434    suite = unittest.makeSuite(Test_Culvert, 'test')
    431435    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.