source: trunk/anuga_work/development/gareth/tests/runup/runuplot.py @ 8375

Last change on this file since 8375 was 8353, checked in by davies, 13 years ago

Updates to balanced_dev and associated tests

File size: 4.3 KB
Line 
1"""View results of runup.py
2"""
3#---------------
4# Import Modules
5#---------------
6import anuga
7import numpy
8import scipy
9from matplotlib import pyplot as pyplot
10import util # Routines to read in and work with ANUGA output
11
12p2=util.get_output('runup_v2.sww', minimum_allowed_height=1.0e-03)
13p=util.get_centroids(p2, velocity_extrapolation=True)
14
15#p=util.get_output('runup_v2.sww', minimum_allowed_height=1.0e-03)
16
17#------------------
18# Select line
19#------------------
20py_central=p.y[scipy.argmin(abs(p.y-0.5))]
21v=(p.y==p.y[py_central])
22
23#--------------------
24# Make plot animation
25#--------------------
26pyplot.close() #If the plot is open, there will be problems
27pyplot.ion()
28
29if True:
30    line, = pyplot.plot( (p.x[v].min(),p.x[v].max()) ,(p.xvel[:,v].min(),p.xvel[:,v].max() ) )
31    for i in range(p.xmom.shape[0]):
32        line.set_xdata(p.x[v])
33        line.set_ydata(p.xvel[i,v])
34        pyplot.draw()
35        pyplot.plot( (0,1),(0,0), 'r' )
36        pyplot.title(str(i)+'/200') # : velocity does not converge to zero' )
37        pyplot.xlabel('x')
38        pyplot.ylabel('Velocity (m/s)')
39
40    pyplot.savefig('runup_x_velocities.png')
41
42#pyplot.clf()
43#pyplot.close()
44
45#------------------------------------------------
46# Maximum y velocities -- occurs in output step 3
47#------------------------------------------------
48#print yvel[3,:].max(), yvel[3,:].min()
49#highx=yvel[3,:].argmax()
50#v=(x==x[highx])
51#pyplot.plot(yvel[3,v])
52#pyplot.title('y-velocity is not always zero at the boundaries, e.g. x='+str(x[highx])+' , t=0.3s')
53#pyplot.xlabel('y')
54#pyplot.ylabel('Velocity (m/s)')
55#pyplot.savefig('runup_y_velocities.png')
56
57pyplot.clf()
58pyplot.plot(p.x[v],p.stage[5,v])
59pyplot.plot(p.x[v],p.stage[5,v],'o')
60pyplot.plot(p.x[v],p.elev[v])
61pyplot.xlabel('x (m)')
62pyplot.ylabel('z (m)')
63pyplot.title('Free surface and bed at y==0.5, time = 1.0 second')
64pyplot.savefig('elev_1s_v2.png')
65
66pyplot.clf()
67pyplot.plot(p.x[v],p.xvel[5,v])
68pyplot.plot(p.x[v],p.xvel[5,v],'o')
69pyplot.title('Velocity at y==0.500, time = 1.0 second')
70pyplot.xlabel('x (m)')
71pyplot.ylabel('Velocity (m/s)')
72pyplot.savefig('vel1d_1s_v2.png')
73
74#pyplot.clf()
75#pyplot.plot(x_cent[y_cent==y_cent[80]],xvel_cent[15,y_cent==y_cent[80]])
76#pyplot.plot(x_cent[y_cent==y_cent[80]],xvel_cent[15,y_cent==y_cent[80]],'o')
77#pyplot.title('Velocity at y==0.500, time = 3.0 second')
78#pyplot.xlabel('x (m)')
79#pyplot.ylabel('Velocity (m/s)')
80#pyplot.savefig('vel1d_3s_v2.png')
81#-------------------------------------
82# Final velocities plot
83#-------------------------------------
84#pyplot.clf()
85#pyplot.quiver(x,y,xvel[200,:],yvel[200,:])
86#pyplot.xlabel('x')
87#pyplot.ylabel('y')
88#pyplot.title('The maximum speed is '+ str(vel[200,:].max()) + ' m/s')
89#pyplot.savefig('final_vel_field.png')
90#print vel[200,:].max()
91
92pyplot.clf()
93pyplot.scatter(p.x,p.y,c=p.elev,edgecolors='none', s=25)
94pyplot.colorbar()
95#pyplot.quiver(x_cent,y_cent,xvel_cent[15,:],yvel_cent[15,:])
96#pyplot.title('The maximum speed is '+ str(vel_cent[15,:].max()) + ' m/s at time 3.0s')
97pyplot.quiver(p.x,p.y,p.xvel[5,:],p.yvel[5,:])
98pyplot.title('The maximum speed is '+ str(p.vel[5,:].max()) + ' m/s at time 1.0s')
99pyplot.savefig('vel_1s_v2.png')
100
101pyplot.clf()
102pyplot.scatter(p.x,p.y,c=p.elev,edgecolors='none', s=25)
103pyplot.colorbar()
104#pyplot.quiver(x_cent,y_cent,xvel_cent[150,:],yvel_cent[150,:])
105#pyplot.title('The maximum speed is '+ str(vel_cent[150,:].max()) + ' m/s at time 30.0s')
106pyplot.quiver(p.x,p.y,p.xvel[150,:],p.yvel[150,:])
107pyplot.title('The maximum speed is '+ str(p.vel[150,:].max()) + ' m/s at time 30.0s')
108pyplot.savefig('vel_30s_v2.png')
109
110pyplot.clf()
111pyplot.plot(p.x[v],p.stage[150,v])
112pyplot.plot(p.x[v],p.stage[150,v],'o')
113pyplot.plot(p.x[v],p.elev[v])
114pyplot.xlabel('x (m)')
115pyplot.ylabel('z (m)')
116pyplot.title('Free surface and bed at y==0.5, time = 30.0 second')
117pyplot.savefig('elev_30s_v2.png')
118pyplot.clf()
119pyplot.plot(p.x[v],p.xvel[150,v])
120pyplot.plot(p.x[v],p.xvel[150,v],'o')
121pyplot.title('Velocity at y==0.500, time = 30.0 second')
122pyplot.xlabel('x (m)')
123pyplot.ylabel('Velocity (m/s)')
124pyplot.savefig('vel1d_30s_v2.png')
125#pyplot.clf()
126#pyplot.plot(x_cent[y_cent==y_cent[80]],xvel_cent[150,y_cent==y_cent[80]])
127#pyplot.plot(x_cent[y_cent==y_cent[80]],xvel_cent[150,y_cent==y_cent[80]],'o')
128#pyplot.title('Velocity at y==0.500, time = 30.0 second')
129#pyplot.xlabel('x (m)')
130#pyplot.ylabel('Velocity (m/s)')
131#pyplot.savefig('vel1d_30s_v2.png')
Note: See TracBrowser for help on using the repository browser.