Changeset 6150
- Timestamp:
- Jan 13, 2009, 1:42:28 PM (16 years ago)
- Location:
- anuga_core/source/anuga/culvert_flows
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py
r6143 r6150 25 25 26 26 from math import pi,pow,sqrt 27 from Numeric import choose, greater, ones, sin, exp, cosh 27 28 import Numeric as num 29 30 28 31 #------------------------------------------------------------------------------ 29 32 # Setup computational domain … … 131 134 Br = Reflective_boundary(domain) # Solid reflective wall 132 135 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 133 Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+ sin(2*pi*(t-4)/10)), 0.0, 0.0])134 Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+ sin(2*pi*(t-4)/20)), 0.0, 0.0])136 Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+num.sin(2*pi*(t-4)/10)), 0.0, 0.0]) 137 Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+num.sin(2*pi*(t-4)/20)), 0.0, 0.0]) 135 138 domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) 136 139 -
anuga_core/source/anuga/culvert_flows/culvert_class.py
r6143 r6150 1 import sys 2 1 3 from anuga.shallow_water.shallow_water_domain import Inflow, General_forcing 2 4 from anuga.culvert_flows.culvert_polygons import create_culvert_polygons … … 10 12 11 13 from anuga.config import g, epsilon 12 from Numeric import take, sqrt13 14 from anuga.config import minimum_allowed_height, velocity_protection 14 15 15 16 17 18 from Numeric import allclose 19 from Numeric import sqrt, sum 20 21 22 23 import sys 16 import Numeric as num 17 24 18 25 19 class Below_interval(Exception): pass … … 284 278 self.length = P['length']; assert self.length > 0.0 285 279 if culvert_description_filename is not None: 286 if not allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2):280 if not num.allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): 287 281 msg = 'WARNING: barrel length specified in "%s" (%.2f m)'\ 288 282 % (culvert_description_filename, … … 770 764 self.vector = P['vector'] 771 765 self.length = P['length']; assert self.length > 0.0 772 if not allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2):766 if not num.allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): 773 767 msg = 'WARNING: barrel length specified in "%s" (%.2f m)' %(culvert_description_filename, length) 774 768 msg += ' does not match distance between specified' … … 1002 996 verbose=False): 1003 997 1004 from Numeric import sqrt, sum1005 1006 998 # Input check 1007 999 if diameter is not None: -
anuga_core/source/anuga/culvert_flows/culvert_polygons.py
r6121 r6150 4 4 # Import necessary modules 5 5 from math import sqrt 6 from Numeric import array, sum7 6 from anuga.utilities.polygon import inside_polygon, polygon_area 7 8 import Numeric as num 9 8 10 9 11 def create_culvert_polygons(end_point0, … … 54 56 dy = y1-y0 55 57 56 vector = array([dx, dy])57 length = sqrt( sum(vector**2))58 vector = num.array([dx, dy]) 59 length = sqrt(num.sum(vector**2)) 58 60 59 61 # Adjust polygon width to number of barrels in this culvert … … 63 65 # Unit direction vector and normal 64 66 vector /= length # Unit vector in culvert direction 65 normal = array([-dy, dx])/length # Normal vector67 normal = num.array([-dy, dx])/length # Normal vector 66 68 67 69 culvert_polygons['vector'] = vector … … 81 83 p2 = p1 - h 82 84 p3 = p0 - h 83 culvert_polygons['exchange_polygon0'] = array([p0,p1,p2,p3])85 culvert_polygons['exchange_polygon0'] = num.array([p0,p1,p2,p3]) 84 86 culvert_polygons['enquiry_point0'] = end_point0 - gap 85 87 … … 90 92 p2 = p1 + h 91 93 p3 = p0 + h 92 culvert_polygons['exchange_polygon1'] = array([p0,p1,p2,p3])94 culvert_polygons['exchange_polygon1'] = num.array([p0,p1,p2,p3]) 93 95 culvert_polygons['enquiry_point1'] = end_point1 + gap 94 96 -
anuga_core/source/anuga/culvert_flows/test_culvert_class.py
r6144 r6150 20 20 21 21 from math import pi,pow,sqrt 22 from Numeric import choose, greater, ones, sin, cos, exp, cosh, allclose 23 22 23 import Numeric as num 24 24 25 25 … … 118 118 # I.e produce delta_h outside the range [0, 10] specified in the the 119 119 # file example_rating_curve.csv 120 Btus = Time_boundary(domain, lambda t: [100* sin(2*pi*(t-4)/10), 0.0, 0.0])121 Btds = Time_boundary(domain, lambda t: [-5*( cos(2*pi*(t-4)/20)), 0.0, 0.0])120 Btus = Time_boundary(domain, lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0]) 121 Btds = Time_boundary(domain, lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0]) 122 122 domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) 123 123 … … 240 240 241 241 msg = 'Total volume has changed' 242 assert allclose(new_volume, ref_volume), msg242 assert num.allclose(new_volume, ref_volume), msg 243 243 pass 244 244 … … 344 344 msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\ 345 345 % (new_volume, ref_volume) 346 if not allclose(new_volume, ref_volume):346 if not num.allclose(new_volume, ref_volume): 347 347 print msg 348 assert allclose(new_volume, ref_volume), msg348 assert num.allclose(new_volume, ref_volume), msg 349 349 350 350 … … 367 367 % (new_volume, ref_volume) 368 368 369 assert allclose(new_volume, ref_volume), msg369 assert num.allclose(new_volume, ref_volume), msg 370 370 371 371 … … 474 474 475 475 msg = 'Total volume has changed' 476 assert allclose(new_volume, ref_volume), msg476 assert num.allclose(new_volume, ref_volume), msg 477 477 pass 478 478 -
anuga_core/source/anuga/culvert_flows/test_culvert_polygons.py
r6121 r6150 6 6 import os.path 7 7 8 from Numeric import choose, greater, ones, sin, exp, cosh, allclose9 8 from anuga.utilities.polygon import inside_polygon, polygon_area 10 9
Note: See TracChangeset
for help on using the changeset viewer.