source: trunk/anuga_work/development/gareth/tests/parabolic/parabolaplot.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: 2.5 KB
Line 
1"""View results of runup.py
2"""
3#---------------
4# Import Modules
5#---------------
6import anuga
7#import struct
8import numpy
9#import scipy
10from matplotlib import pyplot as pyplot
11import util
12
13p=util.get_output('parabola_v2.sww', 0.01)
14p2=util.get_centroids(p, velocity_extrapolation=True)
15
16# Define some 'lines' along which to plot
17v=(p2.y==p2.y[0])
18
19#--------------------
20# Make plot animation
21#--------------------
22pyplot.close() #If the plot is open, there will be problems
23pyplot.ion()
24
25if False:
26    line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,(p2.stage[:,v].min(),p2.stage[:,v].max() ) )
27    for i in range(700,p2.xmom.shape[0]):
28        line.set_xdata(p2.x[v])
29        line.set_ydata(p2.stage[i,v])
30        pyplot.draw()
31        #pyplot.plot( (0,1),(0,0), 'r' )
32        pyplot.plot(p2.x[v],p2.elev[v]) 
33        pyplot.title(str(i)+'/200') # : velocity does not converge to zero' )
34        pyplot.xlabel('x')
35        pyplot.ylabel('stage (m/s)')
36
37if False:
38    pyplot.clf()
39 
40    line, = pyplot.plot( (p2.x[v].min(),p2.x[v].max()) ,(p2.xvel[:,v].min(),p2.xvel[:,v].max() ), 'ro' )
41    for i in range(700,p2.xmom.shape[0]):
42        line.set_xdata(p2.x[v])
43        line.set_ydata(p2.xvel[i,v])
44        pyplot.draw()
45        pyplot.plot( (p2.x[v].min(),p2.x[v].max()),(0,0), 'ro' )
46        #pyplot.plot(x[v],elev[v])
47        pyplot.title(str(i)+'/200') # : velocity does not converge to zero' )
48        pyplot.xlabel('x')
49        pyplot.ylabel('xvel (m/s)')
50
51D0=4.0
52L=10.0
53A=2.0
54g=9.8
55#t=time[30]
56
57omega=numpy.sqrt(2*D0*g)/L
58T= 2*numpy.pi/omega
59ppp= (abs(p2.x-4.*L/2.)).argmin()
60ppp2= (abs(p2.x-4.*L/4.)).argmin()
61
62w = D0 + 2*A*D0/(L**2)*numpy.cos(omega*p2.time)*( (p2.x[ppp]-4.*L/2.) -A/2.*numpy.cos(omega*p2.time))
63w2 = D0 + 2*A*D0/(L**2)*numpy.cos(omega*p2.time)*( (p2.x[ppp2]-4.*L/2.) -A/2.*numpy.cos(omega*p2.time))
64w2 = w2*(w2>p2.elev[ppp2])+p2.elev[ppp2]*(w2<=p2.elev[ppp2])
65
66pyplot.clf()
67pyplot.plot(p2.time,w, color='blue')
68pyplot.plot(p2.time,p2.stage[:,ppp], color='green')
69pyplot.savefig('Stage_centre_v2.png')
70#       pyplot.savefig('runup_x_velocities.png')
71pyplot.clf()
72pyplot.plot(p2.time,w2, color='blue')
73pyplot.plot(p2.time,p2.stage[:,ppp2], color='green')
74pyplot.savefig('Stage_centre_v3.png')
75
76
77pltind=numpy.argmin(abs(p2.time-T*3))
78
79pyplot.clf()
80pyplot.plot(p2.x[v],p2.xvel[pltind,v])
81pyplot.title('Velocity near to time=3T')
82pyplot.savefig('Vel_3T_v2.png')
83
84pltind=numpy.argmin(abs(p2.time-T*3.25))
85
86pyplot.clf()
87pyplot.plot(p2.x[v],p2.xvel[pltind,v])
88pyplot.title('Velocity near to time=3.25T')
89pyplot.savefig('Vel_3_5T_v2.png')
90#pyplot.clf()
91#pyplot.close()
Note: See TracBrowser for help on using the repository browser.