# Changeset 3753

Ignore:
Timestamp:
Oct 11, 2006, 3:58:53 PM (17 years ago)
Message:

Location:
anuga_core/documentation/user_manual/examples
Files:
3 edited

Unmodified
Removed
• ## anuga_core/documentation/user_manual/examples/channel_1.py

 r3747 dx = dy = 1           # Resolution: Length of subdivisions on both axes points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) domain = Domain(points, vertices, boundary)   # Create domain domain.set_name('channel_1')                  # Output name return -x/10                             # linear bed slope domain.set_quantity('elevation', topography)            # Use function for elevation domain.set_quantity('friction', 0.01)                   # Constant friction domain.set_quantity('stage', expression='elevation')    # Dry #domain.set_quantity('stage', expression='elevation + 0.1')    # Wet domain.set_quantity('elevation', topography) # Use function for elevation domain.set_quantity('friction', 0.01)        # Constant friction domain.set_quantity('stage', expression='elevation')        # Dry #domain.set_quantity('stage', expression='elevation + 0.1') # Wet # Setup boundary conditions #------------------------------------------------------------------------------ Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow Br = Reflective_boundary(domain)                                # Solid reflective wall Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow Br = Reflective_boundary(domain)             # Solid reflective wall domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
• ## anuga_core/documentation/user_manual/examples/channel_2.py

 r3747 """Simple water flow example using ANUGA Water flowing down a channel Water flowing down a channel with changing boundary conditions """ dx = dy = 1           # Resolution: Length of subdivisions on both axes points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) domain = Domain(points, vertices, boundary) domain.set_name('channel_2')                  # Output name domain.set_name('channel_2')                 # Output name return -x/10                             # linear bed slope domain.set_quantity('elevation', topography)            # Use function for elevation domain.set_quantity('friction', 0.01)                   # Constant friction domain.set_quantity('stage', expression='elevation')    # Dry domain.set_quantity('elevation', topography) # Use function for elevation domain.set_quantity('friction', 0.01)        # Constant friction domain.set_quantity('stage', expression='elevation')  # Dry initial condition # Setup boundary conditions #------------------------------------------------------------------------------ Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow Br = Reflective_boundary(domain)                                # Solid reflective wall Bo = Dirichlet_boundary([-5, 0, 0])                             # Outflow Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow Br = Reflective_boundary(domain)             # Solid reflective wall Bo = Dirichlet_boundary([-5, 0, 0])          # Outflow domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br}) domain.write_time() #print 'Stage(10,2.5) = ', domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) from Numeric import allclose #if allclose(t, 20): if domain.get_quantity('stage').get_values(interpolation_points=[[10, 2.5]]) > 0: print 'Stage > 0: Changing boundary' if domain.get_quantity('stage').\ get_values(interpolation_points=[[10, 2.5]]) > 0: print 'Stage > 0: Changing to outflow boundary' domain.modify_boundary({'right': Bo}) import sys; sys.exit() import time t0 = time.time() 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]])' import profile, pstats FN = 'profile.dat' profile.run(s, FN) print 'That took %.2f seconds' %(time.time()-t0) S = pstats.Stats(FN) #S.sort_stats('time').print_stats(20) s = S.sort_stats('cumulative').print_stats(30) print s
• ## anuga_core/documentation/user_manual/examples/channel_3.py

 r3747 """Simple water flow example using ANUGA Water flowing down a channel Water flowing down a channel with more complex topography """ width = 5. dx = dy = 1           # Resolution: Length of subdivisions on both axes #dx = dy = .1           # Resolution: Length of subdivisions on both axes points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width) domain = Domain(points, vertices, boundary) domain.set_name('channel_3')                  # Output name #------------------------------------------------------------------------------ def topography(x,y): z = -x/10                             # linear bed slope """Complex topography defined by a function of vectors x and y """ z = -x/10 N = len(x) domain.set_quantity('elevation', topography)            # Use function for elevation domain.set_quantity('friction', 0.01)                   # Constant friction domain.set_quantity('stage', expression='elevation')    # Dry domain.set_quantity('elevation', topography)  # Use function for elevation domain.set_quantity('friction', 0.01)         # Constant friction domain.set_quantity('stage', expression='elevation')   # Dry initial condition # Setup boundary conditions #------------------------------------------------------------------------------ Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow Br = Reflective_boundary(domain)                                # Solid reflective wall Bo = Dirichlet_boundary([-5, 0, 0])                             # Outflow Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow Br = Reflective_boundary(domain)              # Solid reflective wall Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
Note: See TracChangeset for help on using the changeset viewer.