Ignore:
Timestamp:
Aug 9, 2009, 5:13:36 PM (15 years ago)
Author:
ole
Message:

Working variable bed example - storing time dependent elevation has not been attempted yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/demos/channel_variable.py

    r7344 r7345  
    3232    """Complex topography defined by a function of vectors x and y."""
    3333
    34     z = -x/10
     34    z = -x/100
    3535
    3636    N = len(x)
     
    4141
    4242        # Constriction
    43         if 27 < x[i] < 29 and y[i] > 3:
    44             z[i] += 2
     43        #if 27 < x[i] < 29 and y[i] > 3:
     44        #    z[i] += 2
    4545
    4646        # Pole
     
    5050    return z
    5151
    52 def pole_increments(x,y):
     52def pole_increment(x,y):
    5353    """This provides a small increment to a pole located mid stream
    5454    For use with variable elevation data
     
    6060    for i in range(N):
    6161        # Pole
    62         if (x[i] - 34)**2 + (y[i] - 2)**2 < 0.4**2:
    63             z[i] += 0.01
    64 
     62        if (x[i] - 20)**2 + (y[i] - 2)**2 < 0.4**2:
     63            z[i] += 0.05
    6564    return z
    6665   
     
    8281# Evolve system through time
    8382#------------------------------------------------------------------------------
    84 for t in domain.evolve(yieldstep=0.1, finaltime=16.0):
     83
     84growing = False
     85shrinking = False
     86done = False
     87for t in domain.evolve(yieldstep=0.1, finaltime=30.0):
    8588    print domain.timestepping_statistics()
    8689
    87     if domain.get_quantity('stage').\
    88            get_values(interpolation_points=[[10, 2.5]]) > 0:
    89         print 'Stage > 0: Changing elevation data'
     90    #w = domain.get_quantity('stage').\
     91    #    get_values(interpolation_points=[[18, 2.5]])
     92    #print 'Level at gauge point = %.2fm' % w
     93           
     94    z = domain.get_quantity('elevation').\
     95        get_values(interpolation_points=[[20, 2]])           
     96    print 'Elevation at pole location = %.2fm' % z           
     97
     98    # Start variable elevation after 10 seconds   
     99    if t > 10 and not (shrinking or growing or done):
     100        growing = True
     101           
     102    # Turn around when pole has reached a height of 2 m
     103    if z >= 2 and growing:
     104        growing = False
     105        shrinking = True
    90106       
     107    # Stop changing when pole has shrunk to 1 m
     108    if z <= 1 and shrinking:
     109        done = True
     110        shrinking = growing = False
     111
     112    # Grow or shrink               
     113    if growing:       
    91114        domain.add_quantity('elevation', pole_increment)
     115       
     116    if shrinking:   
     117        domain.add_quantity('elevation', lambda x,y: -pole_increment(x,y))   
     118       
Note: See TracChangeset for help on using the changeset viewer.