Changeset 9233


Ignore:
Timestamp:
Jul 2, 2014, 1:33:17 PM (10 years ago)
Author:
davies
Message:

Updates for serial boyd-box-operator with smoothing timescale

Location:
trunk/anuga_core/source
Files:
4 edited

Legend:

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

    r9148 r9233  
    11import anuga
    22import math
     3import numpy
    34
    45
     
    129130
    130131        #  delta_total_energy will determine which inlet is inflow
     132        # Update 02/07/2014 -- now using smooth_delta_total_energy
    131133        if self.use_velocity_head:
    132134            self.delta_total_energy = \
     
    136138                 self.inlets[0].get_enquiry_stage() - self.inlets[1].get_enquiry_stage()
    137139
    138         self.inflow  = self.inlets[0]
    139         self.outflow = self.inlets[1]
    140 
    141         if self.delta_total_energy < 0:
     140        # Compute 'smoothed' total energy
     141        forward_Euler_smooth=True
     142        if(forward_Euler_smooth):
     143            # To avoid 'overshoot' we ensure ts<1.
     144            if(self.domain.timestep>0.):
     145                ts=self.domain.timestep/max(self.domain.timestep, self.smoothing_timescale,1.0e-06)
     146            else:
     147                # Without this the unit tests with no smoothing fail [since they have domain.timestep=0.]
     148                # Note though the discontinuous behaviour as domain.timestep-->0. from above
     149                ts=1.0
     150            self.smooth_delta_total_energy=self.smooth_delta_total_energy+\
     151                                    ts*(self.delta_total_energy-self.smooth_delta_total_energy)
     152        else:
     153            # Use backward euler -- the 'sensible' ts limitation is different in this case
     154            # ts --> Inf is reasonable and corresponds to the 'nosmoothing' case
     155            ts=self.domain.timestep/max(self.smoothing_timescale, 1.0e-06)
     156            self.smooth_delta_total_energy = (self.smooth_delta_total_energy+ts*(self.delta_total_energy))/(1.+ts)
     157
     158        if self.smooth_delta_total_energy >= 0.:
     159            self.inflow  = self.inlets[0]
     160            self.outflow = self.inlets[1]
     161            self.delta_total_energy=self.smooth_delta_total_energy
     162        else:
    142163            self.inflow  = self.inlets[1]
    143164            self.outflow = self.inlets[0]
    144             self.delta_total_energy = -self.delta_total_energy
     165            self.delta_total_energy = -self.smooth_delta_total_energy
    145166           
    146167           
    147            
    148 
    149 
    150168        # Only calculate flow if there is some water at the inflow inlet.
    151169        if self.inflow.get_enquiry_depth() > 0.01: #this value was 0.01:
     
    193211                                                sum_loss            =self.sum_loss,
    194212                                                manning             =self.manning)
     213            #
     214            # Update 02/07/2014 -- using time-smoothed discharge
     215            Qsign=numpy.sign(self.smooth_delta_total_energy) #(self.outflow_index-self.inflow_index) # To adjust sign of Q
     216            if(forward_Euler_smooth):
     217                self.smooth_Q = self.smooth_Q +ts*(Q*Qsign-self.smooth_Q)
     218            else:
     219                # Try implicit euler method
     220                self.smooth_Q = (self.smooth_Q+ts*(Q*Qsign))/(1.+ts)
     221           
     222            if numpy.sign(self.smooth_Q)!=Qsign:
     223                # The flow direction of the 'instantaneous Q' based on the
     224                # 'smoothed delta_total_energy' is not the same as the
     225                # direction of smooth_Q. To prevent 'jumping around', let's
     226                # set Q to zero
     227                Q=0.
     228            else:
     229                Q = min(abs(self.smooth_Q), Q) #abs(self.smooth_Q)
     230            barrel_velocity=Q/flow_area
     231
    195232        else:
    196233             Q = barrel_velocity = outlet_culvert_depth = 0.0
  • trunk/anuga_core/source/anuga/utilities/spatialInputUtil.py

    r9219 r9233  
    7575        driver=ogr.GetDriverByName("ESRI Shapefile")
    7676        dataSrc=driver.Open(shapefile, 0)
     77        #dataSrc=ogr.Open(shapefile)
    7778        layer=dataSrc.GetLayer()
    7879       
     
    110111        driver=ogr.GetDriverByName("ESRI Shapefile")
    111112        dataSrc=driver.Open(shapefile, 0)
     113        #dataSrc=ogr.Open(shapefile)
    112114        layer=dataSrc.GetLayer()
    113115       
     
    139141        driver=ogr.GetDriverByName("ESRI Shapefile")
    140142        dataSrc=driver.Open(shapefile, 0)
     143        #dataSrc=ogr.Open(shapefile)
    141144        layer=dataSrc.GetLayer()
    142145   
  • trunk/anuga_core/source/anuga_parallel/parallel_boyd_box_operator.py

    r9133 r9233  
    174174            if(forward_Euler_smooth):
    175175                # To avoid 'overshoot' we ensure ts<1.
    176                 ts=self.domain.timestep/max(self.domain.timestep, self.smoothing_timescale,1.0e-06)
     176                if(self.domain.timestep>0.):
     177                    ts=self.domain.timestep/max(self.domain.timestep, self.smoothing_timescale,1.0e-06)
     178                else:
     179                    # This case is included in the serial version, which ensures the unit tests pass
     180                    # even when domain.timestep=0.0.
     181                    # Note though the discontinuous behaviour as domain.timestep-->0. from above
     182                    ts=1.0
    177183                self.smooth_delta_total_energy=self.smooth_delta_total_energy+\
    178184                                        ts*(self.delta_total_energy-self.smooth_delta_total_energy)
  • trunk/anuga_core/source/anuga_parallel/parallel_operator_factory.py

    r9130 r9233  
    154154                                                                    manning=manning,
    155155                                                                    enquiry_gap=enquiry_gap,
     156                                                                    smoothing_timescale=smoothing_timescale,
    156157                                                                    use_momentum_jet=use_momentum_jet,
    157158                                                                    use_velocity_head=use_velocity_head,
Note: See TracChangeset for help on using the changeset viewer.