Changeset 3753


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

Updates

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  
    2020dx = dy = 1           # Resolution: Length of subdivisions on both axes
    2121
    22 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width)
     22points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     23                                               len1=length, len2=width)
     24
    2325domain = Domain(points, vertices, boundary)   # Create domain
    2426domain.set_name('channel_1')                  # Output name
     
    3133    return -x/10                             # linear bed slope
    3234
    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
     35domain.set_quantity('elevation', topography) # Use function for elevation
     36domain.set_quantity('friction', 0.01)        # Constant friction
     37domain.set_quantity('stage',
     38                    expression='elevation')        # Dry
     39#domain.set_quantity('stage',
     40                     expression='elevation + 0.1') # Wet
    3741
    3842
     
    4044# Setup boundary conditions
    4145#------------------------------------------------------------------------------
    42 Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow
    43 Br = Reflective_boundary(domain)                                # Solid reflective wall
     46Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow
     47Br = Reflective_boundary(domain)             # Solid reflective wall
    4448
    4549domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
  • anuga_core/documentation/user_manual/examples/channel_2.py

    r3747 r3753  
    11"""Simple water flow example using ANUGA
    22
    3 Water flowing down a channel
     3Water flowing down a channel with changing boundary conditions
    44"""
    55
     
    2121dx = dy = 1           # Resolution: Length of subdivisions on both axes
    2222
    23 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width)
     23points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     24                                               len1=length, len2=width)
    2425domain = Domain(points, vertices, boundary)   
    25 domain.set_name('channel_2')                  # Output name
     26domain.set_name('channel_2')                 # Output name
    2627
    2728
     
    3233    return -x/10                             # linear bed slope
    3334
    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
     35domain.set_quantity('elevation', topography) # Use function for elevation
     36domain.set_quantity('friction', 0.01)        # Constant friction
     37domain.set_quantity('stage',
     38                    expression='elevation')  # Dry initial condition
    3739
    3840
     
    4042# Setup boundary conditions
    4143#------------------------------------------------------------------------------
    42 Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow
    43 Br = Reflective_boundary(domain)                                # Solid reflective wall
    44 Bo = Dirichlet_boundary([-5, 0, 0])                             # Outflow
     44Bi = Dirichlet_boundary([0.4, 0, 0])         # Inflow
     45Br = Reflective_boundary(domain)             # Solid reflective wall
     46Bo = Dirichlet_boundary([-5, 0, 0])          # Outflow
    4547
    4648domain.set_boundary({'left': Bi, 'right': Br, 'top': Br, 'bottom': Br})
     
    5355    domain.write_time()
    5456
    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'
    6160        domain.modify_boundary({'right': Bo})
    6261
    6362
    64 import sys; sys.exit()
    65 
    66 import time
    67 t0 = time.time()
    6863
    6964
    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, pstats
    73 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 s
    84 
  • anuga_core/documentation/user_manual/examples/channel_3.py

    r3747 r3753  
    11"""Simple water flow example using ANUGA
    22
    3 Water flowing down a channel
     3Water flowing down a channel with more complex topography
    44"""
    55
     
    2020width = 5.
    2121dx = dy = 1           # Resolution: Length of subdivisions on both axes
     22#dx = dy = .1           # Resolution: Length of subdivisions on both axes
    2223
    23 points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy), len1=length, len2=width)
     24points, vertices, boundary = rectangular_cross(int(length/dx), int(width/dy),
     25                                               len1=length, len2=width)
    2426domain = Domain(points, vertices, boundary)   
    2527domain.set_name('channel_3')                  # Output name
     
    3032#------------------------------------------------------------------------------
    3133def 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                               
    3338
    3439    N = len(x)
     
    5055
    5156
    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
     57domain.set_quantity('elevation', topography)  # Use function for elevation
     58domain.set_quantity('friction', 0.01)         # Constant friction
     59domain.set_quantity('stage',
     60                    expression='elevation')   # Dry initial condition
    5561
    5662
     
    5864# Setup boundary conditions
    5965#------------------------------------------------------------------------------
    60 Bi = Dirichlet_boundary([0.4, 0, 0])                            # Inflow
    61 Br = Reflective_boundary(domain)                                # Solid reflective wall
    62 Bo = Dirichlet_boundary([-5, 0, 0])                             # Outflow
     66Bi = Dirichlet_boundary([0.4, 0, 0])          # Inflow
     67Br = Reflective_boundary(domain)              # Solid reflective wall
     68Bo = Dirichlet_boundary([-5, 0, 0])           # Outflow
    6369
    6470domain.set_boundary({'left': Bi, 'right': Bo, 'top': Br, 'bottom': Br})
Note: See TracChangeset for help on using the changeset viewer.