Changeset 3223


Ignore:
Timestamp:
Jun 24, 2006, 4:34:26 PM (18 years ago)
Author:
sexton
Message:

update for year10 student-

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentation/user_manual/examples/runuptest.py

    r3197 r3223  
    1717from pyvolution.shallow_water import Transmissive_boundary
    1818
    19 N = 10000.0
    2019waveheight = 1.0
    2120#------------------------------------------------------------------------------
     
    2322#------------------------------------------------------------------------------
    2423
    25 polygon = [[N,N],[-N,N],[-N,-N],[N,-N]]
    26 #polygon = [[N,N],[0,N],[0,0],[N,0]]
     24west = 340000.
     25east = 380000.
     26south = 6265000.
     27north = 6250000.
     28polygon = [[east,north],[west,north],[west,south],[east,south]]
    2729meshname = 'test.msh'
    28 #interior_regions =
     30
    2931create_mesh_from_regions(polygon,
    3032                         boundary_tags={'top': [0],
     
    3739
    3840domain = Domain(meshname,use_cache=True,verbose = True)
    39 domain.set_name('bedslope')                 # Output to bedslope.sww
     41domain.set_name('test')                     # Output to test.sww
    4042domain.set_datadir('.')                     # Use current directory for output
    4143domain.set_quantities_to_be_stored(['stage',# Store all conserved quantities
     
    4951
    5052def topography(x,y):
    51     return -x/2                              # linear bed slope
    52     #return x*(-(2.0-x)*.5)                  # curved bed slope
     53    slope = -1./400.
     54    c = 850.0
     55    return slope*x+c                              # linear bed slope
    5356
    5457domain.set_quantity('elevation', topography) # Use function for elevation
    55 domain.set_quantity('friction', 0.1)         # Constant friction
    56 #domain.set_quantity('stage', -.4)            # Constant negative initial stage
    57 domain.set_quantity('stage', -N/2)            # Constant negative initial stage
     58domain.set_quantity('friction', 0. )         # Constant friction
     59domain.set_quantity('stage', 0.0)            # Constant initial stage
    5860
    5961#------------------------------------------------------------------------------
     
    6466Br = Reflective_boundary(domain)      # Solid reflective wall
    6567Bt = Transmissive_boundary(domain)    # Continue all values on boundary
    66 Bd = Dirichlet_boundary([-N/2.,0.,0.]) # Constant boundary values
     68Bd = Dirichlet_boundary([0.,0.,0.])  # Constant boundary values
    6769Bw = Time_boundary(domain=domain,     # Time dependent boundary 
    68                    f=lambda t: [((1<t<2)*waveheight), 0.0, 0.0])
     70                   f=lambda t: [((10<t<20)*waveheight), 0.0, 0.0])
    6971
    7072# Associate boundary tags with boundary objects
     
    7779
    7880stagestep = []
    79 filename = 'runupheight%.2f.csv' %waveheight
    80 fid = open(filename, 'w')
    8181for t in domain.evolve(yieldstep = 10, finaltime = 100.0):
    8282    domain.write_time()
    83     thisstagestep = domain.get_quantity('stage')
    84     stagestep.append(max(max(thisstagestep.get_values())))
    8583
    86 s = '%.2f, %.2f\n' %(waveheight, max(stagestep))
     84# Gauge line
     85def gauge_line(west,east,north,south):
     86    from Numeric import arange
     87    gaugex = arange(west,east,1000.)
     88    gauges = []
     89    for x in gaugex:
     90        y = (north+south)/2.
     91        gauges.append([x,y])
     92    return gauges
     93
     94#-----------------------------------------------------------------------------
     95# Interrogate solution
     96#-----------------------------------------------------------------------------
     97
     98gauges = gauge_line(west,east,north,south)
     99
     100f = file_function(gauges)
     101minw = 10000.0
     102theminw = minw
     103minws = []
     104for k, g in enumerate(gauges):
     105    for i, t in enumerate(f.get_time()):
     106         if w < minw: minw = w
     107    minws.append(minw)
     108    if theminw < minw:
     109       theminw = minw
     110       gaugeloc = k
     111
     112filename = 'maxrunup'+waveheight+'.csv'
     113fid = open(filename,'w')   
     114s = 'Waveheight,Runup distance,Runup height\n'
    87115fid.write(s)
     116gaugestar = gauges[gaugeloc]
     117s = '%.2f, %.2f/n' %(waveheight,gaugestar[0],gaugestar[1])
     118fid.write(s)
     119
     120from pylab import plot, xlabel, ylabel, title
     121plot(gaugex,minws,'g-',gaugestar[0],gaugestar[1],'r*')
     122xlabel('x')
     123ylabel('stage')
     124title('Minimum stage for gauge line')
Note: See TracChangeset for help on using the changeset viewer.