Changeset 8874


Ignore:
Timestamp:
May 24, 2013, 12:06:00 PM (12 years ago)
Author:
steve
Message:

Added in get_enquiry_water_depth

Location:
trunk/anuga_core/source/anuga/structures
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/structures/inlet_enquiry.py

    r8873 r8874  
    8383    def get_enquiry_depth(self):
    8484
     85        return max(self.get_enquiry_stage() - self.get_enquiry_invert_elevation(), 0.0)
     86
     87
     88    def get_enquiry_water_depth(self):
     89
    8590        return self.get_enquiry_stage() - self.get_enquiry_elevation()
    8691
     
    96101    def get_enquiry_velocity(self):
    97102
    98             depth = self.get_enquiry_depth()
     103            depth = self.get_enquiry_water_depth()
    99104            u = self.get_enquiry_xmom()/(depth + velocity_protection/depth)
    100105            v = self.get_enquiry_ymom()/(depth + velocity_protection/depth)
     
    105110    def get_enquiry_xvelocity(self):
    106111
    107             depth = self.get_enquiry_depth()
     112            depth = self.get_enquiry_water_depth()
    108113            return self.get_enquiry_xmom()/(depth + velocity_protection/depth)
    109114
    110115    def get_enquiry_yvelocity(self):
    111116
    112             depth = self.get_enquiry_depth()
     117            depth = self.get_enquiry_water_depth()
    113118            return self.get_enquiry_ymom()/(depth + velocity_protection/depth)
    114119
  • trunk/anuga_core/source/anuga/structures/inlet_operator.py

    r8849 r8874  
    1818    def __init__(self,
    1919                 domain,
    20                  line,
     20                 poly,
    2121                 Q = 0.0,
    2222                 velocity = None,
     
    3030        anuga.Operator.__init__(self, domain, description, label, logging, verbose)
    3131
    32         self.line = numpy.array(line, dtype='d')
     32        self.poly = numpy.array(poly, dtype='d')
    3333
    3434        # should set this up to be a function of time and or space)
     
    3838        #print self.Q
    3939
    40         self.enquiry_point = 0.5*(self.line[0] + self.line[1])
     40
     41        self.inlet = inlet.Inlet(self.domain, self.poly, verbose= verbose)
     42       
     43        n = len(self.poly)
     44
     45        self.enquiry_point = numpy.sum(self.poly,axis=1)/n
     46
     47
    4148        #self.outward_vector = self.line
    42         self.inlet = inlet.Inlet(self.domain, self.line, verbose= verbose)
    4349
    4450        if velocity is not None:
  • trunk/anuga_core/source/anuga/structures/run_inlet_operator.py

    r8361 r8874  
    104104line0 = [[0.0, 5.0], [0.0, 10.0]]
    105105
     106
    106107Q = file_function('test_hydrograph.tms', quantities=['hydrograph'])
    107108
    108 inlet0 = Inlet_operator(domain, line0, Q, label='first inlet')
     109#inlet0 = Inlet_operator(domain, line0, Q, label='first inlet')
    109110
    110111
    111112line1 = [[1.0, 5.0], [2.0, 10.0]]
    112 inlet1 = Inlet_operator(domain, line1, 2.0)
     113poly1 = [[1.0, 5.0], [2.0, 5.0], [2.0, 10.0], [1.0, 10.0]]
     114inlet1 = Inlet_operator(domain, poly1, 2.0)
    113115
    114116
     
    154156    print domain.volumetric_balance_statistics()
    155157
    156     inlet0.print_timestepping_statistics()
    157     print inlet1.timestepping_statistics()
     158    #inlet0.print_timestepping_statistics()
     159    inlet1.print_timestepping_statistics()
    158160    pass
    159161
  • trunk/anuga_core/source/anuga/structures/structure_operator.py

    r8873 r8874  
    298298        n_exchange_1 = len(self.exchange_lines[1])
    299299
    300         assert n_exchange_0 == n_exchange_1, 'There shoiuld be the same number of points in both exchange_lines'
     300        assert n_exchange_0 == n_exchange_1, 'There should be the same number of points in both exchange_lines'
    301301
    302302        if n_exchange_0 == 2:
  • trunk/anuga_core/source/anuga/structures/test_inlet_operator.py

    r8828 r8874  
    126126
    127127        assert numpy.allclose((Q1+Q2)*finaltime, vol1-vol0, rtol=1.0e-8)
    128        
    129     def test_inlet_variable_Q(self):
     128
     129
     130
     131    def test_inlet_constant_Q_polygon(self):
    130132        """test_inlet_Q
    131        
     133
    132134        This tests that the inlet operator adds the correct amount of water
    133135        """
     
    140142        domain_length = 200.0
    141143        domain_width = 200.0
    142        
     144
    143145
    144146        domain = self._create_domain(d_length=domain_length,
     
    154156
    155157        finaltime = 3.0
    156 
    157         #Make sure we are inthe right directory to find the
    158         #time series data for the inlets
    159         import os
    160         baseDir = os.getcwd()
    161 
    162         try:
    163             os.chdir('structures')
    164         except:
    165             pass
    166 
    167         line1 = [[95.0, 10.0], [105.0, 10.0]]
    168         Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph'])
    169        
    170         line2 = [[10.0, 90.0], [20.0, 90.0]]
    171         Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph'])
    172 
    173         os.chdir(baseDir)
    174        
    175         Inlet_operator(domain, line1, Q1)
    176         Inlet_operator(domain, line2, Q2)
     158        poly1 = [[95.0, 10.0], [105.0, 10.0], [105, 20.0], [95.0, 20.0]]
     159        Q1 = 5.00
     160
     161
     162        Inlet_operator(domain, poly1, Q1, logging=True)
     163
    177164
    178165        for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime):
     
    180167            #print domain.volumetric_balance_statistics()
    181168            pass
    182  
     169
    183170
    184171        vol1 = domain.compute_total_volume()
    185172
    186         #print vol1-vol0
    187        
    188         assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8)
    189                
    190     def test_inlet_variable_Q_default(self):
     173        assert numpy.allclose((Q1)*finaltime, vol1-vol0, rtol=1.0e-8)
     174
     175
     176
     177    def test_inlet_variable_Q(self):
    191178        """test_inlet_Q
    192 
     179       
    193180        This tests that the inlet operator adds the correct amount of water
    194181        """
     
    201188        domain_length = 200.0
    202189        domain_width = 200.0
    203 
     190       
    204191
    205192        domain = self._create_domain(d_length=domain_length,
     
    214201        vol0 = domain.compute_total_volume()
    215202
    216         finaltime = 5.0
     203        finaltime = 3.0
    217204
    218205        #Make sure we are inthe right directory to find the
     
    228215        line1 = [[95.0, 10.0], [105.0, 10.0]]
    229216        Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph'])
    230 
     217       
    231218        line2 = [[10.0, 90.0], [20.0, 90.0]]
    232219        Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph'])
    233220
    234221        os.chdir(baseDir)
    235 
    236         Inlet_operator(domain, line1, Q1, default=6)
    237         Inlet_operator(domain, line2, Q2, default=3)
     222       
     223        Inlet_operator(domain, line1, Q1)
     224        Inlet_operator(domain, line2, Q2)
    238225
    239226        for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime):
     
    241228            #print domain.volumetric_balance_statistics()
    242229            pass
     230 
     231
     232        vol1 = domain.compute_total_volume()
     233
     234        #print vol1-vol0
     235       
     236        assert numpy.allclose(13.5, vol1-vol0, rtol=1.0e-8)
     237               
     238    def test_inlet_variable_Q_default(self):
     239        """test_inlet_Q
     240
     241        This tests that the inlet operator adds the correct amount of water
     242        """
     243
     244        stage_0 = 11.0
     245        stage_1 = 10.0
     246        elevation_0 = 10.0
     247        elevation_1 = 10.0
     248
     249        domain_length = 200.0
     250        domain_width = 200.0
     251
     252
     253        domain = self._create_domain(d_length=domain_length,
     254                                     d_width=domain_width,
     255                                     dx = 10.0,
     256                                     dy = 10.0,
     257                                     elevation_0 = elevation_0,
     258                                     elevation_1 = elevation_1,
     259                                     stage_0 = stage_0,
     260                                     stage_1 = stage_1)
     261
     262        vol0 = domain.compute_total_volume()
     263
     264        finaltime = 5.0
     265
     266        #Make sure we are inthe right directory to find the
     267        #time series data for the inlets
     268        import os
     269        baseDir = os.getcwd()
     270
     271        try:
     272            os.chdir('structures')
     273        except:
     274            pass
     275
     276        line1 = [[95.0, 10.0], [105.0, 10.0]]
     277        Q1 = file_function(filename='inlet_operator_test1.tms', quantities=['hydrograph'])
     278
     279        line2 = [[10.0, 90.0], [20.0, 90.0]]
     280        Q2 = file_function(filename='inlet_operator_test2.tms', quantities=['hydrograph'])
     281
     282        os.chdir(baseDir)
     283
     284        Inlet_operator(domain, line1, Q1, default=6)
     285        Inlet_operator(domain, line2, Q2, default=3)
     286
     287        for t in domain.evolve(yieldstep = 1.0, finaltime = finaltime):
     288            #domain.write_time()
     289            #print domain.volumetric_balance_statistics()
     290            pass
    243291
    244292
     
    251299# =========================================================================
    252300if __name__ == "__main__":
    253     suite = unittest.makeSuite(Test_inlet_operator, 'test')
     301    suite = unittest.makeSuite(Test_inlet_operator, 'test_inlet_constant_Q_polygon')
    254302    runner = unittest.TextTestRunner()
    255303    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.