Index: /anuga_core/source/anuga/culvert_flows/culvert_class.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/culvert_class.py	(revision 6101)
+++ /anuga_core/source/anuga/culvert_flows/culvert_class.py	(revision 6102)
@@ -753,4 +753,5 @@
                     
                 opening.total_energy = 0.5*(u*u + v*v)/g + stage
+                # FIXME(Ole): What happens if this is negative?
                 #print 'Et = %.3f m' %opening.total_energy
 
Index: /anuga_core/source/anuga/culvert_flows/example_rating_curve2.csv
===================================================================
--- /anuga_core/source/anuga/culvert_flows/example_rating_curve2.csv	(revision 6102)
+++ /anuga_core/source/anuga/culvert_flows/example_rating_curve2.csv	(revision 6102)
@@ -0,0 +1,20 @@
+Name, type, width or diameter, height, length, number of barrels, losses, description 	
+Test Culvert, box, 3, 1.8, 4, 1, 0.084, From Petar's spreadsheet
+
+
+Rating Curve: Delta W (m), Q (m3/s), Velocity (m/s)
+0,0,0
+0.1,0.720243203,0.800270226
+0.2,1.018577706,1.131753007
+0.3,1.247497822,1.386108691
+0.4,1.440486406,1.600540451
+0.5,1.610512763,1.789458625
+0.6,1.764228338,1.960253709
+0.7,1.905584399,2.117315999
+0.8,2.037155412,2.263506014
+0.9,2.160729609,2.400810677
+1,2.277608991,2.530676657
+2,3.221025525,3.57891725
+3,3.944934492,4.383260547
+5,5.09288853,5.658765034
+10,7.202432031,8.002702257
Index: /anuga_core/source/anuga/culvert_flows/test_culvert_class.py
===================================================================
--- /anuga_core/source/anuga/culvert_flows/test_culvert_class.py	(revision 6101)
+++ /anuga_core/source/anuga/culvert_flows/test_culvert_class.py	(revision 6102)
@@ -5,6 +5,9 @@
 import os.path
 
-from anuga.utilities.system_tools import get_pathname_from_package        
+from anuga.utilities.system_tools import get_pathname_from_package
+from anuga.utilities.polygon import Polygon_function
+        
 from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular_cross
+from anuga.abstract_2d_finite_volumes.quantity import Quantity
 
 from anuga.shallow_water import Domain, Reflective_boundary,\
@@ -333,7 +336,96 @@
 
     
+    
+
+    def test_predicted_flow(self):
+        """test_predicted_flow
+        
+        Test that flows predicted are consistent with what what
+        is calculated in engineering codes.
+        The data was supplied by Petar Milevski
+        """
+
+        path = get_pathname_from_package('anuga.culvert_flows')    
+        
+        length = 12.
+        width = 5.
+
+        dx = dy = 0.5           # Resolution: Length of subdivisions on both axes
+
+        points, vertices, boundary = rectangular_cross(int(length/dx),
+                                                       int(width/dy),
+                                                       len1=length, 
+                                                       len2=width)
+        domain = Domain(points, vertices, boundary)   
+        
+        domain.set_name('test_culvert')                 # Output name
+        domain.set_default_order(2)
+
+
+        #----------------------------------------------------------------------
+        # Setup initial conditions
+        #----------------------------------------------------------------------
+
+        def topography(x, y):
+            # General Slope of Topography
+            z=-x/10
+            
+            return z
+
+
+        domain.set_quantity('elevation', topography) 
+        domain.set_quantity('friction', 0.01)         # Constant friction 
+        domain.set_quantity('stage', expression='elevation')
+
+
+        Q0 = domain.get_quantity('stage')
+        Q1 = Quantity(domain)
+        
+        # Add depths to stage        
+        head_water_depth = 0.169
+        tail_water_depth = 0.089
+        
+        inlet_poly = [[0,0], [6,0], [6,5], [0,5]]
+        outlet_poly = [[6,0], [12,0], [12,5], [6,5]]        
+        
+        Q1.set_values(Polygon_function([(inlet_poly, head_water_depth),
+                                        (outlet_poly, tail_water_depth)]))
+        
+        domain.set_quantity('stage', Q0 + Q1)
+
+
+        if True:        
+            filename=os.path.join(path, 'example_rating_curve2.csv')
+            culvert = Culvert_flow_rating(domain,
+                                          culvert_description_filename=filename,        
+                                          end_point0=[4.0, 2.5], 
+                                          end_point1=[8.0, 2.5],
+                                          verbose=True)
+        else:
+            culvert = Culvert_flow_energy(domain,
+                                          label='Test culvert',
+                                          description='4 m test culvert',   
+                                          end_point0=[4.0, 2.5], 
+                                          end_point1=[8.0, 2.5],
+                                          width=1.20, 
+                                          height=0.75,
+                                          culvert_routine=boyd_generalised_culvert_model,        
+                                          number_of_barrels=1,
+                                          verbose=True)
+                               
+
+        domain.forcing_terms.append(culvert)
+        
+        # Call
+        culvert(domain)
+    
+        #print 'Inlet flow', culvert.inlet.rate
+        #print 'Outlet flow', culvert.outlet.rate        
+        
+    
                
 #-------------------------------------------------------------
 if __name__ == "__main__":
+    #suite = unittest.makeSuite(Test_Culvert, 'test_predicted_flow')
     suite = unittest.makeSuite(Test_Culvert, 'test')
     runner = unittest.TextTestRunner()
