Changeset 7345
 Timestamp:
 Aug 9, 2009, 5:13:36 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/documentation/user_manual/demos/channel_variable.py
r7344 r7345 32 32 """Complex topography defined by a function of vectors x and y.""" 33 33 34 z = x/10 34 z = x/100 35 35 36 36 N = len(x) … … 41 41 42 42 # Constriction 43 if 27 < x[i] < 29 and y[i] > 3:44 z[i] += 243 #if 27 < x[i] < 29 and y[i] > 3: 44 # z[i] += 2 45 45 46 46 # Pole … … 50 50 return z 51 51 52 def pole_increment s(x,y):52 def pole_increment(x,y): 53 53 """This provides a small increment to a pole located mid stream 54 54 For use with variable elevation data … … 60 60 for i in range(N): 61 61 # 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 65 64 return z 66 65 … … 82 81 # Evolve system through time 83 82 # 84 for t in domain.evolve(yieldstep=0.1, finaltime=16.0): 83 84 growing = False 85 shrinking = False 86 done = False 87 for t in domain.evolve(yieldstep=0.1, finaltime=30.0): 85 88 print domain.timestepping_statistics() 86 89 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 90 106 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: 91 114 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.