Changeset 7974


Ignore:
Timestamp:
Aug 25, 2010, 12:31:14 PM (9 years ago)
Author:
habili
Message:

Refactoring of code

File:
1 edited

Legend:

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

    r7971 r7974  
    389389                v = 0.0
    390390               
    391             v_squared =  u**2 + v**2   
     391            uv2 =  u**2 + v**2   
    392392               
    393393            if self.use_velocity_head is True:
    394                 velocity_head = 0.5*v_squared/g   
     394                velocity_head = 0.5*uv2/g   
    395395            else:
    396396                velocity_head = 0.0
    397397           
    398             total_energies[i] = velocity_head + stage
    399             specific_energies[i] = velocity_head + depth
    400             velocities[i] = math.sqrt(v_squared)           
     398            inlet.set_total_energy(velocity_head + stage)
     399            inlet.set_specific_energy(velocity_head + depth)
    401400
    402401        # We now need to deal with each opening individually
    403402        # Determine flow direction based on total energy difference
    404         delta_total_energy = total_energies[0] - total_energies[1]
     403        delta_total_energy = inlets[0].get_total_energy() - inlets[1].get_total_energy()
     404       
    405405        if delta_total_energy >= 0:
    406406            inlet = inlets[0]
    407407            outlet = inlets[1]
    408408        else:
    409             msg = 'Total energy difference is negative'
    410             assert delta_total_energy >= 0.0, msg
     409            inlet = inlets[1]
     410            outlet = inlets[2]
     411           
     412            #msg = 'Total energy difference is negative'
     413            #assert delta_total_energy >= 0.0, msg
    411414
    412415        # Recompute slope and issue warning if flow is uphill
     
    428431           
    429432        # Determine controlling energy (driving head) for culvert
    430         if inlet.specific_energy > delta_total_energy:
     433        if inlet.get_specific_energy() > delta_total_energy:
    431434            # Outlet control
    432435            driving_head = delta_total_energy
    433436        else:
    434437            # Inlet control
    435             driving_head = inlet.specific_energy
    436            
    437         if self.inlet.depth <= self.trigger_depth:
     438            driving_head = inlet.get_specific_energy()
     439           
     440        inlet_depth = inlet.get_average_stage() - inlet.get_average_elevation()
     441        outlet_depth = outlet.get_average_stage() - outlet.get_average_elevation()
     442       
     443        if inlet_depth <= self.trigger_depth:
    438444            Q = 0.0
    439445        else:
     
    471477                # User culvert routine
    472478                Q, barrel_velocity, culvert_outlet_depth =\
    473                     self.culvert_routine(inlet.depth,
    474                                          outlet.depth,
    475                                          inlet.velocity,
    476                                          outlet.velocity,
    477                                          inlet.specific_energy,
     479                    self.culvert_routine(inlet_depth,
     480                                         outlet_depth,
     481                                         inlet.get_average_velocity(),
     482                                         outlet.get_average_velocity(),
     483                                         inlet.get_specific_energy(),
    478484                                         delta_total_energy,
    479485                                         g,
Note: See TracChangeset for help on using the changeset viewer.