Changeset 6103
- Timestamp:
- Dec 24, 2008, 12:40:42 PM (15 years ago)
- 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 18 18 # FIXME(Ole): Write in C and reuse this function by similar code in interpolate.py 19 19 def 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 22 32 i = 0 23 33 while x > xvec[i]: i += 1 24 34 25 if i == 0:26 msg = 'Value provided = %.2f, interpolation minimum = %.2f.' %(x, xvec[0])27 raise Below_interval, msg28 29 if i == len(xvec):30 msg = 'Value provided = %.2f, interpolation maximum = %.2f.' %(x, xvec[-1])31 raise Above_interval, msg32 33 35 34 36 x0 = xvec[i-1] … … 305 307 stage = dq['stage'].get_values(location='centroids', 306 308 indices=[self.enquiry_indices[i]]) 307 308 309 309 310 # Store current average stage and depth with each opening object 310 311 opening.depth = stage - opening.elevation … … 332 333 else: 333 334 # Calculate discharge for one barrel and set inlet.rate and outlet.rate 335 334 336 try: 335 337 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 19 19 20 20 from math import pi,pow,sqrt 21 from Numeric import choose, greater, ones, sin, exp, cosh, allclose21 from Numeric import choose, greater, ones, sin, cos, exp, cosh, allclose 22 22 23 23 … … 31 31 32 32 33 def test_that_culvert_runs (self):34 """test_that_culvert_runs 35 36 This test only exercises the culvert - there is no quantitative37 diagnostics yet33 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 38 38 """ 39 39 … … 112 112 Br = Reflective_boundary(domain) # Solid reflective wall 113 113 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]) 116 120 domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) 117 121 … … 427 431 #------------------------------------------------------------- 428 432 if __name__ == "__main__": 429 #suite = unittest.makeSuite(Test_Culvert, 'test_ predicted_flow')433 #suite = unittest.makeSuite(Test_Culvert, 'test_that_culvert_runs_rating') 430 434 suite = unittest.makeSuite(Test_Culvert, 'test') 431 435 runner = unittest.TextTestRunner()
Note: See TracChangeset
for help on using the changeset viewer.