source: development/momentum_sink/CCS.py @ 2417

Last change on this file since 2417 was 2417, checked in by nicholas, 19 years ago

Creation of looped friction to auto generate multiple friction blocks. CCS.py created as modified copy of PCS.py ( plots cross section at various times of buildings and friction blocks)

File size: 2.9 KB
Line 
1"""Read in sww file, interpolate at specified locations and
2    Cross section at specified T
3
4"""
5from os import sep
6import Numeric
7import project
8from pyvolution.util import file_function
9from create_buildings import porosity, WidtH
10# from run_friction import fric
11from pylab import *
12   
13
14swwfile_B = project.outputdir + sep  + 'friction_n=10_3135.sww'
15swwfile_F = project.outputdir + sep  + 'friction_n=20_3135.sww'
16
17gauge_depth = Numeric.arrayrange(0, 2.5*WidtH, 5)
18gauge_breadth = 100
19gauge_locations = []
20
21for GD in gauge_depth:
22    gauge_location = [GD,gauge_breadth]
23    gauge_locations.append(gauge_location)
24
25
26#Read model output
27quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum']
28
29f_B = file_function(swwfile_B,
30                  quantities = quantities,
31                  interpolation_points = gauge_locations,
32                  verbose = True,
33                  use_cache = True)
34
35f_F = file_function(swwfile_F,
36                  quantities = quantities,
37                  interpolation_points = gauge_locations,
38                  verbose = True,
39                  use_cache = True)
40
41
42T = Numeric.arrayrange(0,500,20)
43#T = [ 20, 50, 100, 150, 200 ]
44
45for t in T:
46    model_time = []
47    stages_B = []
48    stages_F = []
49    elevations = []
50    momenta = []
51    velocity = []
52    for i, GL in enumerate(gauge_depth):
53
54        # mines data from specified time values in sww file
55        wB = f_B(t, point_id = i)[0]
56        zB = f_B(t, point_id = i)[1]
57        uhB = f_B(t, point_id = i)[2]
58        vhB = f_B(t, point_id = i)[3]
59
60        wF = f_F(t, point_id = i)[0]       
61        uhF = f_B(t, point_id = i)[2]
62        vhF = f_B(t, point_id = i)[3]
63        #m = sqrt(uh*uh + vh*vh)   #Absolute momentum
64        velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity
65        velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity                   
66        #print velB, "buiding velocity"
67        #print velF, "friction velocity"
68
69        stages_B.append(wB)
70        stages_F.append(wF)
71        #elevations.append(zB)  #Should be constant over time
72        #momenta.append(mB)
73        #velocityB.append(velB)
74        #velocityF.append(velF)
75       
76    #print len(stages), "stages"
77    diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F))
78    #print diff, "difference"
79
80
81    ion()
82    hold(True)
83    subplot(211)
84   
85    plot(gauge_depth, stages_B, '-b',gauge_depth,stages_F,'-r')
86    title('Time_%d_ vs water depth (n=%f, BP=%f)' %(t, fric, porosity))
87    xlabel('gauge length(m)')
88    ylabel('water depths (m)')
89    #savefig('Comp_Time%d_B_vs_F' %t)
90    hold(False)
91#savefig('Final_comp_n=%s' %fric)
92subplot(212)
93subplots_adjust(hspace = 0.4)
94plot(gauge_depth, diff, 'g')
95title('Final Differences in water levels')
96xlabel('gauge length(m)')
97ylabel('water differences (m)')
98savefig('Final_Water_diff_n=%s' %fric)
99print "finished"
100
101
Note: See TracBrowser for help on using the repository browser.