Changeset 3511


Ignore:
Timestamp:
Aug 21, 2006, 1:17:30 PM (18 years ago)
Author:
ole
Message:

Grid on and snapshots as per request from Rosh.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/examples/runup_convergence.py

    r3508 r3511  
    2222from pyvolution.shallow_water import Transmissive_Momentum_Set_Stage_boundary
    2323from pyvolution.util import file_function
    24 from pylab import plot, xlabel, ylabel, title, ion, close, savefig, figure, axis
    25 ion()
     24from pylab import plot, xlabel, ylabel, title, ion, close, savefig, figure, axis, legend, grid, hold
     25
    2626
    2727
     
    9696
    9797def waveform(t):
    98     return sea_level + amplitude/cosh(t-5)**2
     98    return sea_level + amplitude/cosh(t-10)**2
    9999
    100100Bw = Time_boundary(domain=domain,     # Time dependent boundary 
     
    114114
    115115stagestep = []
    116 for t in domain.evolve(yieldstep = 1, finaltime = 100):
     116for t in domain.evolve(yieldstep = 1, finaltime = 150):
    117117    domain.write_time()
    118118
     
    126126def gauge_line(west,east,north,south):
    127127    from Numeric import arange
    128     x_vector = arange(west, (east-west)/2, 10) # Gauges every 1 meter from west to midpt
     128    x_vector = arange(west, east, dx/4) # Gauges every dx/2 meter from west to east
    129129    y = (north+south)/2.
    130130
     
    142142                  interpolation_points = gauges,
    143143                  verbose = True,
    144                   use_cache = True)
     144                  use_cache = False)
    145145
    146146
     
    171171
    172172# Print
    173 
    174173print 'wave height [m]:                    ', amplitude
    175174runup_height = topography(runup_point, (north+south)/2.)
     
    182181
    183182
     183# Take snapshots and plot
     184ion()
     185figure(1)
     186plot(x_vector, topography(x_vector,(north+south)/2.), 'r-')
     187xlabel('x')
     188ylabel('Elevation')
     189#legend(('Max stage', 'Min stage', 'Elevation'), shadow=True, loc='upper right')
     190title('Stage snapshots (t=0, 10, ...) for gauge line')
     191grid()
     192hold(True)
     193
     194for i, t in enumerate(f.get_time()):
     195    if i % 10 == 0:
     196        # Take only some timesteps to avoid clutter
     197        stages = []   
     198        for k, g in enumerate(gauges):
     199            w = f(t, point_id = k)[0]       
     200            stages.append(w)
     201
     202        plot(x_vector, stages, 'b-')
     203         
     204savefig('snapshots')
     205       
     206
     207
    184208
    185209# Store
    186210filename = 'maxrunup'+str(amplitude)+'.csv'
    187211fid = open(filename,'w')   
    188 s = 'Depth at eastern boundary,Waveheight,Runup distance,Runup height\n'
     212s = 'Waveheight,Runup distance,Runup height\n'
    189213fid.write(s)
    190214
     
    194218fid.close()
    195219
    196 # Plot
    197 figure(1)
     220
     221
     222
     223
     224# Plot max runup etc
     225ion()
     226hold(False)
     227figure(2)
    198228plot(x_vector, max_stage, 'g+',
    199229     x_vector, min_stage, 'b+',     
     
    201231xlabel('x')
    202232ylabel('stage')
     233legend(('Max stage', 'Min stage', 'Elevation'), shadow=True, loc='upper right')
    203234title('Maximum stage for gauge line')
     235grid()
    204236#axis([33000, 47000, -1000, 3000])
    205237savefig('max_stage')
Note: See TracChangeset for help on using the changeset viewer.