Changeset 6150


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

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

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  
    2525     
    2626from math import pi,pow,sqrt
    27 from Numeric import choose, greater, ones, sin, exp, cosh
     27
     28import Numeric as num
     29
     30
    2831#------------------------------------------------------------------------------
    2932# Setup computational domain
     
    131134Br = Reflective_boundary(domain)              # Solid reflective wall
    132135Bo = 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])
     136Btus = Time_boundary(domain, lambda t: [0.0+ 1.25*(1+num.sin(2*pi*(t-4)/10)), 0.0, 0.0])
     137Btds = Time_boundary(domain, lambda t: [0.0+ 0.75*(1+num.sin(2*pi*(t-4)/20)), 0.0, 0.0])
    135138domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br})
    136139
  • anuga_core/source/anuga/culvert_flows/culvert_class.py

    r6143 r6150  
     1import sys
     2
    13from anuga.shallow_water.shallow_water_domain import Inflow, General_forcing
    24from anuga.culvert_flows.culvert_polygons import create_culvert_polygons
     
    1012       
    1113from anuga.config import g, epsilon
    12 from Numeric import take, sqrt
    1314from anuga.config import minimum_allowed_height, velocity_protection       
    1415
    15        
    16 
    17 
    18 from Numeric import allclose
    19 from Numeric import sqrt, sum
    20 
    21 
    22 
    23 import sys
     16import Numeric as num
     17
    2418
    2519class Below_interval(Exception): pass
     
    284278        self.length = P['length']; assert self.length > 0.0
    285279        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):
    287281                msg = 'WARNING: barrel length specified in "%s" (%.2f m)'\
    288282                    % (culvert_description_filename,
     
    770764        self.vector = P['vector']
    771765        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):
    773767            msg = 'WARNING: barrel length specified in "%s" (%.2f m)' %(culvert_description_filename, length)
    774768            msg += ' does not match distance between specified'
     
    1002996                 verbose=False):
    1003997       
    1004         from Numeric import sqrt, sum
    1005 
    1006998        # Input check
    1007999        if diameter is not None:
  • anuga_core/source/anuga/culvert_flows/culvert_polygons.py

    r6121 r6150  
    44# Import necessary modules
    55from math import sqrt
    6 from Numeric import array, sum
    76from anuga.utilities.polygon import inside_polygon, polygon_area
     7
     8import Numeric as num
     9
    810
    911def create_culvert_polygons(end_point0,
     
    5456    dy = y1-y0
    5557
    56     vector = array([dx, dy])
    57     length = sqrt(sum(vector**2))
     58    vector = num.array([dx, dy])
     59    length = sqrt(num.sum(vector**2))
    5860
    5961    # Adjust polygon width to number of barrels in this culvert
     
    6365    # Unit direction vector and normal
    6466    vector /= length                 # Unit vector in culvert direction
    65     normal = array([-dy, dx])/length # Normal vector
     67    normal = num.array([-dy, dx])/length # Normal vector
    6668   
    6769    culvert_polygons['vector'] = vector
     
    8183    p2 = p1 - h
    8284    p3 = p0 - h
    83     culvert_polygons['exchange_polygon0'] = array([p0,p1,p2,p3])
     85    culvert_polygons['exchange_polygon0'] = num.array([p0,p1,p2,p3])
    8486    culvert_polygons['enquiry_point0'] = end_point0 - gap
    8587   
     
    9092    p2 = p1 + h
    9193    p3 = p0 + h
    92     culvert_polygons['exchange_polygon1'] = array([p0,p1,p2,p3])
     94    culvert_polygons['exchange_polygon1'] = num.array([p0,p1,p2,p3])
    9395    culvert_polygons['enquiry_point1'] = end_point1 + gap 
    9496
  • anuga_core/source/anuga/culvert_flows/test_culvert_class.py

    r6144 r6150  
    2020     
    2121from math import pi,pow,sqrt
    22 from Numeric import choose, greater, ones, sin, cos, exp, cosh, allclose
    23 
     22
     23import Numeric as num
    2424
    2525
     
    118118        # I.e produce delta_h outside the range [0, 10] specified in the the
    119119        # 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])
    122122        domain.set_boundary({'left': Btus, 'right': Btds, 'top': Br, 'bottom': Br})
    123123
     
    240240           
    241241            msg = 'Total volume has changed'
    242             assert allclose(new_volume, ref_volume), msg
     242            assert num.allclose(new_volume, ref_volume), msg
    243243            pass
    244244   
     
    344344            msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\
    345345                % (new_volume, ref_volume)
    346             if not allclose(new_volume, ref_volume):
     346            if not num.allclose(new_volume, ref_volume):
    347347                print msg
    348             assert allclose(new_volume, ref_volume), msg       
     348            assert num.allclose(new_volume, ref_volume), msg       
    349349       
    350350       
     
    367367                    % (new_volume, ref_volume)
    368368
    369                 assert allclose(new_volume, ref_volume), msg
     369                assert num.allclose(new_volume, ref_volume), msg
    370370   
    371371   
     
    474474           
    475475            msg = 'Total volume has changed'
    476             assert allclose(new_volume, ref_volume), msg
     476            assert num.allclose(new_volume, ref_volume), msg
    477477            pass
    478478   
  • anuga_core/source/anuga/culvert_flows/test_culvert_polygons.py

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