Changeset 8080


Ignore:
Timestamp:
Nov 20, 2010, 10:18:51 AM (8 years ago)
Author:
steve
Message:

Added water level in inlet_operator

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

Legend:

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

    r8073 r8080  
    216216
    217217        self.domain.quantities['elevation'].centroid_values.put(self.triangle_indices, elevation)
     218
     219    def set_stages_evenly(self,volume):
     220        """ Distribute volume of water over
     221        inlet exchange region so that stage is level
     222        """
     223
     224        areas = self.get_areas()
     225        stages = self.get_stages()
     226
     227        stages_order = stages.argsort()
     228
     229        summed_areas = num.zeros_like(areas)
     230        summed_volume = num.zeros_like(areas)
     231        #diff_stage = num.zeros_like(areas)
     232
     233        for i,a in enumerate(areas[stages_order]):
     234            #print i,a, stages[stages_order[i]]
     235            if i == 0:
     236                summed_areas[i] = a
     237                summed_volume[i] = 0.0
     238                #diff_stage[i] = 0.0
     239            else:
     240                summed_areas[i] = summed_areas[i-1] + a
     241
     242                summed_volume[i] = summed_volume[i-1] + summed_areas[i-1]*\
     243                    (stages[stages_order[i]] - stages[stages_order[i-1]])
     244
     245                #diff_stage[i] = stages[stages_order[i]] - stages[stages_order[i-1]]
     246
     247        #print 'amount ',amount
     248        #print summed_areas
     249        #print summed_amount
     250        #print diff_stage
     251
     252           
     253        #index = len(summed_amount)
     254        for i,a in enumerate(summed_volume):
     255            #print 'a ',a
     256            if volume > a :
     257                index = i
     258
     259        #print index
     260
     261        #print stages_order
     262        #print stages
     263       
     264        depth = (volume - summed_volume[index])/summed_areas[index]
     265               
     266        stages[stages_order[0:index+1]] = stages[stages_order[index]]+depth
     267
     268        self.set_stages(stages)
     269
     270    def set_depths_evenly(self,volume):
     271        """ Distribute volume over all exchange
     272        cells with equal depth of water
     273        """
     274           
     275        new_depth = self.get_average_depth() + (volume/self.get_area())
     276        self.set_depths(new_depth)
     277
  • trunk/anuga_core/source/anuga/structures/inlet_operator.py

    r8079 r8080  
    6969        Q = self.Q
    7070
    71         amount = Q*timestep
     71        volume = Q*timestep
    7272
    73         assert Q >= 0.0, 'removing water from an inlet!'
     73        assert Q >= 0.0, 'Q < 0: Water to be removed from an inlet!'
    7474
    7575
    76         # FIXME (SR): Might be nice to spread the over the inlet so that it is flat
    77 
    78 
    79         # Spread Q*timestep amount of water evenly over the inlet region
    80 
    81         areas = self.inlet.get_areas()
    82         stages = self.inlet.get_stages()
    83 
    84         stages_order = stages.argsort()
    85 
    86         summed_areas = numpy.zeros_like(areas)
    87         summed_amount = numpy.zeros_like(areas)
    88         diff_stage = numpy.zeros_like(areas)
    89 
    90         for i,a in enumerate(areas[stages_order]):
    91             #print i,a, stages[stages_order[i]]
    92             if i == 0:
    93                 summed_areas[i] = a
    94                 summed_amount[i] = 0.0
    95                 diff_stage[i] = 0.0
    96             else:
    97                 summed_areas[i] = summed_areas[i-1] + a
    98 
    99                 summed_amount[i] = summed_amount[i-1] + summed_areas[i-1]*\
    100                     (stages[stages_order[i]] - stages[stages_order[i-1]])
    101 
    102                 diff_stage[i] = stages[stages_order[i]] - stages[stages_order[i-1]]
    103 
    104         #print 'amount ',amount
    105         #print summed_areas
    106         #print summed_amount
    107         #print diff_stage
    108 
    109            
    110         #index = len(summed_amount)
    111         for i,a in enumerate(summed_amount):
    112             #print 'a ',a
    113             if amount > a :
    114                 index = i
    115 
    116         #print index
    117 
    118         #print stages_order
    119         #print stages
     76        # Distribute volume so as to obtain flat surface
     77        self.inlet.set_stages_evenly(volume)
    12078       
    121         amount = (amount - summed_amount[index])/summed_areas[index]
    122                
    123         stages[stages_order[0:index+1]] = stages[stages_order[index]]+amount
    124        
    125        
    126         #print stages
    127         #print areas
    128         #print stages[stages_order]
    129 
    130 
    131         #new_inlet_depth = self.inlet.get_average_depth() + (amount/self.inlet.get_area())
    132         #self.inlet.set_depths(new_inlet_depth)
    133 
    134         self.inlet.set_stages(stages)   
     79        # Distribute volume evenly over all cells
     80        #self.inlet.set_depths_evenly(volume)
     81 
    13582
    13683    def statistics(self):
Note: See TracChangeset for help on using the changeset viewer.