Index: /anuga_core/source/anuga/culvert_flows/culvert_routines.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/culvert_routines.py	(revision 7072)
+++ /anuga_core/source/anuga/culvert_flows/culvert_routines.py	(revision 7073)
@@ -1,3 +1,8 @@
 """Collection of culvert routines for use with Culvert_flow in culvert_class
+
+This module holds various riutines to determine FLOW through CULVERTS and SIMPLE BRIDGES
+
+
+
 
 Usage:
@@ -33,14 +38,43 @@
                                    log_filename=None):
 
-    """Boyd's generalisation of the US department of transportation culvert 
-    model
-      
-    The quantity of flow passing through a culvert is controlled by many factors
-    It could be that the culvert is controlled by the inlet only, with it 
-    being unsubmerged this is effectively equivalent to the weir Equation
-    Else the culvert could be controlled by the inlet, with it being 
-    submerged, this is effectively the Orifice Equation
-    Else it may be controlled by down stream conditions where depending on 
-    the down stream depth, the momentum in the culvert etc. flow is controlled 
+    """Boyd's generalisation of the US department of transportation culvert methods
+	
+	WARNING THIS IS A SIMPLISTIC APPROACH and OUTLET VELOCITIES ARE LIMITED TO EITHER
+	FULL PIPE OR CRITICAL DEPTH ONLY
+	For Supercritical flow this is UNDERESTIMATING the Outlet Velocity
+	The obtain the CORRECT velocity requires an iteration of Depth to Establish 
+	the Normal Depth of flow in the pipe.
+	
+	It is proposed to provide this in a seperate routine called
+    boyd_generalised_culvert_model_complex
+	
+    The Boyd Method is based on methods described by the following:
+	1.
+	US Dept. Transportation Federal Highway Administration (1965) 
+	Hydraulic Chart for Selection of Highway Culverts.
+	Hydraulic Engineering Circular No. 5 US Government Printing
+	2.
+	US Dept. Transportation Federal Highway Administration (1972) 
+	Capacity charts for the Hydraulic design of highway culverts.
+	Hydraulic Engineering Circular No. 10 US Government Printing
+    These documents provide around 60 charts for various configurations of culverts and inlets.
+	
+	Note these documents have been superceded by:
+	2005 Hydraulic Design of Highway Culverts, Hydraulic Design Series No. 5 (HDS-5), 
+	Which combines culvert design information previously contained in Hydraulic Engineering Circulars 
+	(HEC) No. 5, No. 10, and No. 13 with hydrologic, storage routing, and special culvert design information.
+	HEC-5 provides 20 Charts
+	HEC-10 Provides an additional 36 Charts
+	HEC-13 Discusses the Design of improved more efficient inlets
+	HDS-5 Provides 60 sets of Charts
+
+	In 1985 Professor Michael Boyd Published "Head-Discharge Relations for Culverts", and in
+	1987 published "Generalised Head Discharge Equations for Culverts".
+	These papers reviewed the previous work by the US DOT and provided a simplistic approach for 3 configurations.
+	
+	It may be possible to extend the same approach for additional charts in the original work, but to date this has not been done.
+	The additional charts cover a range of culvert shapes and inlet configurations
+	
+   
     """
 
@@ -48,7 +82,10 @@
     from anuga.config import velocity_protection
     from anuga.utilities.numerical_tools import safe_acos as acos
-
-
+    print "STARTING..BOYD................."
+    local_debug ='false'
     if inlet_depth > 0.1: #this value was 0.01:
+        if local_debug =='true':
+            print 'Specific E & Deltat Tot E = ',inlet_specific_energy,delta_total_energy
+            print 'culvert typ = ',culvert_type
         # Water has risen above inlet
         
@@ -61,81 +98,136 @@
                       
 
-        if culvert_type == 'circle':
-            # Round culvert (use width as diameter)
-            diameter = culvert_width            
-
+        if culvert_type =='circle':
+            # Round culvert (use height as diameter)
+            diameter = culvert_height   
+
+            """
+            For a circular pipe the Boyd method reviews 3 conditions
+            1. Whether the Pipe Inlet is Unsubmerged (acting as weir flow into the inlet)
+            2. Whether the Pipe Inlet is Fully Submerged (acting as an Orifice)
+            3. Whether the energy loss in the pipe results in the Pipe being controlled by Channel Flow of the Pipe 
+            
+            For these conditions we also would like to assess the pipe flow characteristics as it leaves the pipe
+            """
+            
             # Calculate flows for inlet control            
             Q_inlet_unsubmerged = 0.421*g**0.5*diameter**0.87*inlet_specific_energy**1.63 # Inlet Ctrl Inlet Unsubmerged 
             Q_inlet_submerged = 0.530*g**0.5*diameter**1.87*inlet_specific_energy**0.63   # Inlet Ctrl Inlet Submerged
+            # Note for to SUBMERGED TO OCCUR inlet_specific_energy should be > 1.2 x diameter.... Should Check !!!
 
             if log_filename is not None:                                        
                 s = 'Q_inlet_unsubmerged = %.6f, Q_inlet_submerged = %.6f' % (Q_inlet_unsubmerged, Q_inlet_submerged)
                 log_to_file(log_filename, s)
-
-
-            # FIXME(Ole): Are these functions really for inlet control?                    
-            if Q_inlet_unsubmerged < Q_inlet_submerged:
-                Q = Q_inlet_unsubmerged
-                alpha = acos(1 - inlet_depth/diameter)
-                flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
-                outlet_culvert_depth = inlet_depth
-                case = 'Inlet unsubmerged'
-            else:    
-                Q = Q_inlet_submerged
-                flow_area = (diameter/2)**2 * pi
-                outlet_culvert_depth = diameter
-                case = 'Inlet submerged'                    
-
-
-
-            if delta_total_energy < inlet_specific_energy:
+            Q = min(Q_inlet_unsubmerged, Q_inlet_submerged)
+
+            # THE LOWEST Value will Control Calcs From here
+            # Calculate Critical Depth Based on the Adopted Flow as an Estimate
+            dcrit1 = diameter/1.26*(Q/g**0.5*diameter**2.5)**(1/3.75)
+            dcrit2 = diameter/0.95*(Q/g**0.5*diameter**2.5)**(1/1.95)
+            # From Boyd Paper ESTIMATE of Dcrit has 2 criteria as
+            if dcrit1/diameter  > 0.85:
+                outlet_culvert_depth = dcrit2
+            else:
+                outlet_culvert_depth = dcrit1
+            #outlet_culvert_depth = min(outlet_culvert_depth, diameter)
+            # Now determine Hydraulic Radius Parameters Area & Wetted Perimeter
+            if outlet_culvert_depth >= diameter:
+                outlet_culvert_depth = diameter  # Once again the pipe is flowing full not partfull
+                flow_area = (diameter/2)**2 * pi  # Cross sectional area of flow in the culvert
+                perimeter = diameter * pi
+                flow_width= diameter
+                case = 'Inlet CTRL Outlet submerged Circular PIPE FULL'
+                if local_debug =='true':
+                    print 'Inlet CTRL Outlet submerged Circular PIPE FULL'
+            else:
+                #alpha = acos(1 - outlet_culvert_depth/diameter)    # Where did this Come From ????/
+                alpha = acos(1-2*outlet_culvert_depth/diameter)*2
+                #flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))        # Pipe is Running Partly Full at the INLET   WHRE did this Come From ?????
+                flow_area = diameter**2/8*(alpha - sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
+                flow_width= diameter*sin(alpha/2.0)
+                perimeter = alpha*diameter/2.0
+                case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
+                if local_debug =='true':
+                    print 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
+                    print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,'  ',alpha
+            if delta_total_energy < inlet_specific_energy:  #  OUTLET CONTROL !!!!
                 # Calculate flows for outlet control
                 
                 # Determine the depth at the outlet relative to the depth of flow in the Culvert
-                if outlet_depth > diameter:        # The Outlet is Submerged
+                if outlet_depth > diameter:       # Outlet is submerged Assume the end of the Pipe is flowing FULL
                     outlet_culvert_depth=diameter
                     flow_area = (diameter/2)**2 * pi  # Cross sectional area of flow in the culvert
                     perimeter = diameter * pi
+                    flow_width= diameter
                     case = 'Outlet submerged'
-                elif outlet_depth==0.0: 
-                    outlet_culvert_depth=inlet_depth # For purpose of calculation assume the outlet depth = the inlet depth
-                    alpha = acos(1 - inlet_depth/diameter)
-                    flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
-                    perimeter = alpha*diameter
-
-                    case = 'Outlet depth is zero'                        
-                else:   # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
-                    outlet_culvert_depth=outlet_depth   # For purpose of calculation assume the outlet depth = the inlet depth
-                    alpha = acos(1 - outlet_depth/diameter)
-                    flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))
-                    perimeter = alpha*diameter
-                    case = 'Outlet is open channel flow'
-
-                hyd_rad = flow_area/perimeter
-                
-                if log_filename is not None:
-                    s = 'hydraulic radius at outlet = %f' %hyd_rad
-                    log_to_file(log_filename, s)
-
-                # Outlet control velocity using tail water
-                culvert_velocity = sqrt(delta_total_energy/((sum_loss/2/g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 
-                Q_outlet_tailwater = flow_area * culvert_velocity
-                
-                if log_filename is not None:                
-                    s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
-                    log_to_file(log_filename, s)
-                    
-                Q = min(Q, Q_outlet_tailwater)
-            else:
-                pass
+                    if local_debug =='true':
+                        print 'Outlet submerged'
+                else:   # Culvert running PART FULL for PART OF ITS LENGTH   Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
+                    # IF  outlet_depth < diameter
+                    dcrit1 = diameter/1.26*(Q/g**0.5*diameter**2.5)**(1/3.75)
+                    dcrit2 = diameter/0.95*(Q/g**0.5*diameter**2.5)**(1/1.95)
+                    if dcrit1/diameter >0.85:
+                        outlet_culvert_depth= dcrit2
+                    else:
+                        outlet_culvert_depth = dcrit1
+                    if outlet_culvert_depth > diameter:
+                        outlet_culvert_depth = diameter  # Once again the pipe is flowing full not partfull
+                        flow_area = (diameter/2)**2 * pi  # Cross sectional area of flow in the culvert
+                        perimeter = diameter * pi
+                        flow_width= diameter
+                        case = 'Outlet unsubmerged PIPE FULL'
+                        if local_debug =='true':
+                            print  'Outlet unsubmerged PIPE FULL'
+                    else:
+                        alpha = acos(1-2*outlet_culvert_depth/diameter)*2
+                        flow_area = diameter**2/8*(alpha - sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
+                        flow_width= diameter*sin(alpha/2.0)
+                        perimeter = alpha*diameter/2.0
+                        case = 'Outlet is open channel flow we will for now assume critical depth'
+                        if local_debug =='true':
+                            print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,'  ',alpha
+                            print 'Outlet is open channel flow we will for now assume critical depth'
+            if local_debug =='true':
+                print 'FLOW AREA = ',flow_area
+                print 'PERIMETER = ',perimeter
+                print 'Q Interim = ',Q
+            hyd_rad = flow_area/perimeter
+
+            if log_filename is not None:
+                s = 'hydraulic radius at outlet = %f' %hyd_rad
+                log_to_file(log_filename, s)
+
+            # Outlet control velocity using tail water
+            if local_debug =='true':
+                print 'GOT IT ALL CALCULATING Velocity'
+                print 'HydRad = ',hyd_rad      
+            culvert_velocity = sqrt(delta_total_energy/((sum_loss/2/g)+(manning**2*culvert_length)/hyd_rad**1.33333)) 
+            Q_outlet_tailwater = flow_area * culvert_velocity
+            if local_debug =='true':
+                print 'VELOCITY = ',culvert_velocity
+                print 'Outlet Ctrl Q = ',Q_outlet_tailwater
+            if log_filename is not None:                
+                s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
+                log_to_file(log_filename, s)
+            Q = min(Q, Q_outlet_tailwater)
+            if local_debug =='true':
+                print ('%s,%.3f,%.3f' %('dcrit 1 , dcit2 =',dcrit1,dcrit2))
+                print ('%s,%.3f,%.3f,%.3f' %('Q and Velocity and Depth=',Q,culvert_velocity,outlet_culvert_depth))
+
+        else:
+            pass
                 #FIXME(Ole): What about inlet control?
-
-
-        else:
-            # Box culvert (rectangle or square)
+        # ====  END OF CODE BLOCK FOR "IF" CIRCULAR PIPE 
+
+        #else....
+        if culvert_type =='box':
+            if local_debug =='true':
+                print 'BOX CULVERT'
+            # Box culvert (rectangle or square)   ========================================================================================================================
 
             # Calculate flows for inlet control
             height = culvert_height
-            width = culvert_width            
+            width = culvert_width
+            flow_width=culvert_width            
             
             Q_inlet_unsubmerged = 0.540*g**0.5*width*inlet_specific_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged
@@ -146,17 +238,32 @@
                 log_to_file(log_filename, s)
 
-
             # FIXME(Ole): Are these functions really for inlet control?    
             if Q_inlet_unsubmerged < Q_inlet_submerged:
                 Q = Q_inlet_unsubmerged
-                flow_area = width*inlet_depth
-                outlet_culvert_depth = inlet_depth
-                case = 'Inlet unsubmerged'
+                dcrit = (Q**2/g/width**2)**0.333333
+                if dcrit > height:
+                    dcrit = height
+                flow_area = width*dcrit
+                outlet_culvert_depth = dcrit
+                case = 'Inlet unsubmerged Box Acts as Weir'
             else:    
                 Q = Q_inlet_submerged
                 flow_area = width*height
                 outlet_culvert_depth = height
-                case = 'Inlet submerged'                    
-
+                case = 'Inlet submerged Box Acts as Orifice'                    
+
+            dcrit = (Q**2/g/width**2)**0.333333
+
+            outlet_culvert_depth = dcrit
+            if outlet_culvert_depth > height:
+                outlet_culvert_depth = height  # Once again the pipe is flowing full not partfull
+                flow_area = width*height  # Cross sectional area of flow in the culvert
+                perimeter = 2*(width+height)
+                case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL'
+            else:
+                flow_area = width * outlet_culvert_depth
+                perimeter = width+2*outlet_culvert_depth
+                case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
+	
             if delta_total_energy < inlet_specific_energy:
                 # Calculate flows for outlet control
@@ -168,17 +275,19 @@
                     perimeter=2.0*(width+height)
                     case = 'Outlet submerged'
-                elif outlet_depth==0.0: 
-                    outlet_culvert_depth=inlet_depth   # For purpose of calculation assume the outlet depth = the inlet depth
-                    flow_area=width*inlet_depth
-                    perimeter=(width+2.0*inlet_depth)
-                    case = 'Outlet depth is zero'                        
                 else:   # Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
-                    outlet_culvert_depth=outlet_depth
-                    flow_area=width*outlet_depth
-                    perimeter=(width+2.0*outlet_depth)
-                    case = 'Outlet is open channel flow'
+                    dcrit = (Q**2/g/width**2)**0.333333
+                    outlet_culvert_depth=dcrit   # For purpose of calculation assume the outlet depth = Critical Depth
+                    if outlet_culvert_depth > height:
+                        outlet_culvert_depth=height
+                        flow_area=width*height
+                        perimeter=2.0*(width+height)
+                        case = 'Outlet is Flowing Full'
+                    else:
+                        flow_area=width*outlet_culvert_depth
+                        perimeter=(width+2.0*outlet_culvert_depth)
+                        case = 'Outlet is open channel flow'
 
                 hyd_rad = flow_area/perimeter
-                
+           
                 if log_filename is not None:                                
                     s = 'hydraulic radius at outlet = %f' % hyd_rad
@@ -196,7 +305,8 @@
                 pass
                 #FIXME(Ole): What about inlet control?
+        # ====  END OF CODE BLOCK FOR "IF" BOX 
 
                 
-        # Common code for circle and square geometries
+        # Common code for circle and box geometries ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         if log_filename is not None:
             log_to_file(log_filename, 'Case: "%s"' % case)
@@ -205,8 +315,10 @@
             s = 'Flow Rate Control = %f' % Q
             log_to_file(log_filename, s)
-
-            
-        culv_froude=sqrt(Q**2*width/(g*flow_area**3))
-        
+        culv_froude=sqrt(Q**2*flow_width/(g*flow_area**3))
+        if local_debug =='true':
+            print 'FLOW AREA = ',flow_area
+            print 'PERIMETER = ',perimeter
+            print 'Q final = ',Q
+            print 'FROUDE = ',culv_froude
         if log_filename is not None:                            
             s = 'Froude in Culvert = %f' % culv_froude
@@ -215,5 +327,5 @@
         # Determine momentum at the outlet 
         barrel_velocity = Q/(flow_area + velocity_protection/flow_area)
-
+    # END CODE BLOCK for DEPTH  > Required depth for CULVERT Flow  
 
     else: # inlet_depth < 0.01:
Index: uga_core/source/anuga/culvert_flows/test_culvert_routines.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_routines.py	(revision 7072)
+++ 	(revision )
@@ -1,588 +1,0 @@
-#!/usr/bin/env python
-
-
-import unittest
-import os.path
-import sys
-
-from anuga.utilities.system_tools import get_pathname_from_package
-from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
-import Numeric as num
-
-
-class Test_culvert_routines(unittest.TestCase):
-    def setUp(self):
-        pass
-
-    def tearDown(self):
-        pass
-
-
-    def test_boyd_0(self):
-        """test_boyd_0
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski
-        This test is the only one that passed in late February 2009
-        """
-      
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=2.0
-        outlet_depth=0.0
-        
-        inlet_velocity=0.0,
-        outlet_velocity=0.0,        
-
-        culvert_length=4.0
-        culvert_width=1.2
-        culvert_height=0.75
-
-        culvert_type='box'
-        manning=0.013
-        sum_loss=0.0
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth # + 
-        E_out = z_out+outlet_depth # +
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_velocity,
-                                                 outlet_velocity,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        #print Q, v, d
-        assert num.allclose(Q, 3.118, rtol=1.0e-3)
-        
-
-        #assert num.allclose(v, 0.93)
-        #assert num.allclose(d, 0.0)
-        
-
-    def Xtest_boyd_00(self):
-        """test_boyd_00
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=0.2
-        outlet_depth=0.0
-
-        inlet_velocity=0.0,
-        outlet_velocity=0.0,                
-        
-        culvert_length=4.0
-        culvert_width=1.2
-        culvert_height=0.75
-
-        culvert_type='box'
-        manning=0.013
-        sum_loss=0.0
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth # + 
-        E_out = z_out+outlet_depth # +
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_velocity,
-                                                 outlet_velocity,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        #print Q, v, d
-        assert num.allclose(Q, 0.185, rtol=1.0e-3)
-        #assert num.allclose(v, 0.93)
-        #assert num.allclose(d, 0.0)
-        
-
-
-    def Xtest_boyd_1(self):
-        """test_boyd_1
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=0.263
-        outlet_depth=0.0
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 0.10, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 1.13, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.15, rtol=1.0e-2) #depth at outlet used to calc v 
-        
-    def Xtest_boyd_2(self):
-        """test_boyd_2
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=1.135
-        outlet_depth=0.0
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_velocity,
-                                                 outlet_velocity,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 1.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 2.59, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.563, rtol=1.0e-2) #depth at outlet used to calc v  
-
-    def Xtest_boyd_3(self):
-        """test_boyd_3
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=12.747
-        outlet_depth=0.0
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 5.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 11.022, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.72, rtol=1.0e-2) #depth at outlet used to calc v
-
-    def Xtest_boyd_4(self):
-        """test_boyd_4
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=1.004
-        outlet_depth=1.00
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 0.10, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 0.22, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-
-    def Xtest_boyd_5(self):
-        """test_boyd_5
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=1.401
-        outlet_depth=1.00
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 1.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 2.204, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-
-
-    def Xtest_boyd_6(self):
-        """test_boyd_5
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.01  # Downward
-
-        inlet_depth=12.747
-        outlet_depth=1.00
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 5.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 11.022, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-
-
-    def Xtest_boyd_7(self):
-        """test_boyd_7
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=0.303
-        outlet_depth=0.00
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 0.10, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 1.13, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.19, rtol=1.0e-2) #depth at outlet used to calc v
-
-
-    def Xtest_boyd_8(self):
-        """test_boyd_8
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=1.135
-        outlet_depth=0.00
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 1.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 2.204, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-
-    def Xtest_boyd_9(self):
-        """test_boyd_9
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=1.1504
-        outlet_depth=1.5
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 0.10, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 0.22, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-
-
-    def Xtest_boyd_10(self):
-        """test_boyd_9
-        
-        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
-        """
-        # FIXME(Ole): This test fails (20 Feb 2009)
-
-        g=9.81
-        culvert_slope=0.1  # Downward
-
-        inlet_depth=1.901
-        outlet_depth=1.5
-
-        culvert_length=4.0
-        culvert_width=0.75
-        culvert_height=0.75
-        
-        culvert_type='pipe'
-        manning=0.013
-        sum_loss=1.5
-
-        inlet_specific_energy=inlet_depth #+0.5*v**2/g 
-        z_in = 0.0
-        z_out = -culvert_length*culvert_slope/100
-        E_in = z_in+inlet_depth  #+ 0.5*v**2/g
-        E_out = z_out+outlet_depth  #+ 0.5*v**2/g
-        delta_total_energy = E_in-E_out
-
-        Q, v, d = boyd_generalised_culvert_model(inlet_depth, 
-                                                 outlet_depth,
-                                                 inlet_specific_energy, 
-                                                 delta_total_energy, 
-                                                 g,
-                                                 culvert_length,
-                                                 culvert_width,
-                                                 culvert_height,
-                                                 culvert_type,
-                                                 manning,
-                                                 sum_loss)
-        
-        print Q, v, d
-        assert num.allclose(Q, 1.00, rtol=1.0e-2) #inflow
-        assert num.allclose(v, 2.204, rtol=1.0e-2) #outflow velocity
-        assert num.allclose(d, 0.76, rtol=1.0e-2) #depth at outlet used to calc v
-    
-               
-#-------------------------------------------------------------
-if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_culvert_routines, 'test')
-    runner = unittest.TextTestRunner()
-    runner.run(suite)
-
Index: /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_10pct.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_10pct.py	(revision 7073)
+++ /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_10pct.py	(revision 7073)
@@ -0,0 +1,342 @@
+#!/usr/bin/env python
+
+
+import unittest
+import os.path
+import sys
+
+from anuga.utilities.system_tools import get_pathname_from_package
+from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
+import Numeric as num
+
+
+class Test_culvert_routines_box_10pct(unittest.TestCase):
+    """
+	This unit test sets up 6 tests for various culvert conditions for a Box Culvert on a 10% Slope
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_boyd_1(self):
+        """test_boyd_1
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+
+
+        inlet_depth=0.150
+        outlet_depth=0.15
+        inlet_velocity=1.00
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=3.6
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        culvert_slope=10.0  # % Downward
+        z_in = 10.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d))
+        print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.5526, 1.146, 0.1339))
+        assert num.allclose(Q, 0.5526, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 1.146, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.1339, rtol=1.0e-1) #depth at outlet used to calc v 
+        
+    def test_boyd_2(self):
+        """test_boyd_2
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=0.500
+        outlet_depth=0.700
+        inlet_velocity=1.0
+        outlet_velocity=0.50
+        
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 2.508, 1.897, 0.367))
+        assert num.allclose(Q, 2.508, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 1.897, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.367, rtol=1.0e-1) #depth at outlet used to calc v  
+
+    def test_boyd_3(self):
+        """test_boyd_3
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.800
+        outlet_depth=0.80
+        inlet_velocity=1.0
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 13.554, 3.329, 1.131))
+        assert num.allclose(Q, 13.554, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.329, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.131, rtol=1.0e-2) #depth at outlet used to calc v
+
+#NOTE FROM HERE DOWN THE UNITS TEST HAVE NOT BEEN AMENDED TO ALLOW VELOCITY COMPONENT TO BE USED. ONLY ABOVE 3 TESTS WORK. PM WILL FIX THE ONES BELOW WHEN THE ABOVE 3 ARE WORKING
+    def test_boyd_4(self):
+        """test_boyd_4
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.00
+        outlet_depth=0.8
+        inlet_velocity=1.0
+        outlet_velocity=0.5 
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+       
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 6.609, 2.621, 0.70))
+        assert num.allclose(Q, 6.609, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 2.621, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 0.70, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_5(self):
+        """test_boyd_5
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 1.0
+        outlet_depth=2.5
+        outlet_velocity=0.5
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',2.961, 0.685, 1.20))
+        assert num.allclose(Q, 2.961, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 0.685, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_6(self):
+        """test_boyd_6
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 4.0
+        outlet_depth=0.80
+        outlet_velocity=4.0
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',15.537, 3.597, 1.20))
+        assert num.allclose(Q, 15.537, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.597, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+# =========================================================================
+# =========================================================================
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_culvert_routines_box_10pct, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
Index: /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_1pct.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_1pct.py	(revision 7073)
+++ /anuga_core/source/anuga/culvert_flows/test_culvert_routines_box_1pct.py	(revision 7073)
@@ -0,0 +1,342 @@
+#!/usr/bin/env python
+
+
+import unittest
+import os.path
+import sys
+
+from anuga.utilities.system_tools import get_pathname_from_package
+from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
+import Numeric as num
+
+
+class Test_culvert_routines_box_1pct(unittest.TestCase):
+    """
+	This unit test sets up 6 tests for various culvert conditions for a Box Culvert on a 1% Slope
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_boyd_1(self):
+        """test_boyd_1
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+
+
+        inlet_depth=0.150
+        outlet_depth=0.15
+        inlet_velocity=1.00
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=3.6
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        culvert_slope=1  # % Downward
+        z_in = 10.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d))
+        print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.5526, 1.146, 0.1339))
+        assert num.allclose(Q, 0.5526, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 1.146, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.1339, rtol=1.0e-1) #depth at outlet used to calc v 
+        
+    def test_boyd_2(self):
+        """test_boyd_2
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=0.500
+        outlet_depth=0.700
+        inlet_velocity=1.50
+        outlet_velocity=0.50
+        
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.224, 0.152, 0.409))
+        assert num.allclose(Q, 0.224, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 0.152, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.409, rtol=1.0e-1) #depth at outlet used to calc v  
+
+    def test_boyd_3(self):
+        """test_boyd_3
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.800
+        outlet_depth=0.80
+        inlet_velocity=1.0
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 13.554, 3.329, 1.131))
+        assert num.allclose(Q, 13.554, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.329, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.131, rtol=1.0e-2) #depth at outlet used to calc v
+
+#NOTE FROM HERE DOWN THE UNITS TEST HAVE NOT BEEN AMENDED TO ALLOW VELOCITY COMPONENT TO BE USED. ONLY ABOVE 3 TESTS WORK. PM WILL FIX THE ONES BELOW WHEN THE ABOVE 3 ARE WORKING
+    def test_boyd_4(self):
+        """test_boyd_4
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.00
+        outlet_depth=0.8
+        inlet_velocity=1.0
+        outlet_velocity=0.5 
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+       
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 5.164, 2.047, 0.70))
+        assert num.allclose(Q, 5.164, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 2.047, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 0.70, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_5(self):
+        """test_boyd_5
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 1.0
+        outlet_depth=1.3
+        outlet_velocity=0.5
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',8.808, 2.039, 1.20))
+        assert num.allclose(Q, 8.808, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 2.039, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+
+
+    def test_boyd_6(self):
+        """test_boyd_6
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 4.0
+        outlet_depth=0.8
+        outlet_velocity=4.0
+        culvert_length=10.0
+        culvert_width=3.60
+        culvert_height=1.20
+        
+        culvert_type='box'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',13.546, 3.136, 1.20))
+        assert num.allclose(Q, 13.546, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.136, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+
+# =========================================================================
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_culvert_routines_box_1pct, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
Index: /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_10pct.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_10pct.py	(revision 7073)
+++ /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_10pct.py	(revision 7073)
@@ -0,0 +1,338 @@
+#!/usr/bin/env python
+
+
+import unittest
+import os.path
+import sys
+
+from anuga.utilities.system_tools import get_pathname_from_package
+from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
+import Numeric as num
+
+
+class Test_culvert_routines_pipe_10pct(unittest.TestCase):
+    """
+	This unit test sets up 6 tests for various culvert conditions for a Circular Pipe Culvert on a 10% Slope
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_boyd_1(self):
+        """test_boyd_1
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+
+
+        inlet_depth=0.150
+        outlet_depth=0.15
+        inlet_velocity=1.00
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        culvert_slope=10.0  # % Downward
+        z_in = 10.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d))
+        print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.113, 0.297, 0.443))
+        assert num.allclose(Q, 0.113, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 0.297, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.443, rtol=1.0e-1) #depth at outlet used to calc v 
+        
+    def test_boyd_2(self):
+        """test_boyd_2
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=0.500
+        outlet_depth=0.700
+        inlet_velocity=1.0
+        outlet_velocity=0.50
+        
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.585, 0.873, 0.687))
+        assert num.allclose(Q, 0.585, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 0.873, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.687, rtol=1.0e-1) #depth at outlet used to calc v  
+
+    def test_boyd_3(self):
+        """test_boyd_3
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.800
+        outlet_depth=0.80
+        inlet_velocity=1.0
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 3.441, 3.042, 1.2))
+        assert num.allclose(Q, 3.441, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.042, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.2, rtol=1.0e-2) #depth at outlet used to calc v
+
+#NOTE FROM HERE DOWN THE UNITS TEST HAVE NOT BEEN AMENDED TO ALLOW VELOCITY COMPONENT TO BE USED. ONLY ABOVE 3 TESTS WORK. PM WILL FIX THE ONES BELOW WHEN THE ABOVE 3 ARE WORKING
+    def test_boyd_4(self):
+        """test_boyd_4
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.00
+        outlet_depth=0.8
+        inlet_velocity=1.0
+        outlet_velocity=0.5 
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+       
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 1.676, 1.821, 0.91))
+        assert num.allclose(Q, 1.676, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 1.821, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 0.91, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_5(self):
+        """test_boyd_5
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 1.0
+        outlet_depth=2.5
+        outlet_velocity=0.5
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',0.759, 0.671, 1.20))
+        assert num.allclose(Q, 0.759, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 0.671, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_6(self):
+        """test_boyd_6
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=10  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 4.0
+        outlet_depth=0.80
+        outlet_velocity=4.0
+        culvert_length=10.0
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',3.962, 3.503, 1.20))
+        assert num.allclose(Q, 3.962, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.503, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+# =========================================================================
+# =========================================================================
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_culvert_routines_pipe_10pct, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
Index: /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_1pct.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_1pct.py	(revision 7073)
+++ /anuga_core/source/anuga/culvert_flows/test_culvert_routines_pipe_1pct.py	(revision 7073)
@@ -0,0 +1,338 @@
+#!/usr/bin/env python
+
+
+import unittest
+import os.path
+import sys
+
+from anuga.utilities.system_tools import get_pathname_from_package
+from anuga.culvert_flows.culvert_routines import boyd_generalised_culvert_model
+import Numeric as num
+
+
+class Test_culvert_routines_pipe_1pct(unittest.TestCase):
+    """
+	This unit test sets up 6 tests for various culvert conditions for a Circular Pipe Culvert on a 1.0% Slope
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+
+    def test_boyd_1(self):
+        """test_boyd_1
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+
+
+        inlet_depth=0.150
+        outlet_depth=0.15
+        inlet_velocity=1.00
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        culvert_slope=1.0  # % Downward
+        z_in = 10.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d))
+        print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 0.113, 0.297, 0.443))
+        assert num.allclose(Q, 0.113, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 0.297, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.443, rtol=1.0e-1) #depth at outlet used to calc v 
+        
+    def test_boyd_2(self):
+        """test_boyd_2
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=0.500
+        outlet_depth=0.700
+        inlet_velocity=1.5
+        outlet_velocity=0.50
+        
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST02 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs', 0.108, 0.152, 0.721))
+        assert num.allclose(Q, 0.108, rtol=1.0e-1) #inflow
+        assert num.allclose(v, 0.152, rtol=1.0e-1) #outflow velocity
+        assert num.allclose(d, 0.721, rtol=1.0e-1) #depth at outlet used to calc v  
+
+    def test_boyd_3(self):
+        """test_boyd_3
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.800
+        outlet_depth=0.80
+        inlet_velocity=1.0
+        outlet_velocity=0.5
+        
+        culvert_length=10.0
+        
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 0.0
+        z_out = -culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST03 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 3.441, 3.042, 1.2))
+        assert num.allclose(Q, 3.441, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.042, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.2, rtol=1.0e-2) #depth at outlet used to calc v
+
+#NOTE FROM HERE DOWN THE UNITS TEST HAVE NOT BEEN AMENDED TO ALLOW VELOCITY COMPONENT TO BE USED. ONLY ABOVE 3 TESTS WORK. PM WILL FIX THE ONES BELOW WHEN THE ABOVE 3 ARE WORKING
+    def test_boyd_4(self):
+        """test_boyd_4
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.00
+        outlet_depth=0.9
+        inlet_velocity=1.0
+        outlet_velocity=0.5 
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+       
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.2f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.2f'%('Delta E = ',delta_total_energy))
+        print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST04 Q-v-d',Q,v,d))
+        print ('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', 1.559, 1.694, 0.91))
+        assert num.allclose(Q, 1.559, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 1.694, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 0.91, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_5(self):
+        """test_boyd_5
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 1.0
+        outlet_depth=1.3
+        outlet_velocity=0.5
+        culvert_length=10.0
+        culvert_width=0.0
+        culvert_height=1.20
+        
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
+        print ('%s,%.3f'%('Delta E = ',delta_total_energy))
+        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST05 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',2.258, 1.996, 1.20))
+        assert num.allclose(Q, 2.258, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 1.996, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+
+    def test_boyd_6(self):
+        """test_boyd_6
+        
+        This tests the Boyd routine with data obtained from ??? by Petar Milevski    
+        """
+        # FIXME(Ole): This test fails (20 Feb 2009)
+
+        g=9.81
+        culvert_slope=1  # Downward
+
+        inlet_depth=1.50
+        inlet_velocity= 4.0
+        outlet_depth=0.80
+        outlet_velocity=4.0
+        culvert_length=10.0
+        culvert_height=1.20
+        culvert_width=0.0
+        culvert_type='circle'
+        manning=0.013
+        sum_loss=1.5
+
+        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g 
+        z_in = 10.0
+        z_out = 10.0-culvert_length*culvert_slope/100
+        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
+        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
+        delta_total_energy = E_in-E_out
+
+
+
+        Q, v, d = boyd_generalised_culvert_model(inlet_depth,
+                                                 outlet_depth,
+                                                 inlet_velocity,
+                                                 outlet_velocity,
+                                                 inlet_specific_energy, 
+                                                 delta_total_energy, 
+                                                 g,
+                                                 culvert_length,
+                                                 culvert_width,
+                                                 culvert_height,
+                                                 culvert_type,
+                                                 manning,
+                                                 sum_loss)        
+        print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d))
+        print ('%s,%.3f,%.3f,%.3f' %('Spreadsheet_Boydcalcs',3.472, 3.070, 1.20))
+        assert num.allclose(Q, 3.472, rtol=1.0e-2) #inflow
+        assert num.allclose(v, 3.070, rtol=1.0e-2) #outflow velocity
+        assert num.allclose(d, 1.20, rtol=1.0e-2) #depth at outlet used to calc v
+# =========================================================================
+# =========================================================================
+
+if __name__ == "__main__":
+    suite = unittest.makeSuite(Test_culvert_routines_pipe_1pct, 'test')
+    runner = unittest.TextTestRunner()
+    runner.run(suite)
