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