Ignore:
Timestamp:
Jul 22, 2009, 9:22:11 AM (16 years ago)
Author:
rwilson
Message:

Replaced 'print' statements with log.critical() calls.

Location:
anuga_core/source/anuga/culvert_flows
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/culvert_flows/Test_Culvert_Flat_Water_Lev.py

    r7276 r7317  
    1111
    1212"""
     13
    1314print 'Starting.... Importing Modules...'
     15
    1416#------------------------------------------------------------------------------
    1517# Import necessary modules
  • anuga_core/source/anuga/culvert_flows/culvert_class.py

    r7276 r7317  
    1313from anuga.config import g, epsilon
    1414from anuga.config import minimum_allowed_height, velocity_protection       
     15import anuga.utilities.log as log
    1516
    1617import numpy as num
     
    287288                msg += ' does not match distance between specified'
    288289                msg += ' end points (%.2f m)' %self.length
    289                 print msg
     290                log.critical(msg)
    290291       
    291292        self.verbose = verbose
     
    441442            msg += 'Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced)
    442443            if self.verbose is True:
    443                 print msg
     444                log.critical(msg)
    444445               
    445446            if self.log_filename is not None:               
     
    506507        delta_total_energy = openings[0].total_energy - openings[1].total_energy
    507508        if delta_total_energy > 0:
    508             #print 'Flow U/S ---> D/S'
    509509            inlet = openings[0]
    510510            outlet = openings[1]
    511511        else:
    512             #print 'Flow D/S ---> U/S'
    513512            inlet = openings[1]
    514513            outlet = openings[0]
     
    530529            # Flow will be purely controlled by uphill outlet face
    531530            if self.verbose is True:
    532                 print '%.2fs - WARNING: Flow is running uphill.' % time
     531                log.critical('%.2fs - WARNING: Flow is running uphill.' % time)
    533532           
    534533        if self.log_filename is not None:
     
    789788            msg += ' does not match distance between specified'
    790789            msg += ' end points (%.2f m)' %self.length
    791             print msg
     790            log.critical(msg)
    792791       
    793792        self.verbose = verbose
     
    906905                V += d * domain.areas[i]
    907906           
    908             #Vsimple = mean(depth)*self.inlet.exchange_area # Current volume in exchange area 
    909             #print 'Q', Q, 'dt', delta_t, 'Q*dt', Q*delta_t, 'V', V, 'Vsimple', Vsimple
    910 
    911907            dt = delta_t           
    912908            if Q*dt > V:
     
    918914                msg += ' Q will be reduced from %.2f m^3/s to %.2f m^3/s.' % (Q, Q_reduced)
    919915               
    920                 #print msg
    921                
    922916                if self.verbose is True:
    923                     print msg
     917                    log.critical(msg)
    924918                if hasattr(self, 'log_filename'):                   
    925919                    log_to_file(self.log_filename, msg)                                       
     
    13131307                   
    13141308                opening.total_energy = 0.5*(u*u + v*v)/g + stage
    1315                 #print 'Et = %.3f m' %opening.total_energy
    13161309
    13171310                # Store current average stage and depth with each opening object
     
    13301323
    13311324            if delta_Et > 0:
    1332                 #print 'Flow U/S ---> D/S'
    13331325                inlet = openings[0]
    13341326                outlet = openings[1]
     
    13381330
    13391331            else:
    1340                 #print 'Flow D/S ---> U/S'
    13411332                inlet = openings[1]
    13421333                outlet = openings[0]
     
    13611352                # Flow will be purely controlled by uphill outlet face
    13621353                if self.verbose is True:
    1363                     print 'WARNING: Flow is running uphill. Watch Out!', inlet.elevation, outlet.elevation
     1354                    log.critical('WARNING: Flow is running uphill. Watch Out! '
     1355                                 'inlet.elevation=%s, outlet.elevation%s'
     1356                                 % (str(inlet.elevation), str(outlet.elevation)))
    13641357
    13651358
  • anuga_core/source/anuga/culvert_flows/culvert_routines.py

    r7276 r7317  
    8686    if inlet_depth > 0.1: #this value was 0.01:
    8787        if local_debug =='true':
    88             print 'Specific E & Deltat Tot E = ',inlet_specific_energy,delta_total_energy
    89             print 'culvert typ = ',culvert_type
     88            log.critical('Specific E & Deltat Tot E = %s, %s'
     89                         % (str(inlet_specific_energy),
     90                            str(delta_total_energy)))
     91            log.critical('culvert type = %s' % str(culvert_type))
    9092        # Water has risen above inlet
    9193       
     
    138140                flow_width= diameter
    139141                case = 'Inlet CTRL Outlet submerged Circular PIPE FULL'
    140                 if local_debug =='true':
    141                     print 'Inlet CTRL Outlet submerged Circular PIPE FULL'
     142                if local_debug == 'true':
     143                    log.critical('Inlet CTRL Outlet submerged Circular '
     144                                 'PIPE FULL')
    142145            else:
    143146                #alpha = acos(1 - outlet_culvert_depth/diameter)    # Where did this Come From ????/
     
    149152                case = 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    150153                if local_debug =='true':
    151                     print 'INLET CTRL Culvert is open channel flow we will for now assume critical depth'
    152                     print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,'  ',alpha
     154                    log.critical('INLET CTRL Culvert is open channel flow '
     155                                 'we will for now assume critical depth')
     156                    log.critical('Q Outlet Depth and ALPHA = %s, %s, %s'
     157                                 % (str(Q), str(outlet_culvert_depth),
     158                                    str(alpha)))
    153159            if delta_total_energy < inlet_specific_energy:  #  OUTLET CONTROL !!!!
    154160                # Calculate flows for outlet control
     
    162168                    case = 'Outlet submerged'
    163169                    if local_debug =='true':
    164                         print 'Outlet submerged'
     170                        log.critical('Outlet submerged')
    165171                else:   # Culvert running PART FULL for PART OF ITS LENGTH   Here really should use the Culvert Slope to calculate Actual Culvert Depth & Velocity
    166172                    # IF  outlet_depth < diameter
     
    178184                        case = 'Outlet unsubmerged PIPE FULL'
    179185                        if local_debug =='true':
    180                             print  'Outlet unsubmerged PIPE FULL'
     186                            log.critical('Outlet unsubmerged PIPE FULL')
    181187                    else:
    182188                        alpha = acos(1-2*outlet_culvert_depth/diameter)*2
     
    185191                        perimeter = alpha*diameter/2.0
    186192                        case = 'Outlet is open channel flow we will for now assume critical depth'
    187                         if local_debug =='true':
    188                             print 'Q Outlet Depth and ALPHA = ',Q,' ',outlet_culvert_depth,'  ',alpha
    189                             print 'Outlet is open channel flow we will for now assume critical depth'
    190             if local_debug =='true':
    191                 print 'FLOW AREA = ',flow_area
    192                 print 'PERIMETER = ',perimeter
    193                 print 'Q Interim = ',Q
     193                        if local_debug == 'true':
     194                            log.critical('Q Outlet Depth and ALPHA = %s, %s, %s'
     195                                         % (str(Q), str(outlet_culvert_depth),
     196                                            str(alpha)))
     197                            log.critical('Outlet is open channel flow we '
     198                                         'will for now assume critical depth')
     199            if local_debug == 'true':
     200                log.critical('FLOW AREA = %s' % str(flow_area))
     201                log.critical('PERIMETER = %s' % str(perimeter))
     202                log.critical('Q Interim = %s' % str(Q))
    194203            hyd_rad = flow_area/perimeter
    195204
     
    200209            # Outlet control velocity using tail water
    201210            if local_debug =='true':
    202                 print 'GOT IT ALL CALCULATING Velocity'
    203                 print 'HydRad = ',hyd_rad     
     211                log.critical('GOT IT ALL CALCULATING Velocity')
     212                log.critical('HydRad = %s' % str(hyd_rad))
    204213            culvert_velocity = sqrt(delta_total_energy/((sum_loss/2/g)+(manning**2*culvert_length)/hyd_rad**1.33333))
    205214            Q_outlet_tailwater = flow_area * culvert_velocity
    206215            if local_debug =='true':
    207                 print 'VELOCITY = ',culvert_velocity
    208                 print 'Outlet Ctrl Q = ',Q_outlet_tailwater
     216                log.critical('VELOCITY = %s' % str(culvert_velocity))
     217                log.critical('Outlet Ctrl Q = %s' % str(Q_outlet_tailwater))
    209218            if log_filename is not None:               
    210219                s = 'Q_outlet_tailwater = %.6f' %Q_outlet_tailwater
     
    212221            Q = min(Q, Q_outlet_tailwater)
    213222            if local_debug =='true':
    214                 print ('%s,%.3f,%.3f' %('dcrit 1 , dcit2 =',dcrit1,dcrit2))
    215                 print ('%s,%.3f,%.3f,%.3f' %('Q and Velocity and Depth=',Q,culvert_velocity,outlet_culvert_depth))
     223                log.critical('%s,%.3f,%.3f'
     224                             % ('dcrit 1 , dcit2 =',dcrit1,dcrit2))
     225                log.critical('%s,%.3f,%.3f,%.3f'
     226                             % ('Q and Velocity and Depth=', Q,
     227                                culvert_velocity, outlet_culvert_depth))
    216228
    217229        else:
     
    221233
    222234        #else....
    223         if culvert_type =='box':
    224             if local_debug =='true':
    225                 print 'BOX CULVERT'
     235        if culvert_type == 'box':
     236            if local_debug == 'true':
     237                log.critical('BOX CULVERT')
    226238            # Box culvert (rectangle or square)   ========================================================================================================================
    227239
     
    318330        culv_froude=sqrt(Q**2*flow_width/(g*flow_area**3))
    319331        if local_debug =='true':
    320             print 'FLOW AREA = ',flow_area
    321             print 'PERIMETER = ',perimeter
    322             print 'Q final = ',Q
    323             print 'FROUDE = ',culv_froude
     332            log.critical('FLOW AREA = %s' % str(flow_area))
     333            log.critical('PERIMETER = %s' % str(perimeter))
     334            log.critical('Q final = %s' % str(Q))
     335            log.critical('FROUDE = %s' % str(culv_froude))
    324336        if log_filename is not None:                           
    325337            s = 'Froude in Culvert = %f' % culv_froude
  • anuga_core/source/anuga/culvert_flows/test_culvert_class.py

    r7276 r7317  
    135135            if delta_w < min_delta_w: min_delta_w = delta_w           
    136136           
    137             #print domain.timestepping_statistics()
    138137            pass
    139138
     
    236235        ref_volume = domain.get_quantity('stage').get_integral()
    237236        for t in domain.evolve(yieldstep = 1, finaltime = 25):
    238             #print domain.timestepping_statistics()
    239237            new_volume = domain.get_quantity('stage').get_integral()
    240238           
     
    339337        ref_volume = domain.get_quantity('stage').get_integral()
    340338        for t in domain.evolve(yieldstep = 0.1, finaltime = 25):
    341             #print domain.timestepping_statistics()
    342339            new_volume = domain.get_quantity('stage').get_integral()
    343340           
    344             msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\
    345                 % (new_volume, ref_volume)
    346             if not num.allclose(new_volume, ref_volume):
    347                 print msg
     341            msg = ('Total volume has changed: Is %.2f m^3 should have been %.2f m^3'
     342                   % (new_volume, ref_volume))
    348343            assert num.allclose(new_volume, ref_volume), msg       
    349344       
     
    360355            ref_volume = domain.get_quantity('stage').get_integral()
    361356            for t in domain.evolve(yieldstep = 0.1, finaltime = 25):
    362                 #print domain.timestepping_statistics()
    363357                new_volume = domain.get_quantity('stage').get_integral()
    364358           
    365                 #print new_volume, ref_volume, new_volume-ref_volume
    366359                msg = 'Total volume has changed: Is %.2f m^3 should have been %.2f m^3'\
    367360                    % (new_volume, ref_volume)
     
    471464        for t in domain.evolve(yieldstep = 1, finaltime = 25):
    472465           
    473             #print domain.timestepping_statistics()
    474466            new_volume = domain.get_quantity('stage').get_integral()
    475467
     
    558550        culvert(domain)
    559551   
    560         #print 'Inlet flow', culvert.inlet.rate
    561         #print 'Outlet flow', culvert.outlet.rate       
    562        
    563    
    564552               
    565553#-------------------------------------------------------------
     554
    566555if __name__ == "__main__":
    567556    suite = unittest.makeSuite(Test_Culvert, 'test')
Note: See TracChangeset for help on using the changeset viewer.