Ignore:
Timestamp:
Jan 23, 2017, 4:44:46 PM (8 years ago)
Author:
steve
Message:

Update to svn

Location:
trunk/anuga_core/anuga/structures
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/anuga/structures/boyd_box_operator.py

    r9737 r9740  
    2828                 width,                                   
    2929                 height=None,                       
    30                  blockage=0.0,  # added by DPM 24/7/2016
     30                 blockage=0.0,
    3131                 z1=0.0,
    3232                 z2=0.0,                 
     
    5555                                          width=width,
    5656                                          height=height,
    57                                           blockage=blockage,  # added by DPM 24/7/2016
     57                                          blockage=blockage,
    5858                                          diameter=None,                                         
    5959                                          apron=apron,
     
    8383        self.culvert_width = self.get_culvert_width()
    8484        self.culvert_height = self.get_culvert_height()
    85         self.culvert_blockage = self.get_culvert_blockage()#added DPM 24/7/2016
     85        self.culvert_blockage = self.get_culvert_blockage()
    8686
    8787        #FIXME SR: Why is this hard coded!
     
    196196                print 'width ',self.culvert_width
    197197                print 'depth ',self.culvert_height
    198                 print 'culvert blockage ',self.culvert_blockage #added DPM 24/7/2016
     198                print 'culvert blockage ',self.culvert_blockage
    199199                print 'flow_width ',self.culvert_width
    200200                print 'length ' ,self.culvert_length
     
    275275
    276276    local_debug = False
    277            
    278     Q_inlet_unsubmerged = 0.544*anuga.g**0.5*(1-blockage)*width*driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged
    279     Q_inlet_submerged = 0.702*anuga.g**0.5*(1-blockage)**2*width*depth**0.89*driving_energy**0.61  # Flow based on Inlet Ctrl Inlet Submerged
    280 
     277   
     278    if blockage >= 1.0:
     279        Q = barrel_velocity = outlet_culvert_depth = 0.0
     280        flow_area = 0.00001
     281        case = '100 blocked culvert'
     282        return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
     283    else:                     
     284        Q_inlet_unsubmerged = 0.544*anuga.g**0.5*(1-blockage)*width*driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged
     285        Q_inlet_submerged = 0.702*anuga.g**0.5*(1-blockage)**2*width*depth**0.89*driving_energy**0.61  # Flow based on Inlet Ctrl Inlet Submerged
     286
     287    #print 'blockage ', blockage
    281288    # FIXME(Ole): Are these functions really for inlet control?
    282289    if Q_inlet_unsubmerged < Q_inlet_submerged:
  • trunk/anuga_core/anuga/structures/boyd_pipe_operator.py

    r9598 r9740  
    2626                 losses,
    2727                 diameter=None,
     28                 blockage=0.0,
    2829                 z1=0.0,
    2930                 z2=0.0,
     
    5253                                          height=None,
    5354                                          diameter=diameter,
     55                                          blockage=blockage,
    5456                                          apron=apron,
    5557                                          manning=manning,
     
    7779        self.culvert_length = self.get_culvert_length()
    7880        self.culvert_diameter = self.get_culvert_diameter()
     81        self.culvert_blockage = self.get_culvert_blockage()
    7982
    8083        #print self.culvert_diameter
     
    136139                              boyd_pipe_function(depth               =self.inflow.get_enquiry_depth(),
    137140                                                 diameter            =self.culvert_diameter,
     141                                                 blockage            =self.culvert_blockage,
    138142                                                 length              =self.culvert_length,
    139143                                                 driving_energy      =self.driving_energy,
     
    143147                                                 manning             =self.manning)
    144148        else:
    145              Q = barrel_velocity = outlet_culvert_depth = 0.0
    146              case = 'Inlet dry'
     149            Q = barrel_velocity = outlet_culvert_depth = 0.0
     150            case = 'Inlet dry'
    147151
    148152
     
    160164# define separately so that can be imported in parallel code.
    161165#=============================================================================
    162 def boyd_pipe_function(depth, diameter, length, driving_energy, delta_total_energy, outlet_enquiry_depth, sum_loss, manning):
     166def boyd_pipe_function(depth, diameter, blockage, length, driving_energy, delta_total_energy, outlet_enquiry_depth, sum_loss, manning):
    163167
    164168
     
    175179    """
    176180
     181
     182    # Note this errors if blockage is set to 1.0 (ie 100% blockaage) and i have no idea how to fix it   
     183    if blockage >= 1.0:
     184        Q = barrel_velocity = outlet_culvert_depth = 0.0
     185        flow_area = 0.00001
     186        case = '100 blocked culvert'
     187        return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
     188    if blockage > 0.9:
     189        bf = 3.333-3.333*blockage     
     190    else:
     191        bf = 1.0-0.4012316798*blockage-0.3768350138*(blockage**2)
     192    #print 'blockage ', blockage
     193    #print '      bf ', bf
     194
    177195    # Calculate flows for inlet control for circular pipe
    178     Q_inlet_unsubmerged = 0.421*anuga.g**0.5*diameter**0.87*driving_energy**1.63 # Inlet Ctrl Inlet Unsubmerged
    179     Q_inlet_submerged = 0.530*anuga.g**0.5*diameter**1.87*driving_energy**0.63   # Inlet Ctrl Inlet Submerged
     196    Q_inlet_unsubmerged = 0.421*anuga.g**0.5*((bf*diameter)**0.87)*driving_energy**1.63 # Inlet Ctrl Inlet Unsubmerged
     197    Q_inlet_submerged = 0.530*anuga.g**0.5*((bf*diameter)**1.87)*driving_energy**0.63   # Inlet Ctrl Inlet Submerged
    180198    # Note for to SUBMERGED TO OCCUR operator.inflow.get_average_specific_energy() should be > 1.2 x diameter.... Should Check !!!
    181199
     
    185203    # THE LOWEST Value will Control Calcs From here
    186204    # Calculate Critical Depth Based on the Adopted Flow as an Estimate
    187     dcrit1 = diameter/1.26*(Q/anuga.g**0.5*diameter**2.5)**(1/3.75)
    188     dcrit2 = diameter/0.95*(Q/anuga.g**0.5*diameter**2.5)**(1/1.95)
     205    dcrit1 = (bf*diameter)/1.26*(Q/anuga.g**0.5*((bf*diameter)**2.5))**(1/3.75)
     206    dcrit2 = (bf*diameter)/0.95*(Q/anuga.g**0.5*(bf*diameter)**2.5)**(1/1.95)
    189207    # From Boyd Paper ESTIMATE of Dcrit has 2 criteria as
    190     if dcrit1/diameter  > 0.85:
     208    if dcrit1/(bf*diameter)  > 0.85:
    191209        outlet_culvert_depth = dcrit2
    192210    else:
     
    194212    #outlet_culvert_depth = min(outlet_culvert_depth, diameter)
    195213    # Now determine Hydraulic Radius Parameters Area & Wetted Perimeter
    196     if outlet_culvert_depth >= diameter:
    197         outlet_culvert_depth = diameter  # Once again the pipe is flowing full not partfull
    198         flow_area = (diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
    199         perimeter = diameter * math.pi
    200         flow_width= diameter
     214    if outlet_culvert_depth >= (bf*diameter):
     215        outlet_culvert_depth = (bf*diameter)  # Once again the pipe is flowing full not partfull
     216        flow_area = (bf*diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
     217        perimeter = bf * diameter * math.pi
     218        flow_width= bf * diameter
    201219        case = 'Inlet CTRL Outlet submerged Circular PIPE FULL'
    202220        if local_debug:
     
    205223    else:
    206224        #alpha = anuga.acos(1 - outlet_culvert_depth/diameter)    # Where did this Come From ????/
    207         alpha = anuga.acos(1-2*outlet_culvert_depth/diameter)*2
     225        alpha = anuga.acos(1-2*outlet_culvert_depth/(bf*diameter))*2
    208226        #flow_area = diameter**2 * (alpha - sin(alpha)*cos(alpha))        # Pipe is Running Partly Full at the INLET   WHRE did this Come From ?????
    209         flow_area = diameter**2/8*(alpha - math.sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
    210         flow_width= diameter*math.sin(alpha/2.0)
    211         perimeter = alpha*diameter/2.0
     227        flow_area = (bf*diameter)**2/8*(alpha - math.sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
     228        flow_width= bf*diameter*math.sin(alpha/2.0)
     229        perimeter = alpha*bf*diameter/2.0
    212230        case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    213231        if local_debug:
     
    221239
    222240        # Determine the depth at the outlet relative to the depth of flow in the Culvert
    223         if outlet_enquiry_depth > diameter:       # Outlet is submerged Assume the end of the Pipe is flowing FULL
    224             outlet_culvert_depth=diameter
    225             flow_area = (diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
    226             perimeter = diameter * math.pi
    227             flow_width= diameter
     241        if outlet_enquiry_depth > bf*diameter:       # Outlet is submerged Assume the end of the Pipe is flowing FULL
     242            outlet_culvert_depth=bf*diameter
     243            flow_area = (bf*diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
     244            perimeter = bf*diameter * math.pi
     245            flow_width= bf*diameter
    228246            case = 'Outlet submerged'
    229247            if local_debug:
     
    231249        else:   # Culvert running PART FULL for PART OF ITS LENGTH   Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
    232250            # IF  operator.outflow.get_average_depth() < diameter
    233             dcrit1 = diameter/1.26*(Q/anuga.g**0.5*diameter**2.5)**(1/3.75)
    234             dcrit2 = diameter/0.95*(Q/anuga.g**0.5*diameter**2.5)**(1/1.95)
    235             if dcrit1/diameter >0.85:
     251            dcrit1 = (bf*diameter)/1.26*(Q/anuga.g**0.5*((bf*diameter)**2.5))**(1/3.75)
     252            dcrit2 = (bf*diameter)/0.95*(Q/anuga.g**0.5*((bf*diameter)**2.5))**(1/1.95)
     253            if dcrit1/(bf*diameter) >0.85:
    236254                outlet_culvert_depth= dcrit2
    237255            else:
    238256                outlet_culvert_depth = dcrit1
    239             if outlet_culvert_depth > diameter:
    240                 outlet_culvert_depth = diameter  # Once again the pipe is flowing full not partfull
    241                 flow_area = (diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
    242                 perimeter = diameter * math.pi
    243                 flow_width= diameter
     257            if outlet_culvert_depth > bf*diameter:
     258                outlet_culvert_depth = bf*diameter  # Once again the pipe is flowing full not partfull
     259                flow_area = (bf*diameter/2)**2 * math.pi  # Cross sectional area of flow in the culvert
     260                perimeter = bf*diameter * math.pi
     261                flow_width= bf*diameter
    244262                case = 'Outlet unsubmerged PIPE FULL'
    245263                if local_debug:
    246264                    anuga.log.critical('Outlet unsubmerged PIPE FULL')
    247265            else:
    248                 alpha = anuga.acos(1-2*outlet_culvert_depth/diameter)*2
    249                 flow_area = diameter**2/8*(alpha - math.sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
    250                 flow_width= diameter*math.sin(alpha/2.0)
    251                 perimeter = alpha*diameter/2.0
     266                alpha = anuga.acos(1-2*outlet_culvert_depth/(bf*diameter))*2
     267                flow_area = (bf*diameter)**2/8*(alpha - math.sin(alpha))   # Equation from  GIECK 5th Ed. Pg. B3
     268                flow_width= bf*diameter*math.sin(alpha/2.0)
     269                perimeter = alpha*bf*diameter/2.0
    252270                case = 'Outlet is open channel flow we will for now assume critical depth'
    253271                if local_debug:
     
    301319    return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
    302320
    303 
    304 
    305 
  • trunk/anuga_core/anuga/structures/tests/test_boyd_box_operator.py

    r9737 r9740  
    26562656        assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity
    26572657        assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v
    2658        
    2659        
     2658
     2659
     2660    def test_boyd_13(self):
     2661        """test_boyd_13
     2662       
     2663        This tests the Boyd routine with data obtained from ??? by Petar Milevski   
     2664        """
     2665        # FIXME(Ole): This test fails (20 Feb 2009)
     2666
     2667        g=9.81
     2668
     2669
     2670        inlet_depth=0.150
     2671        outlet_depth=0.15
     2672        inlet_velocity=1.00
     2673        outlet_velocity=0.5
     2674       
     2675        culvert_length=10.0
     2676        culvert_width=3.6
     2677        culvert_height=1.20
     2678        culvert_blockage = 0.50
     2679               
     2680        culvert_type='box'
     2681        manning=0.013
     2682        sum_loss=1.5
     2683
     2684        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2685        culvert_slope=1  # % Downward
     2686        z_in = 10.0
     2687        z_out = z_in-culvert_length*culvert_slope/100
     2688        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
     2689        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
     2690        delta_total_energy = E_in-E_out
     2691        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2692
     2693
     2694        Q_expected = 0.28
     2695        v_expected = 1.15
     2696        d_expected = 0.13
     2697
     2698        if verbose:
     2699            print 50*'='
     2700            print 'width ',culvert_width
     2701            print 'depth ',culvert_height
     2702            print 'blockage',culvert_blockage
     2703            print 'flow_width ',culvert_width
     2704            print 'length ' ,culvert_length
     2705            print 'driving_energy ',inlet_specific_energy
     2706            print 'delta_total_energy ',delta_total_energy
     2707            print 'outlet_enquiry_depth ',outlet_depth
     2708            print 'sum_loss ',sum_loss
     2709            print 'manning ',manning
     2710           
     2711        Q, v, d, flow_area, case= boyd_box_function(culvert_width,
     2712                                                    culvert_height,
     2713                                                    culvert_blockage,
     2714                                                    culvert_width,
     2715                                                    culvert_length,
     2716                                                    inlet_specific_energy,
     2717                                                    delta_total_energy,
     2718                                                    outlet_depth,
     2719                                                    sum_loss,
     2720                                                    manning)
     2721       
     2722#         Q, v, d = boyd_generalised_culvert_model(inlet_depth,
     2723#                                                  outlet_depth,
     2724#                                                  inlet_velocity,
     2725#                                                  outlet_velocity,
     2726#                                                  inlet_specific_energy,
     2727#                                                  delta_total_energy,
     2728#                                                  g,
     2729#                                                  culvert_length,
     2730#                                                  culvert_width,
     2731#                                                  culvert_height,
     2732#                                                  culvert_type,
     2733#                                                  manning,
     2734#                                                  sum_loss)
     2735        if verbose:
     2736            print ('%s,%.2f,%.2f,%.2f' %('ANUGAcalcsTEST01 Q-v-d',Q,v,d))
     2737            print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected))
     2738
     2739        assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow
     2740        assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity
     2741        assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v
     2742
     2743    def test_boyd_13_operator(self):
     2744        """test_boyd_non_skew
     2745       
     2746        This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer  BD Parkinson,
     2747        calculation code by MJ Boyd
     2748        """
     2749
     2750        g=9.81
     2751
     2752
     2753        inlet_depth=0.150
     2754        outlet_depth=0.15
     2755        inlet_velocity=1.00
     2756        outlet_velocity=0.5
     2757       
     2758        culvert_length=10.0
     2759        culvert_width=3.6
     2760        culvert_height=1.20
     2761       
     2762        culvert_type='box'
     2763        manning=0.013
     2764        sum_loss=1.5
     2765
     2766        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2767        culvert_slope=1  # % Downward
     2768        z_in = 10.0
     2769        z_out = z_in-culvert_length*culvert_slope/100
     2770        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
     2771        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
     2772        delta_total_energy = E_in-E_out
     2773        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2774
     2775
     2776        Q_expected = 0.5526
     2777        v_expected = 1.146
     2778        d_expected = 0.1339
     2779       
     2780     
     2781       
     2782        elevation_0 = z_in
     2783        elevation_1 = z_out
     2784       
     2785        stage_0 = elevation_0 + inlet_depth
     2786        stage_1 = elevation_1 + outlet_depth
     2787 
     2788
     2789        domain_length = 200.0
     2790        domain_width = 200.0
     2791
     2792        #culvert_length = 20.0
     2793        #culvert_width = 3.66
     2794        #culvert_height = 3.66
     2795        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
     2796        culvert_mannings = 0.013
     2797       
     2798        culvert_apron = 0.0
     2799        enquiry_gap = 5.0
     2800
     2801
     2802
     2803
     2804        domain = self._create_domain(d_length=domain_length,
     2805                                     d_width=domain_width,
     2806                                     dx = 5.0,
     2807                                     dy = 5.0,
     2808                                     elevation_0 = elevation_0,
     2809                                     elevation_1 = elevation_1,
     2810                                     stage_0 = stage_0,
     2811                                     stage_1 = stage_1,
     2812                                     xvelocity_0 = inlet_velocity,
     2813                                     xvelocity_1 = outlet_velocity)
     2814 
     2815
     2816        #print 'Defining Structures'
     2817       
     2818        ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0])
     2819        ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0])
     2820       
     2821       
     2822        culvert = Boyd_box_operator(domain,
     2823                                    losses=culvert_losses,
     2824                                    width=culvert_width,
     2825                                    end_points=[ep0, ep1],
     2826                                    height=culvert_height,
     2827                                    apron=culvert_apron,
     2828                                    enquiry_gap=enquiry_gap,
     2829                                    use_momentum_jet=False,
     2830                                    use_velocity_head=True,
     2831                                    manning=culvert_mannings,
     2832                                    logging=False,
     2833                                    label='3.6x1.2RCBC',
     2834                                    verbose=False)
     2835
     2836        #culvert.determine_inflow_outflow()
     2837       
     2838        ( Q, v, d ) = culvert.discharge_routine()
     2839       
     2840        if verbose:
     2841            print 'test_boyd_operator_1'
     2842            print 'expected ',Q_expected,v_expected, d_expected
     2843            print 'calc ',Q,v,d
     2844       
     2845
     2846        assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow
     2847        assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity
     2848        assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v
     2849
     2850
     2851    def test_boyd_14(self):
     2852        """test_boyd_14
     2853       
     2854        This tests the Boyd routine with data obtained from ??? by Petar Milevski   
     2855        """
     2856        # FIXME(Ole): This test fails (20 Feb 2009)
     2857
     2858        g=9.81
     2859        culvert_slope=1  # Downward
     2860
     2861        inlet_depth=1.50
     2862        inlet_velocity= 4.0
     2863        outlet_depth=0.8
     2864        outlet_velocity=4.0
     2865       
     2866        culvert_length=10.0
     2867        culvert_width=3.60
     2868        culvert_height=1.20
     2869        culvert_blockage = 0.50
     2870       
     2871        culvert_type='box'
     2872        manning=0.013
     2873        sum_loss=1.5
     2874
     2875        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2876        z_in = 10.0
     2877        z_out = 10.0-culvert_length*culvert_slope/100
     2878        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
     2879        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
     2880        delta_total_energy = E_in-E_out
     2881
     2882
     2883        Q_expected = 3.88
     2884        v_expected = 2.77
     2885        d_expected = 0.78
     2886       
     2887        if verbose:
     2888            print 50*'='
     2889            print 'width ',culvert_width
     2890            print 'depth ',culvert_height
     2891            print 'blockage',culvert_blockage
     2892            print 'flow_width ',culvert_width
     2893            print 'length ' ,culvert_length
     2894            print 'driving_energy ',inlet_specific_energy
     2895            print 'delta_total_energy ',delta_total_energy
     2896            print 'outlet_enquiry_depth ',outlet_depth
     2897            print 'sum_loss ',sum_loss
     2898            print 'manning ',manning
     2899           
     2900        Q, v, d, flow_area, case= boyd_box_function(culvert_width,
     2901                                                    culvert_height,
     2902                                                    culvert_blockage,
     2903                                                    culvert_width,
     2904                                                    culvert_length,
     2905                                                    inlet_specific_energy,
     2906                                                    delta_total_energy,
     2907                                                    outlet_depth,
     2908                                                    sum_loss,
     2909                                                    manning)
     2910
     2911#         Q, v, d = boyd_generalised_culvert_model(inlet_depth,
     2912#                                                  outlet_depth,
     2913#                                                  inlet_velocity,
     2914#                                                  outlet_velocity,
     2915#                                                  inlet_specific_energy,
     2916#                                                  delta_total_energy,
     2917#                                                  g,
     2918#                                                  culvert_length,
     2919#                                                  culvert_width,
     2920#                                                  culvert_height,
     2921#                                                  culvert_type,
     2922#                                                  manning,
     2923#                                                  sum_loss)       
     2924        if verbose:
     2925            print ('%s,%.3f'%('SPEC_E = ',inlet_specific_energy))
     2926            print ('%s,%.3f'%('Delta E = ',delta_total_energy))
     2927       
     2928            print ('%s,%.3f,%.3f,%.3f' %('ANUGAcalcsTEST06 Q-v-d',Q,v,d))
     2929            print('%s,%.2f,%.2f,%.2f' %('Spreadsheet_Boydcalcs', Q_expected, v_expected, d_expected))
     2930
     2931        assert numpy.allclose(Q, Q_expected, rtol=1.0e-1) #inflow
     2932        assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity
     2933        assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v
     2934
     2935    def test_boyd_14_operator(self):
     2936        """test_boyd_non_skew
     2937       
     2938        This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer  BD Parkinson,
     2939        calculation code by MJ Boyd
     2940        """
     2941
     2942        g=9.81
     2943        culvert_slope=1  # Downward
     2944
     2945        inlet_depth=1.50
     2946        inlet_velocity= 4.0
     2947        outlet_depth=0.8
     2948        outlet_velocity=4.0
     2949        culvert_length=10.0
     2950        culvert_width=3.60
     2951        culvert_height=1.20
     2952       
     2953        culvert_type='box'
     2954        manning=0.013
     2955        sum_loss=1.5
     2956
     2957        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     2958        z_in = 10.0
     2959        z_out = 10.0-culvert_length*culvert_slope/100
     2960        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
     2961        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
     2962        delta_total_energy = E_in-E_out
     2963
     2964
     2965        Q_expected = 13.546
     2966        v_expected = 3.136
     2967        d_expected = 1.20
     2968       
     2969        elevation_0 = z_in
     2970        elevation_1 = z_out
     2971       
     2972        stage_0 = elevation_0 + inlet_depth
     2973        stage_1 = elevation_1 + outlet_depth
     2974 
     2975
     2976        domain_length = 200.0
     2977        domain_width = 200.0
     2978
     2979        #culvert_length = 20.0
     2980        #culvert_width = 3.66
     2981        #culvert_height = 3.66
     2982        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
     2983        culvert_mannings = 0.013
     2984       
     2985        culvert_apron = 0.0
     2986        enquiry_gap = 5.0
     2987
     2988
     2989
     2990
     2991        domain = self._create_domain(d_length=domain_length,
     2992                                     d_width=domain_width,
     2993                                     dx = 5.0,
     2994                                     dy = 5.0,
     2995                                     elevation_0 = elevation_0,
     2996                                     elevation_1 = elevation_1,
     2997                                     stage_0 = stage_0,
     2998                                     stage_1 = stage_1,
     2999                                     xvelocity_0 = inlet_velocity,
     3000                                     xvelocity_1 = outlet_velocity)
     3001 
     3002
     3003        #print 'Defining Structures'
     3004       
     3005        ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0])
     3006        ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0])
     3007       
     3008       
     3009        culvert = Boyd_box_operator(domain,
     3010                                    losses=culvert_losses,
     3011                                    width=culvert_width,
     3012                                    end_points=[ep0, ep1],
     3013                                    height=culvert_height,
     3014                                    apron=culvert_apron,
     3015                                    enquiry_gap=enquiry_gap,
     3016                                    use_momentum_jet=False,
     3017                                    use_velocity_head=True,
     3018                                    manning=culvert_mannings,
     3019                                    logging=False,
     3020                                    label='3.6x1.2RCBC',
     3021                                    verbose=False)
     3022
     3023        #culvert.determine_inflow_outflow()
     3024       
     3025        ( Q, v, d ) = culvert.discharge_routine()
     3026       
     3027        if verbose:
     3028            print 'test_boyd_operator_1'
     3029            print 'expected ',Q_expected,v_expected, d_expected
     3030            print 'calc ',Q,v,d
     3031       
     3032
     3033        assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow
     3034        assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity
     3035        assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v
     3036       
     3037
     3038    def test_boyd_14_operator_invert(self):
     3039        """test_boyd_non_skew
     3040       
     3041        This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer  BD Parkinson,
     3042        calculation code by MJ Boyd
     3043        """
     3044
     3045        #verbose = True
     3046        g=9.81
     3047        culvert_slope=1  # Downward
     3048
     3049        inlet_depth=1.50
     3050        inlet_velocity= 4.0
     3051        outlet_depth=0.8
     3052        outlet_velocity=4.0
     3053        culvert_length=10.0
     3054        culvert_width=3.60
     3055        culvert_height=1.20
     3056       
     3057        culvert_type='box'
     3058        manning=0.013
     3059        sum_loss=1.5
     3060
     3061        inlet_specific_energy=inlet_depth + 0.5*inlet_velocity**2/g
     3062        z_in = 10.0
     3063        z_out = 10.0-culvert_length*culvert_slope/100
     3064        E_in = z_in+inlet_depth + 0.5*inlet_velocity**2/g
     3065        E_out = z_out+outlet_depth + 0.5*outlet_velocity**2/g
     3066        delta_total_energy = E_in-E_out
     3067
     3068        invert0 = 20.0
     3069        invert1 = 30.0
     3070
     3071
     3072        #Q_expected = 13.546
     3073        #v_expected = 3.136
     3074        #d_expected = 1.20
     3075       
     3076        Q_expected = 0.0
     3077        v_expected = 0.0
     3078        d_expected = 0.0
     3079       
     3080        elevation_0 = z_in
     3081        elevation_1 = z_out
     3082       
     3083        stage_0 = elevation_0 + inlet_depth
     3084        stage_1 = elevation_1 + outlet_depth
     3085 
     3086
     3087        domain_length = 200.0
     3088        domain_width = 200.0
     3089
     3090        #culvert_length = 20.0
     3091        #culvert_width = 3.66
     3092        #culvert_height = 3.66
     3093        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
     3094        culvert_mannings = 0.013
     3095       
     3096        culvert_apron = 0.0
     3097        enquiry_gap = 5.0
     3098
     3099
     3100
     3101
     3102        domain = self._create_domain(d_length=domain_length,
     3103                                     d_width=domain_width,
     3104                                     dx = 5.0,
     3105                                     dy = 5.0,
     3106                                     elevation_0 = elevation_0,
     3107                                     elevation_1 = elevation_1,
     3108                                     stage_0 = stage_0,
     3109                                     stage_1 = stage_1,
     3110                                     xvelocity_0 = inlet_velocity,
     3111                                     xvelocity_1 = outlet_velocity)
     3112 
     3113
     3114        #print 'Defining Structures'
     3115       
     3116        ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0])
     3117        ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0])
     3118       
     3119       
     3120        culvert = Boyd_box_operator(domain,
     3121                                    losses=culvert_losses,
     3122                                    width=culvert_width,
     3123                                    end_points=[ep0, ep1],
     3124                                    height=culvert_height,
     3125                                    apron=culvert_apron,
     3126                                    #invert_elevations=[elevation_0,elevation_1],
     3127                                    invert_elevations=[invert0,invert1],
     3128                                    enquiry_gap=enquiry_gap,
     3129                                    use_momentum_jet=False,
     3130                                    use_velocity_head=True,
     3131                                    manning=culvert_mannings,
     3132                                    logging=False,
     3133                                    label='3.6x1.2RCBC',
     3134                                    verbose=verbose)
     3135
     3136        #culvert.determine_inflow_outflow()
     3137       
     3138        ( Q, v, d ) = culvert.discharge_routine()
     3139       
     3140        if verbose:
     3141            print 'test_boyd_operator_12_invert'
     3142            print 'expected ',Q_expected,v_expected, d_expected
     3143            print 'calc ',Q,v,d
     3144       
     3145
     3146        assert numpy.allclose(Q, Q_expected, rtol=2.0e-2) #inflow
     3147        assert numpy.allclose(v, v_expected, rtol=2.0e-2) #outflow velocity
     3148        assert numpy.allclose(d, d_expected, rtol=2.0e-2) #depth at outlet used to calc v           
    26603149# =========================================================================
    26613150if __name__ == "__main__":
  • trunk/anuga_core/anuga/structures/tests/test_boyd_pipe_operator.py

    r9440 r9740  
    122122        culvert_width = 1.2
    123123        ##culvert_height = 3.66
     124        culvert_blockage = 0.0
     125       
    124126        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
    125127        culvert_mannings = 0.013
     
    153155                                    losses=culvert_losses,
    154156                                    diameter=culvert_width,
     157                                    blockage=culvert_blockage,
    155158                                    end_points=[ep0, ep1],
    156159                                    #height=culvert_height,
     
    196199        culvert_width = 1.2
    197200        ##culvert_height = 3.66
     201        culvert_blockage = 0.0
     202               
    198203        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
    199204        culvert_mannings = 0.013
     
    227232                                    losses=culvert_losses,
    228233                                    diameter=culvert_width,
     234                                    blockage=culvert_blockage,
    229235                                    end_points=[ep0, ep1],
    230236                                    #height=culvert_height,
     
    270276        culvert_width = 1.2
    271277        ##culvert_height = 3.66
     278        culvert_blockage=0.0
     279       
    272280        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
    273281        culvert_mannings = 0.013
     
    301309                                    losses=culvert_losses,
    302310                                    diameter=culvert_width,
     311                                    blockage=culvert_blockage,
    303312                                    end_points=[ep0, ep1],
    304313                                    #height=culvert_height,
     
    345354        culvert_width = 1.2
    346355        ##culvert_height = 3.66
     356        culvert_blockage = 0.0
     357       
    347358        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
    348359        culvert_mannings = 0.013
     
    376387                                    losses=culvert_losses,
    377388                                    diameter=culvert_width,
     389                                    blockage=culvert_blockage,
    378390                                    end_points=[ep0, ep1],
    379391                                    #height=culvert_height,
     
    420432        culvert_width = 1.2
    421433        ##culvert_height = 3.66
     434        culvert_blockage = 0.0
     435       
    422436        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
    423437        culvert_mannings = 0.013
     
    451465                                    losses=culvert_losses,
    452466                                    diameter=culvert_width,
     467                                    blockage=culvert_blockage,
    453468                                    end_points=[ep0, ep1],
    454469                                    #height=culvert_height,
     
    475490        assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow
    476491        assert numpy.allclose(v, expected_v, rtol=1.0e-2) #outflow velocity
     492        assert numpy.allclose(d, expected_d, rtol=1.0e-2) #depth at outlet used to calc v       
     493       
     494    def test_boyd_non_skew6(self):
     495        """test_boyd_non_skew
     496       
     497        This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer  BD Parkinson,
     498        calculation code by MJ Boyd
     499        This tests the blockage code
     500        """
     501
     502        stage_0 = 15.0 #change
     503        stage_1 = 14.0 #change
     504        elevation_0 = 11.0
     505        elevation_1 = 10.0
     506
     507        domain_length = 200.0
     508        domain_width = 200.0
     509
     510        culvert_length = 20.0
     511        culvert_width = 1.2
     512        ##culvert_height = 3.66
     513        culvert_blockage = 0.50
     514       
     515        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
     516        culvert_mannings = 0.013
     517       
     518        culvert_apron = 0.0
     519        enquiry_gap = 5.0
     520
     521       
     522        expected_Q = 1.75
     523        expected_v = 3.11
     524        expected_d = 0.85
     525       
     526
     527        domain = self._create_domain(d_length=domain_length,
     528                                     d_width=domain_width,
     529                                     dx = 5.0,
     530                                     dy = 5.0,
     531                                     elevation_0 = elevation_0,
     532                                     elevation_1 = elevation_1,
     533                                     stage_0 = stage_0,
     534                                     stage_1 = stage_1)
     535 
     536
     537        #print 'Defining Structures'
     538       
     539        ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0])
     540        ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0])
     541       
     542       
     543        culvert = Boyd_pipe_operator(domain,
     544                                    losses=culvert_losses,
     545                                    diameter=culvert_width,
     546                                    blockage=culvert_blockage,
     547                                    end_points=[ep0, ep1],
     548                                    #height=culvert_height,
     549                                    apron=culvert_apron,
     550                                    enquiry_gap=enquiry_gap,
     551                                    use_momentum_jet=False,
     552                                    use_velocity_head=False,
     553                                    manning=culvert_mannings,
     554                                    logging=False,
     555                                    label='1.2pipe',
     556                                    verbose=False)
     557
     558        #culvert.determine_inflow_outflow()
     559       
     560        ( Q, v, d ) = culvert.discharge_routine()
     561       
     562        if verbose:
     563            print 'test_boyd_non_skew6'
     564            print 'Q: ', Q, 'expected_Q: ', expected_Q
     565            print 'v: ', v, 'expected_v: ', expected_v
     566            print 'd: ', d, 'expected_d: ', expected_d
     567
     568
     569        assert numpy.allclose(Q, expected_Q, rtol=1.0e-2) #inflow
     570        assert numpy.allclose(v, expected_v, rtol=1.0e-2) #outflow velocity
    477571        assert numpy.allclose(d, expected_d, rtol=1.0e-2) #depth at outlet used to calc v 
     572
     573    def test_boyd_non_skew7(self):
     574        """test_boyd_non_skew
     575       
     576        This tests the Boyd routine with data obtained from culvertw application 1.1 by IceMindserer  BD Parkinson,
     577        calculation code by MJ Boyd
     578        This tests the blockage code
     579        """
     580
     581        stage_0 = 15.0 #change
     582        stage_1 = 14.0 #change
     583        elevation_0 = 11.0
     584        elevation_1 = 10.0
     585
     586        domain_length = 200.0
     587        domain_width = 200.0
     588
     589        culvert_length = 20.0
     590        culvert_width = 1.2
     591        ##culvert_height = 3.66
     592        culvert_blockage = 1.0
     593       
     594        culvert_losses = {'inlet':0.5, 'outlet':1.0, 'bend':0.0, 'grate':0.0, 'pier': 0.0, 'other': 0.0}
     595        culvert_mannings = 0.013
     596       
     597        culvert_apron = 0.0
     598        enquiry_gap = 5.0
     599
     600       
     601        expected_Q = 0.0
     602        expected_v = 0.0
     603        expected_d = 0.0
     604       
     605
     606        domain = self._create_domain(d_length=domain_length,
     607                                     d_width=domain_width,
     608                                     dx = 5.0,
     609                                     dy = 5.0,
     610                                     elevation_0 = elevation_0,
     611                                     elevation_1 = elevation_1,
     612                                     stage_0 = stage_0,
     613                                     stage_1 = stage_1)
     614 
     615
     616        #print 'Defining Structures'
     617       
     618        ep0 = numpy.array([domain_length/2-culvert_length/2, 100.0])
     619        ep1 = numpy.array([domain_length/2+culvert_length/2, 100.0])
     620       
     621       
     622        culvert = Boyd_pipe_operator(domain,
     623                                    losses=culvert_losses,
     624                                    diameter=culvert_width,
     625                                    blockage=culvert_blockage,
     626                                    end_points=[ep0, ep1],
     627                                    #height=culvert_height,
     628                                    apron=culvert_apron,
     629                                    enquiry_gap=enquiry_gap,
     630                                    use_momentum_jet=False,
     631                                    use_velocity_head=False,
     632                                    manning=culvert_mannings,
     633                                    logging=False,
     634                                    label='1.2pipe',
     635                                    verbose=False)
     636
     637        #culvert.determine_inflow_outflow()
     638       
     639        ( Q, v, d ) = culvert.discharge_routine()
     640       
     641        if verbose:
     642            print 'test_boyd_non_skew7'
     643            print 'Q: ', Q, 'expected_Q: ', expected_Q
     644            print 'v: ', v, 'expected_v: ', expected_v
     645            print 'd: ', d, 'expected_d: ', expected_d
     646
     647
     648        assert numpy.allclose(Q, expected_Q, rtol=1.0e-2, atol=1.0e-5) #inflow
     649        assert numpy.allclose(v, expected_v, rtol=1.0e-2, atol=1.0e-5) #outflow velocity
     650        assert numpy.allclose(d, expected_d, rtol=1.0e-2, atol=1.0e-5) #depth at outlet used to calc v 
     651
    478652# =========================================================================
    479653if __name__ == "__main__":
  • trunk/anuga_core/anuga/structures/tests/test_weir_orifice_trapezoid_operator.py

    r9440 r9740  
    1616
    1717
    18 verbose = False
     18verbose = True
    1919
    2020
     
    206206        culvert_z1=2
    207207        culvert_z2=2
     208        culvert_blockage = 0.0
    208209       
    209210        culvert_type='trapezoid'
     
    228229            print 'width ',culvert_width
    229230            print 'depth ',culvert_height
     231            print 'blockage ',culvert_blockage
    230232            print 'flow_width ',culvert_width
    231233            print 'length ' ,culvert_length
     
    236238            print 'manning ',manning
    237239       
    238         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    239                                                     culvert_height,
    240                                                     culvert_width,
    241                                                     culvert_slope,
    242                                                     culvert_z1,
    243                                                     culvert_z2,
    244                                                     culvert_length,
    245                                                     inlet_specific_energy,
    246                                                     delta_total_energy,
    247                                                     outlet_depth,
    248                                                     sum_loss,
    249                                                     manning)
    250        
    251 
    252 
     240        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     241                                                    width      = culvert_width,
     242                                                    depth      = culvert_height,
     243                                                    blockage   = culvert_blockage,
     244                                                    z1         = culvert_z1,
     245                                                    z2         = culvert_z2,
     246                                                    flow_width = culvert_width,
     247                                                    length     = culvert_length,
     248                                                    culvert_slope      = culvert_slope,
     249                                                    driving_energy     = inlet_specific_energy,
     250                                                    delta_total_energy = delta_total_energy,
     251                                                    outlet_enquiry_depth = outlet_depth,
     252                                                    sum_loss   = sum_loss,
     253                                                    manning    = manning)
     254       
    253255
    254256
     
    284286        culvert_z1=2
    285287        culvert_z2=2
     288        culvert_blockage = 0.0
    286289       
    287290        culvert_type='trapezoid'
     
    303306        if verbose:
    304307            print 50*'='
    305             print 'UNITTEST ',inspect.stack()[0][3] 
     308            print 'UNITTEST ',inspect.stack()[0][3]
    306309            print 'width ',culvert_width
    307310            print 'depth ',culvert_height
     311            print 'blockage ',culvert_blockage
    308312            print 'flow_width ',culvert_width
    309313            print 'length ' ,culvert_length
     
    314318            print 'manning ',manning
    315319       
    316         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    317                                                     culvert_height,
    318                                                     culvert_width,
    319                                                     culvert_slope,
    320                                                     culvert_z1,
    321                                                     culvert_z2,
    322                                                     culvert_length,
    323                                                     inlet_specific_energy,
    324                                                     delta_total_energy,
    325                                                     outlet_depth,
    326                                                     sum_loss,
    327                                                     manning)
     320        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     321                                                    width      = culvert_width,
     322                                                    depth      = culvert_height,
     323                                                    blockage   = culvert_blockage,
     324                                                    z1         = culvert_z1,
     325                                                    z2         = culvert_z2,
     326                                                    flow_width = culvert_width,
     327                                                    length     = culvert_length,
     328                                                    culvert_slope      = culvert_slope,
     329                                                    driving_energy     = inlet_specific_energy,
     330                                                    delta_total_energy = delta_total_energy,
     331                                                    outlet_enquiry_depth = outlet_depth,
     332                                                    sum_loss   = sum_loss,
     333                                                    manning    = manning)
    328334
    329335
     
    360366        culvert_z1=2
    361367        culvert_z2=2
     368        culvert_blockage = 0.0
    362369       
    363370        culvert_type='trapezoid'
     
    382389            print 'width ',culvert_width
    383390            print 'depth ',culvert_height
     391            print 'blockage ',culvert_blockage
    384392            print 'flow_width ',culvert_width
    385393            print 'length ' ,culvert_length
     
    390398            print 'manning ',manning
    391399       
    392         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    393                                                     culvert_height,
    394                                                     culvert_width,
    395                                                     culvert_slope,
    396                                                     culvert_z1,
    397                                                     culvert_z2,
    398                                                     culvert_length,
    399                                                     inlet_specific_energy,
    400                                                     delta_total_energy,
    401                                                     outlet_depth,
    402                                                     sum_loss,
    403                                                     manning)
     400        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     401                                                    width      = culvert_width,
     402                                                    depth      = culvert_height,
     403                                                    blockage   = culvert_blockage,
     404                                                    z1         = culvert_z1,
     405                                                    z2         = culvert_z2,
     406                                                    flow_width = culvert_width,
     407                                                    length     = culvert_length,
     408                                                    culvert_slope      = culvert_slope,
     409                                                    driving_energy     = inlet_specific_energy,
     410                                                    delta_total_energy = delta_total_energy,
     411                                                    outlet_enquiry_depth = outlet_depth,
     412                                                    sum_loss   = sum_loss,
     413                                                    manning    = manning)
    404414
    405415
     
    436446        culvert_z1=2
    437447        culvert_z2=2
     448        culvert_blockage = 0.0
    438449       
    439450        culvert_type='trapezoid'
     
    458469            print 'width ',culvert_width
    459470            print 'depth ',culvert_height
     471            print 'blockage ',culvert_blockage
    460472            print 'flow_width ',culvert_width
    461473            print 'length ' ,culvert_length
     
    466478            print 'manning ',manning
    467479       
    468         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    469                                                     culvert_height,
    470                                                     culvert_width,
    471                                                     culvert_slope,
    472                                                     culvert_z1,
    473                                                     culvert_z2,
    474                                                     culvert_length,
    475                                                     inlet_specific_energy,
    476                                                     delta_total_energy,
    477                                                     outlet_depth,
    478                                                     sum_loss,
    479                                                     manning)
     480        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     481                                                    width      = culvert_width,
     482                                                    depth      = culvert_height,
     483                                                    blockage   = culvert_blockage,
     484                                                    z1         = culvert_z1,
     485                                                    z2         = culvert_z2,
     486                                                    flow_width = culvert_width,
     487                                                    length     = culvert_length,
     488                                                    culvert_slope      = culvert_slope,
     489                                                    driving_energy     = inlet_specific_energy,
     490                                                    delta_total_energy = delta_total_energy,
     491                                                    outlet_enquiry_depth = outlet_depth,
     492                                                    sum_loss   = sum_loss,
     493                                                    manning    = manning)
    480494
    481495
     
    513527        culvert_z1=2
    514528        culvert_z2=2
     529        culvert_blockage = 0.0
    515530       
    516531        culvert_type='trapezoid'
     
    535550            print 'width ',culvert_width
    536551            print 'depth ',culvert_height
     552            print 'blockage ',culvert_blockage
    537553            print 'flow_width ',culvert_width
    538554            print 'length ' ,culvert_length
     
    543559            print 'manning ',manning
    544560       
    545         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    546                                                     culvert_height,
    547                                                     culvert_width,
    548                                                     culvert_slope,
    549                                                     culvert_z1,
    550                                                     culvert_z2,
    551                                                     culvert_length,
    552                                                     inlet_specific_energy,
    553                                                     delta_total_energy,
    554                                                     outlet_depth,
    555                                                     sum_loss,
    556                                                     manning)
     561        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     562                                                    width      = culvert_width,
     563                                                    depth      = culvert_height,
     564                                                    blockage   = culvert_blockage,
     565                                                    z1         = culvert_z1,
     566                                                    z2         = culvert_z2,
     567                                                    flow_width = culvert_width,
     568                                                    length     = culvert_length,
     569                                                    culvert_slope      = culvert_slope,
     570                                                    driving_energy     = inlet_specific_energy,
     571                                                    delta_total_energy = delta_total_energy,
     572                                                    outlet_enquiry_depth = outlet_depth,
     573                                                    sum_loss   = sum_loss,
     574                                                    manning    = manning)
    557575
    558576
     
    589607        culvert_z1=2
    590608        culvert_z2=2
     609        culvert_blockage = 0.0
    591610       
    592611        culvert_type='trapezoid'
     
    611630            print 'width ',culvert_width
    612631            print 'depth ',culvert_height
     632            print 'blockage ',culvert_blockage
    613633            print 'flow_width ',culvert_width
    614634            print 'length ' ,culvert_length
     
    619639            print 'manning ',manning
    620640       
    621         Q, v, d, flow_area, case= weir_orifice_trapezoid_function(culvert_width,
    622                                                     culvert_height,
    623                                                     culvert_width,
    624                                                     culvert_slope,
    625                                                     culvert_z1,
    626                                                     culvert_z2,
    627                                                     culvert_length,
    628                                                     inlet_specific_energy,
    629                                                     delta_total_energy,
    630                                                     outlet_depth,
    631                                                     sum_loss,
    632                                                     manning)
     641        Q, v, d, flow_area, case= weir_orifice_trapezoid_function(
     642                                                    width      = culvert_width,
     643                                                    depth      = culvert_height,
     644                                                    blockage   = culvert_blockage,
     645                                                    z1         = culvert_z1,
     646                                                    z2         = culvert_z2,
     647                                                    flow_width = culvert_width,
     648                                                    length     = culvert_length,
     649                                                    culvert_slope      = culvert_slope,
     650                                                    driving_energy     = inlet_specific_energy,
     651                                                    delta_total_energy = delta_total_energy,
     652                                                    outlet_enquiry_depth = outlet_depth,
     653                                                    sum_loss   = sum_loss,
     654                                                    manning    = manning)
    633655
    634656
     
    644666        assert numpy.allclose(v, v_expected, rtol=1.0e-1) #outflow velocity
    645667        assert numpy.allclose(d, d_expected, rtol=1.0e-1) #depth at outlet used to calc v
     668
    646669# =========================================================================
    647670if __name__ == "__main__":
  • trunk/anuga_core/anuga/structures/weir_orifice_trapezoid_operator.py

    r9737 r9740  
    2828                 z1,
    2929                 z2,
     30                 blockage=0.0,  #added by DPM 5/10/2016
    3031                 height=None,
    3132                 end_points=None,
     
    5253                                          width=width,
    5354                                          height=height,
     55                                          blockage=blockage, #added by DPM 5/10/2016
    5456                                          #culvert_slope=culvert_slope,
    5557                                          z1=z1,
     
    8284        self.culvert_width = self.get_culvert_width()
    8385        self.culvert_height = self.get_culvert_height()
     86        self.culvert_blockage = self.get_culvert_blockage()
    8487        self.culvert_slope = self.culvert_slope()
    8588        self.culvert_z1 = self.get_culvert_z1()
     
    161164                print 'width ',self.culvert_width
    162165                print 'depth ',self.culvert_height
     166                print 'culvert blockage ',self.culvert_blockage #added by DPM 5/10/2016
    163167                print 'left bank slope ',self.culvert_z1
    164168                print 'right bank slope ',self.culvert_z2               
     
    178182                              weir_orifice_trapezoid_function(width =self.culvert_width,
    179183                                                depth               =self.culvert_height,
     184                                                blockage            =self.culvert_blockage, #added by DPM 5/10/2016
    180185                                                z1                  =self.culvert_z1,
    181186                                                z2                  =self.culvert_z2,
     
    189194                                                manning             =self.manning)
    190195        else:
    191              Q = barrel_velocity = outlet_culvert_depth = 0.0
    192              case = 'Inlet dry'
     196            Q = barrel_velocity = outlet_culvert_depth = 0.0
     197            case = 'Inlet dry'
    193198
    194199
     
    211216def weir_orifice_trapezoid_function(width,
    212217                        depth,
     218                        blockage, #added by DPM 5/10/2016
    213219                        z1,
    214220                        z2,
     
    227233
    228234    local_debug = False
    229    
    230     Q_inlet_unsubmerged = 1.7*((2*width+depth*(z1+z2))/2)*driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged (weir flow equation)
    231     Q_inlet_submerged = 0.8*anuga.g**0.5*(0.5*depth*(2*width+depth*(z1+z2)))*driving_energy**0.5  # Flow based on Inlet Ctrl Inlet Submerged (orifice equation)
    232 
    233     # FIXME(Ole): Are these functions really for inlet control?
    234     if Q_inlet_unsubmerged < Q_inlet_submerged:
    235         Q = Q_inlet_unsubmerged
     235
     236    if blockage >= 1.0:
     237        Q = barrel_velocity = outlet_culvert_depth = 0.0
     238        flow_area = 0.00001
     239        case = '100 blocked culvert'
     240        return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
     241    else:
     242        b_depth = (1-blockage)*depth
     243        b_width = (1-blockage)*width
     244         
     245        Q_inlet_unsubmerged = 1.7*((2*b_width+b_depth*(z1+z2))/2)*driving_energy**1.50 # Flow based on Inlet Ctrl Inlet Unsubmerged (weir flow equation)
     246        Q_inlet_submerged = 0.8*anuga.g**0.5*(0.5*b_depth*(2*b_width+b_depth*(z1+z2)))*driving_energy**0.5  # Flow based on Inlet Ctrl Inlet Submerged (orifice equation)
     247
     248
     249
     250        # FIXME(Ole): Are these functions really for inlet control?
     251        if Q_inlet_unsubmerged < Q_inlet_submerged:
     252            Q = Q_inlet_unsubmerged
     253            # Critical Depths Calculation
     254            dcrit=0.00001
     255            ic=0
     256            dyc=0.001
     257            while abs(dyc)>0.00001:
     258                Tc=b_width+(z1+z2)*dcrit
     259                Pc=b_width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
     260                Ac=0.5*dcrit*(b_width+Tc)
     261                Rc=Ac/Pc
     262                fc=Ac**1.5*Tc**-0.5-Q/(9.81**0.5)
     263                ffc=Ac**1.5*-0.5*Tc**-1.5*(z1+z2)+Tc**-0.5*1.5*Ac**0.5*Tc
     264                dyc=-fc/ffc
     265                dcrit=dcrit+dyc
     266                ic=ic+1
     267            dcrit = dcrit
     268            if dcrit > depth:
     269                dcrit = depth
     270                flow_area = b_width*dcrit+0.5*(z1+z2)*dcrit**2
     271                perimeter= 2.0*b_width+(z1+z2)*dcrit + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
     272            else: # dcrit < depth
     273                flow_area = b_width*dcrit+0.5*(z1+z2)*dcrit**2
     274                perimeter= b_width + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
     275            outlet_culvert_depth = dcrit
     276            case = 'Inlet unsubmerged Box Acts as Weir'
     277        else: # Inlet Submerged but check internal culvert flow depth
     278            Q = Q_inlet_submerged
     279            # Critical Depths Calculation
     280            dcrit=0.00001
     281            ic=0
     282            dyc=0.001
     283            while abs(dyc)>0.00001:
     284                Tc=b_width+(z1+z2)*dcrit
     285                Pc=b_width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
     286                Ac=0.5*dcrit*(b_width+Tc)
     287                Rc=Ac/Pc
     288                fc=Ac**1.5*Tc**-0.5-Q/(9.81**0.5)
     289                ffc=Ac**1.5*-0.5*Tc**-1.5*(z1+z2)+Tc**-0.5*1.5*Ac**0.5*Tc
     290                dyc=-fc/ffc
     291                dcrit=dcrit+dyc
     292                ic=ic+1
     293            dcrit = dcrit
     294            if dcrit > depth:
     295                dcrit = depth
     296                flow_area = b_width*dcrit+0.5*(z1+z2)*dcrit**2
     297                perimeter= 2.0*b_width+(z1+z2)*dcrit + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
     298            else: # dcrit < depth
     299                flow_area = b_width*dcrit+0.5*(z1+z2)*dcrit**2
     300                perimeter= b_width + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
     301            outlet_culvert_depth = dcrit
     302            case = 'Inlet submerged Box Acts as Orifice'
    236303        # Critical Depths Calculation
    237304        dcrit=0.00001
     
    239306        dyc=0.001
    240307        while abs(dyc)>0.00001:
    241             Tc=width+(z1+z2)*dcrit
    242             Pc=width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
    243             Ac=0.5*dcrit*(width+Tc)
     308            Tc=b_width+(z1+z2)*dcrit
     309            Pc=b_width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
     310            Ac=0.5*dcrit*(b_width+Tc)
    244311            Rc=Ac/Pc
    245312            fc=Ac**1.5*Tc**-0.5-Q/(9.81**0.5)
     
    249316            ic=ic+1
    250317        dcrit = dcrit
    251         if dcrit > depth:
    252             dcrit = depth
    253             flow_area = width*dcrit+0.5*(z1+z2)*dcrit**2
    254             perimeter= 2.0*width+(z1+z2)*dcrit + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
    255         else: # dcrit < depth
    256             flow_area = width*dcrit+0.5*(z1+z2)*dcrit**2
    257             perimeter= width + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
     318        # May not need this .... check if same is done above
    258319        outlet_culvert_depth = dcrit
    259         case = 'Inlet unsubmerged Box Acts as Weir'
    260     else: # Inlet Submerged but check internal culvert flow depth
    261         Q = Q_inlet_submerged
    262         # Critical Depths Calculation
    263         dcrit=0.00001
    264         ic=0
    265         dyc=0.001
    266         while abs(dyc)>0.00001:
    267             Tc=width+(z1+z2)*dcrit
    268             Pc=width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
    269             Ac=0.5*dcrit*(width+Tc)
    270             Rc=Ac/Pc
    271             fc=Ac**1.5*Tc**-0.5-Q/(9.81**0.5)
    272             ffc=Ac**1.5*-0.5*Tc**-1.5*(z1+z2)+Tc**-0.5*1.5*Ac**0.5*Tc
    273             dyc=-fc/ffc
    274             dcrit=dcrit+dyc
    275             ic=ic+1
    276         dcrit = dcrit
    277         if dcrit > depth:
    278             dcrit = depth
    279             flow_area = width*dcrit+0.5*(z1+z2)*dcrit**2
    280             perimeter= 2.0*width+(z1+z2)*dcrit + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
    281         else: # dcrit < depth
    282             flow_area = width*dcrit+0.5*(z1+z2)*dcrit**2
    283             perimeter= width + (dcrit**2+(z1*dcrit)**2)**0.5 + (dcrit**2+(z2*dcrit)**2)**0.5
    284         outlet_culvert_depth = dcrit
    285         case = 'Inlet submerged Box Acts as Orifice'
    286     # Critical Depths Calculation
    287     dcrit=0.00001
    288     ic=0
    289     dyc=0.001
    290     while abs(dyc)>0.00001:
    291         Tc=width+(z1+z2)*dcrit
    292         Pc=width+((z1**2+1)**0.5+(z2**2+1)**0.5)*dcrit
    293         Ac=0.5*dcrit*(width+Tc)
    294         Rc=Ac/Pc
    295         fc=Ac**1.5*Tc**-0.5-Q/(9.81**0.5)
    296         ffc=Ac**1.5*-0.5*Tc**-1.5*(z1+z2)+Tc**-0.5*1.5*Ac**0.5*Tc
    297         dyc=-fc/ffc
    298         dcrit=dcrit+dyc
    299         ic=ic+1
    300     dcrit = dcrit
    301     # May not need this .... check if same is done above
    302     outlet_culvert_depth = dcrit
    303     if outlet_culvert_depth > depth:
    304         outlet_culvert_depth = depth  # Once again the pipe is flowing full not partfull
    305         flow_area = width*depth+0.5*(z1+z2)*depth**2  # Cross sectional area of flow in the culvert
    306         perimeter = 2.0*width+(z1+z2)*depth + (depth**2+(z1*depth)**2)**0.5 + (depth**2+(z2*depth)**2)**0.5
    307         case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL'
    308     else:
    309         flow_area = width*outlet_culvert_depth+0.5*(z1+z2)*outlet_culvert_depth**2
    310         perimeter = 2.0*width+(z1+z2)*outlet_culvert_depth + (outlet_culvert_depth**2+(z1*outlet_culvert_depth)**2)**0.5 + (outlet_culvert_depth**2+(z2*outlet_culvert_depth)**2)**0.5
    311         case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    312     # Initial Estimate of Flow for Outlet Control using energy slope
    313     #( may need to include Culvert Bed Slope Comparison)
    314     hyd_rad = flow_area/perimeter
    315     culvert_velocity = math.sqrt(delta_total_energy/((sum_loss/2/anuga.g) \
    316                                                           +(manning**2*length)/hyd_rad**1.33333))
    317     Q_outlet_tailwater = flow_area * culvert_velocity
    318 
    319 
    320     if delta_total_energy < driving_energy:
    321         # Calculate flows for outlet control
    322 
    323         # Determine the depth at the outlet relative to the depth of flow in the Culvert
    324         if outlet_enquiry_depth > depth:        # The Outlet is Submerged
    325             outlet_culvert_depth=depth
    326             flow_area=width*depth+0.5*(z1+z2)*depth**2  # Cross sectional area of flow in the culvert
    327             perimeter=width + (depth**2+(z1*depth)**2)**0.5 + (depth**2+(z2*depth)**2)**0.5
    328             case = 'Outlet submerged'
    329         else:   # Here we use the Culvert Slope to calculate Actual Culvert Depth & Velocity             
    330             # Iterate to determine Normal Depth...........
     320        if outlet_culvert_depth > depth:
     321            outlet_culvert_depth = depth  # Once again the pipe is flowing full not partfull
     322            flow_area = b_width*b_depth+0.5*(z1+z2)*(b_depth)**2  # Cross sectional area of flow in the culvert
     323            perimeter = 2.0*b_width+(z1+z2)*b_depth + ((b_depth)**2+(z1*(b_depth))**2)**0.5 + ((b_depth)**2+(z2*(b_depth))**2)**0.5
     324            case = 'Inlet CTRL Outlet unsubmerged PIPE PART FULL'
     325        else:
     326            flow_area = b_width*outlet_culvert_depth+0.5*(z1+z2)*outlet_culvert_depth**2
     327            perimeter = 2.0*b_width+(z1+z2)*outlet_culvert_depth + (outlet_culvert_depth**2+(z1*outlet_culvert_depth)**2)**0.5 + (outlet_culvert_depth**2+(z2*outlet_culvert_depth)**2)**0.5
     328            case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
     329        # Initial Estimate of Flow for Outlet Control using energy slope
     330        #( may need to include Culvert Bed Slope Comparison)
     331        hyd_rad = flow_area/perimeter
     332        culvert_velocity = math.sqrt(delta_total_energy/((sum_loss/2/anuga.g) \
     333                                                              +(manning**2*length)/hyd_rad**1.33333))
     334        Q_outlet_tailwater = flow_area * culvert_velocity
     335   
     336   
     337        if delta_total_energy < driving_energy:
     338            # Calculate flows for outlet control
     339   
     340            # Determine the depth at the outlet relative to the depth of flow in the Culvert
     341            if outlet_enquiry_depth > depth:        # The Outlet is Submerged
     342                outlet_culvert_depth=depth
     343                flow_area=b_width*b_depth+0.5*(z1+z2)*(b_depth)**2  # Cross sectional area of flow in the culvert
     344                perimeter=b_width + ((b_depth)**2+(z1*(b_depth))**2)**0.5 + ((b_depth)**2+(z2*(b_depth))**2)**0.5
     345                case = 'Outlet submerged'
     346            else:   # Here we use the Culvert Slope to calculate Actual Culvert Depth & Velocity             
     347                # Iterate to determine Normal Depth...........
     348               
     349                Q = min(Q, Q_outlet_tailwater)
     350                dnorm=0.00001
     351                idn=1
     352                dyn=0.001
     353               
     354                while abs(dyn)>0.0001:
     355                    Tn=b_width+(z1+z2)*dnorm
     356                    An=0.5*dnorm*(b_width+Tn)
     357                    Pn=b_width+2*dnorm*((z1**2+z2**2)**0.5)
     358                    Rn=An/Pn
     359                    fn=((culvert_slope**0.5*An*Rn**0.67)/manning) - Q
     360                    ffn=((culvert_slope**0.5)/manning)*(((Rn**0.67)*Tn)+(Tn/Pn)-(2*dnorm*Rn/Pn))
     361                    dnorm=dnorm-fn/ffn       
     362                    dyn=-fn/ffn
     363                    idn=idn+1
     364                outlet_culvert_depth = dnorm
     365                if outlet_culvert_depth > depth:
     366                    outlet_culvert_depth=depth
     367                    flow_area=b_width*b_depth+0.5*(z1+z2)*(b_depth)**2
     368                    perimeter=b_width + ((b_depth)**2+(z1*(b_depth))**2)**0.5 + ((b_depth)**2+(z2*(b_depth))**2)**0.5
     369                    case = 'Outlet is Flowing Full'
     370                else:
     371                    flow_area=b_width*outlet_culvert_depth+0.5*(z1+z2)*outlet_culvert_depth**2
     372                    perimeter=b_width + (outlet_culvert_depth**2+(z1*outlet_culvert_depth)**2)**0.5 + (outlet_culvert_depth**2+(z2*outlet_culvert_depth)**2)**0.5
     373                    case = 'Outlet is open channel flow'
     374   
     375            hyd_rad = flow_area/perimeter
     376   
     377            # Final Outlet control velocity using tail water
     378            culvert_velocity = math.sqrt(delta_total_energy/((sum_loss/2/anuga.g)\
     379                                                              +(manning**2*length)/hyd_rad**1.33333))
     380            Q_outlet_tailwater = flow_area * culvert_velocity
     381   
     382            Q = min(Q, Q_outlet_tailwater)
     383        else:
     384   
     385            pass
     386            #FIXME(Ole): What about inlet control?
     387   
     388        if  flow_area <= 0.0 :
     389            culv_froude = 0.0
     390        else:
     391            culv_froude=math.sqrt(Q**2*flow_width/(anuga.g*flow_area**3))
    331392           
    332             Q = min(Q, Q_outlet_tailwater)
    333             dnorm=0.00001
    334             idn=1
    335             dyn=0.001
    336            
    337             while abs(dyn)>0.0001:
    338                 Tn=width+(z1+z2)*dnorm
    339                 An=0.5*dnorm*(width+Tn)
    340                 Pn=width+2*dnorm*((z1**2+z2**2)**0.5)
    341                 Rn=An/Pn
    342                 fn=((culvert_slope**0.5*An*Rn**0.67)/manning) - Q
    343                 ffn=((culvert_slope**0.5)/manning)*(((Rn**0.67)*Tn)+(Tn/Pn)-(2*dnorm*Rn/Pn))
    344                 dnorm=dnorm-fn/ffn       
    345                 dyn=-fn/ffn
    346                 idn=idn+1
    347             outlet_culvert_depth = dnorm
    348             if outlet_culvert_depth > depth:
    349                 outlet_culvert_depth=depth
    350                 flow_area=width*depth+0.5*(z1+z2)*depth**2
    351                 perimeter=width + (depth**2+(z1*depth)**2)**0.5 + (depth**2+(z2*depth)**2)**0.5
    352                 case = 'Outlet is Flowing Full'
    353             else:
    354                 flow_area=width*outlet_culvert_depth+0.5*(z1+z2)*outlet_culvert_depth**2
    355                 perimeter=width + (outlet_culvert_depth**2+(z1*outlet_culvert_depth)**2)**0.5 + (outlet_culvert_depth**2+(z2*outlet_culvert_depth)**2)**0.5
    356                 case = 'Outlet is open channel flow'
    357 
    358         hyd_rad = flow_area/perimeter
    359 
    360         # Final Outlet control velocity using tail water
    361         culvert_velocity = math.sqrt(delta_total_energy/((sum_loss/2/anuga.g)\
    362                                                           +(manning**2*length)/hyd_rad**1.33333))
    363         Q_outlet_tailwater = flow_area * culvert_velocity
    364 
    365         Q = min(Q, Q_outlet_tailwater)
    366     else:
    367 
    368         pass
    369         #FIXME(Ole): What about inlet control?
    370 
    371     if  flow_area <= 0.0 :
    372         culv_froude = 0.0
    373     else:
    374         culv_froude=math.sqrt(Q**2*flow_width/(anuga.g*flow_area**3))
    375        
    376     if local_debug:
    377         anuga.log.critical('FLOW AREA = %s' % str(flow_area))
    378         anuga.log.critical('PERIMETER = %s' % str(perimeter))
    379         anuga.log.critical('Q final = %s' % str(Q))
    380         anuga.log.critical('FROUDE = %s' % str(culv_froude))
    381 
    382     # Determine momentum at the outlet
    383     barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area)
    384 
    385     # END CODE BLOCK for DEPTH  > Required depth for CULVERT Flow
    386 
    387     return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
     393        if local_debug:
     394            anuga.log.critical('FLOW AREA = %s' % str(flow_area))
     395            anuga.log.critical('PERIMETER = %s' % str(perimeter))
     396            anuga.log.critical('Q final = %s' % str(Q))
     397            anuga.log.critical('FROUDE = %s' % str(culv_froude))
     398   
     399        # Determine momentum at the outlet
     400        barrel_velocity = Q/(flow_area + anuga.velocity_protection/flow_area)
     401   
     402        # END CODE BLOCK for DEPTH  > Required depth for CULVERT Flow
     403   
     404        return Q, barrel_velocity, outlet_culvert_depth, flow_area, case
Note: See TracChangeset for help on using the changeset viewer.