Changeset 3753
- Timestamp:
- Oct 11, 2006, 3:58:53 PM (16 years ago)
- Location:
- anuga_core/documentation/user_manual/examples
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/examples/channel_1.py
r3747 r3753 20 20 dx = dy = 1 # Resolution: Length of subdivisions on both axes 21 21 22 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) 22 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 23 len1=length, len2=width) 24 23 25 domain = Domain(points, vertices, boundary) # Create domain 24 26 domain.set_name('channel_1') # Output name … … 31 33 return -x/10 # linear bed slope 32 34 33 domain.set_quantity('elevation', topography) # Use function for elevation 34 domain.set_quantity('friction', 0.01) # Constant friction 35 domain.set_quantity('stage', expression='elevation') # Dry 36 #domain.set_quantity('stage', expression='elevation + 0.1') # Wet 35 domain.set_quantity('elevation', topography) # Use function for elevation 36 domain.set_quantity('friction', 0.01) # Constant friction 37 domain.set_quantity('stage', 38 expression='elevation') # Dry 39 #domain.set_quantity('stage', 40 expression='elevation + 0.1') # Wet 37 41 38 42 … … 40 44 # Setup boundary conditions 41 45 #------------------------------------------------------------------------------ 42 Bi = Dirichlet_boundary([0.4, 0, 0]) 43 Br = Reflective_boundary(domain) 46 Bi = Dirichlet_boundary([0.4, 0, 0]) # Inflow 47 Br = Reflective_boundary(domain) # Solid reflective wall 44 48 45 49 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) -
anuga_core/documentation/user_manual/examples/channel_2.py
r3747 r3753 1 1 """Simple water flow example using ANUGA 2 2 3 Water flowing down a channel 3 Water flowing down a channel with changing boundary conditions 4 4 """ 5 5 … … 21 21 dx = dy = 1 # Resolution: Length of subdivisions on both axes 22 22 23 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) 23 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 24 len1=length, len2=width) 24 25 domain = Domain(points, vertices, boundary) 25 domain.set_name('channel_2') 26 domain.set_name('channel_2') # Output name 26 27 27 28 … … 32 33 return -x/10 # linear bed slope 33 34 34 domain.set_quantity('elevation', topography) # Use function for elevation 35 domain.set_quantity('friction', 0.01) # Constant friction 36 domain.set_quantity('stage', expression='elevation') # Dry 35 domain.set_quantity('elevation', topography) # Use function for elevation 36 domain.set_quantity('friction', 0.01) # Constant friction 37 domain.set_quantity('stage', 38 expression='elevation') # Dry initial condition 37 39 38 40 … … 40 42 # Setup boundary conditions 41 43 #------------------------------------------------------------------------------ 42 Bi = Dirichlet_boundary([0.4, 0, 0]) 43 Br = Reflective_boundary(domain) 44 Bo = Dirichlet_boundary([-5, 0, 0]) 44 Bi = Dirichlet_boundary([0.4, 0, 0]) # Inflow 45 Br = Reflective_boundary(domain) # Solid reflective wall 46 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 45 47 46 48 domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) … … 53 55 domain.write_time() 54 56 55 #print 'Stage(10,2.5) = ', domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) 56 57 from Numeric import allclose 58 #if allclose(t, 20): 59 if domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) > 0: 60 print 'Stage > 0: Changing boundary' 57 if domain.get_quantity('stage').\ 58 get_values(interpolation_points=[[10, 2.5]]) > 0: 59 print 'Stage > 0: Changing to outflow boundary' 61 60 domain.modify_boundary({'right': Bo}) 62 61 63 62 64 import sys; sys.exit()65 66 import time67 t0 = time.time()68 63 69 64 70 s = 'for t in domain.evolve(yieldstep = 0.2, finaltime = 40.0): domain.write_time(); domain.get_quantity("stage").get_values(interpolation_points=[[10, 2.5]])'71 72 import profile, pstats73 FN = 'profile.dat'74 75 profile.run(s, FN)76 77 print 'That took %.2f seconds' %(time.time()-t0)78 79 S = pstats.Stats(FN)80 #S.sort_stats('time').print_stats(20)81 s = S.sort_stats('cumulative').print_stats(30)82 83 print s84 -
anuga_core/documentation/user_manual/examples/channel_3.py
r3747 r3753 1 1 """Simple water flow example using ANUGA 2 2 3 Water flowing down a channel 3 Water flowing down a channel with more complex topography 4 4 """ 5 5 … … 20 20 width = 5. 21 21 dx = dy = 1 # Resolution: Length of subdivisions on both axes 22 #dx = dy = .1 # Resolution: Length of subdivisions on both axes 22 23 23 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) 24 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), 25 len1=length, len2=width) 24 26 domain = Domain(points, vertices, boundary) 25 27 domain.set_name('channel_3') # Output name … … 30 32 #------------------------------------------------------------------------------ 31 33 def topography(x,y): 32 z = -x/10 # linear bed slope 34 """Complex topography defined by a function of vectors x and y 35 """ 36 37 z = -x/10 33 38 34 39 N = len(x) … … 50 55 51 56 52 domain.set_quantity('elevation', topography) # Use function for elevation 53 domain.set_quantity('friction', 0.01) # Constant friction 54 domain.set_quantity('stage', expression='elevation') # Dry 57 domain.set_quantity('elevation', topography) # Use function for elevation 58 domain.set_quantity('friction', 0.01) # Constant friction 59 domain.set_quantity('stage', 60 expression='elevation') # Dry initial condition 55 61 56 62 … … 58 64 # Setup boundary conditions 59 65 #------------------------------------------------------------------------------ 60 Bi = Dirichlet_boundary([0.4, 0, 0]) 61 Br = Reflective_boundary(domain) 62 Bo = Dirichlet_boundary([-5, 0, 0]) 66 Bi = Dirichlet_boundary([0.4, 0, 0]) # Inflow 67 Br = Reflective_boundary(domain) # Solid reflective wall 68 Bo = Dirichlet_boundary([-5, 0, 0]) # Outflow 63 69 64 70 domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
Note: See TracChangeset
for help on using the changeset viewer.