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