# Changeset 6150

Ignore:
Timestamp:
Jan 13, 2009, 1:42:28 PM (14 years ago)
Message:

Change Numeric imports to general form - ready to change to NumPy?.

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

Unmodified
Removed
• ## anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py

 r6143 from math import pi,pow,sqrt from Numeric import choose, greater, ones, sin, exp, cosh import Numeric as num #------------------------------------------------------------------------------ # Setup computational domain Br = Reflective_boundary(domain)              # Solid reflective wall Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+sin(2*pi*(t-4)/10)), 0.0, 0.0]) Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+sin(2*pi*(t-4)/20)), 0.0, 0.0]) Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+num.sin(2*pi*(t-4)/10)), 0.0, 0.0]) Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+num.sin(2*pi*(t-4)/20)), 0.0, 0.0]) domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br})
• ## anuga_core/source/anuga/culvert_flows/culvert_class.py

 r6143 import sys from anuga.shallow_water.shallow_water_domain import Inflow, General_forcing from anuga.culvert_flows.culvert_polygons import create_culvert_polygons from anuga.config import g, epsilon from Numeric import take, sqrt from anuga.config import minimum_allowed_height, velocity_protection from Numeric import allclose from Numeric import sqrt, sum import sys import Numeric as num class Below_interval(Exception): pass self.length = P['length']; assert self.length > 0.0 if culvert_description_filename is not None: if not allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): if not num.allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): msg = 'WARNING: barrel length specified in "%s" (%.2f m)'\ % (culvert_description_filename, self.vector = P['vector'] self.length = P['length']; assert self.length > 0.0 if not allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): if not num.allclose(self.length, length, rtol=1.0e-2, atol=1.0e-2): msg = 'WARNING: barrel length specified in "%s" (%.2f m)' %(culvert_description_filename, length) msg += ' does not match distance between specified' verbose=False): from Numeric import sqrt, sum # Input check if diameter is not None:
• ## anuga_core/source/anuga/culvert_flows/culvert_polygons.py

 r6121 # Import necessary modules from math import sqrt from Numeric import array, sum from anuga.utilities.polygon import inside_polygon, polygon_area import Numeric as num def create_culvert_polygons(end_point0, dy = y1-y0 vector = array([dx, dy]) length = sqrt(sum(vector**2)) vector = num.array([dx, dy]) length = sqrt(num.sum(vector**2)) # Adjust polygon width to number of barrels in this culvert # Unit direction vector and normal vector /= length                 # Unit vector in culvert direction normal = array([-dy, dx])/length # Normal vector normal = num.array([-dy, dx])/length # Normal vector culvert_polygons['vector'] = vector p2 = p1 - h p3 = p0 - h culvert_polygons['exchange_polygon0'] = array([p0,p1,p2,p3]) culvert_polygons['exchange_polygon0'] = num.array([p0,p1,p2,p3]) culvert_polygons['enquiry_point0'] = end_point0 - gap p2 = p1 + h p3 = p0 + h culvert_polygons['exchange_polygon1'] = array([p0,p1,p2,p3]) culvert_polygons['exchange_polygon1'] = num.array([p0,p1,p2,p3]) culvert_polygons['enquiry_point1'] = end_point1 + gap
• ## anuga_core/source/anuga/culvert_flows/test_culvert_class.py

 r6144 from math import pi,pow,sqrt from Numeric import choose, greater, ones, sin, cos, exp, cosh, allclose import Numeric as num # I.e produce delta_h outside the range [0, 10] specified in the the # file example_rating_curve.csv Btus = Time_boundary(domain, lambda t: [100*sin(2*pi*(t-4)/10), 0.0, 0.0]) Btds = Time_boundary(domain, lambda t: [-5*(cos(2*pi*(t-4)/20)), 0.0, 0.0]) Btus = Time_boundary(domain, lambda t: [100*num.sin(2*pi*(t-4)/10), 0.0, 0.0]) Btds = Time_boundary(domain, lambda t: [-5*(num.cos(2*pi*(t-4)/20)), 0.0, 0.0]) domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br}) msg = 'Total volume has changed' assert allclose(new_volume, ref_volume), msg assert num.allclose(new_volume, ref_volume), msg pass msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\ % (new_volume, ref_volume) if not allclose(new_volume, ref_volume): if not num.allclose(new_volume, ref_volume): print msg assert allclose(new_volume, ref_volume), msg assert num.allclose(new_volume, ref_volume), msg % (new_volume, ref_volume) assert allclose(new_volume, ref_volume), msg assert num.allclose(new_volume, ref_volume), msg msg = 'Total volume has changed' assert allclose(new_volume, ref_volume), msg assert num.allclose(new_volume, ref_volume), msg pass
• ## anuga_core/source/anuga/culvert_flows/test_culvert_polygons.py

 r6121 import os.path from Numeric import choose, greater, ones, sin, exp, cosh, allclose from anuga.utilities.polygon import inside_polygon, polygon_area
Note: See TracChangeset for help on using the changeset viewer.