Ignore:
Timestamp:
May 14, 2009, 2:24:54 PM (15 years ago)
Author:
rwilson
Message:

Back-merge from Numeric trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/culvert_flows/culvert_class.py

    r6902 r7035  
    1515
    1616import numpy as num
    17 
     17from math import sqrt
    1818
    1919class Below_interval(Exception): pass
     
    137137                 manning=None,          # Mannings Roughness for Culvert
    138138                 sum_loss=None,
    139                  use_velocity_head=False,
     139                 use_velocity_head=False, # FIXME(Ole): Get rid of - always True
    140140                 use_momentum_jet=False, # FIXME(Ole): Not yet implemented
    141141                 label=None,
     
    464464            log_filename = self.log_filename
    465465           
    466         # Compute stage and energy at the
     466        # Compute stage, energy and velocity at the
    467467        # enquiry points at each end of the culvert
    468468        openings = self.openings
     
    474474            depth = h = stage-opening.elevation
    475475                                                           
    476                                                
     476           
     477            # Get velocity                                 
     478            xmomentum = dq['xmomentum'].get_values(location='centroids',
     479                                                   indices=[idx])[0]
     480            ymomentum = dq['xmomentum'].get_values(location='centroids',
     481                                                   indices=[idx])[0]
     482           
     483            if h > minimum_allowed_height:
     484                u = xmomentum/(h + velocity_protection/h)
     485                v = ymomentum/(h + velocity_protection/h)
     486            else:
     487                u = v = 0.0
     488               
     489            v_squared = u*u + v*v
     490           
    477491            if self.use_velocity_head is True:
    478                 xmomentum = dq['xmomentum'].get_values(location='centroids',
    479                                                        indices=[idx])[0]
    480                 ymomentum = dq['xmomentum'].get_values(location='centroids',
    481                                                        indices=[idx])[0]
    482            
    483                 if h > minimum_allowed_height:
    484                     u = xmomentum/(h + velocity_protection/h)
    485                     v = ymomentum/(h + velocity_protection/h)
    486                 else:
    487                     u = v = 0.0
    488                
    489                 velocity_head = 0.5*(u*u + v*v)/g   
     492                velocity_head = 0.5*v_squared/g   
    490493            else:
    491494                velocity_head = 0.0
     
    495498            opening.stage = stage
    496499            opening.depth = depth
     500            opening.velocity = sqrt(v_squared)
    497501           
    498502
     
    583587                    self.culvert_routine(inlet.depth,
    584588                                         outlet.depth,
     589                                         inlet.velocity,
     590                                         outlet.velocity,
    585591                                         inlet.specific_energy,
    586592                                         delta_total_energy,
Note: See TracChangeset for help on using the changeset viewer.