source: anuga_work/development/momentum_sink/scripts/PCS.py @ 6985

Last change on this file since 6985 was 3514, checked in by duncan, 19 years ago

Hi all,
I'm doing a change in the anuga structure, moving the code to

\anuga_core\source\anuga

After you have done an svn update, the PYTHONPATH has to be changed to;
PYTHONPATH = anuga_core/source/

This is part of changes required to make installation of anuga quicker and reducing the size of our sandpits.

If any imports are broken, try fixing them. With adding anuga. to them for example. If this seems to have really broken things, email/phone me.

Cheers
Duncan

File size: 3.6 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 anuga.pyvolution.util import file_function
9from create_buildings import  WidtH
10# from run_friction import fric
11from pylab import *
12
13fric = 'mid_limit_0'    # FILE LABEL
14#swwfile = project.newoutputname + '.sww'
15#swwfile = project.outputname
16
17#swwfile_B = project.outputdir + sep  + 'Buildings_3790.sww'
18swwfile_B = project.outputdir + sep  + 'buildings_Str_D=5.8_976.sww'
19#swwfile_F = project.outputdir + sep  + 'buildings_Str_half_Off_D=6.89_1116.sww'
20#swwfile_B = project.outputdir + sep  + 'friction_n=6_3135.sww'
21swwfile_F = project.outputdir + sep  + 'friction_n=0.9_3135.sww'
22
23# gauge_depth = Numeric.arrayrange(51, 1.5*WidtH, 25) # Random special
24
25#gauge_depth = Numeric.arrayrange(0, 5*WidtH, 5)
26gauge_depth = [49.600000000000001, 74.6, 99.6, 124.6, 149.6, 174.6, 199.6, 224.6, 240.00999999999999]
27
28gauge_breadth = 100
29gauge_locations = []
30
31for GD in gauge_depth:
32    gauge_location = [GD,gauge_breadth]
33    gauge_locations.append(gauge_location)
34
35
36#Read model output
37quantities = ['stage', 'xmomentum', 'ymomentum']
38
39f_B = file_function(swwfile_B,
40                  quantities = quantities,
41                  interpolation_points = gauge_locations,
42                  verbose = True,
43                  use_cache = False)
44
45f_F = file_function(swwfile_F,
46                  quantities = quantities,
47                  interpolation_points = gauge_locations,
48                  verbose = True,
49                  use_cache = False)
50
51
52T = Numeric.arrayrange(700,1000,10)
53#T = [ 20, 50, 100, 150, 200 ]
54
55for t in T:
56    model_time = []
57    stages_B = []
58    stages_F = []
59    elevations = []
60    momenta = []
61    velocity = []
62    for i, GL in enumerate(gauge_depth):
63
64        # mines data from specified time values in sww file
65        wB = f_B(t, point_id = i)[0]
66        uhB = f_B(t, point_id = i)[1]
67        vhB = f_B(t, point_id = i)[2]
68
69        wF = f_F(t, point_id = i)[0]       
70        uhF = f_B(t, point_id = i)[1]
71        vhF = f_B(t, point_id = i)[2]
72        #m = sqrt(uh*uh + vh*vh)   #Absolute momentum
73        velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity
74        velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity                   
75        #print velB, "buiding velocity"
76        #print velF, "friction velocity"
77
78        stages_B.append(wB)
79        stages_F.append(wF)
80        #elevations.append(zB)  #Should be constant over time
81        #momenta.append(mB)
82        #velocityB.append(velB)
83        #velocityF.append(velF)
84       
85    #print len(stages), "stages"
86    diff = abs(Numeric.array(stages_B) - Numeric.array(stages_F))
87    #print diff, "difference"
88   
89
90    ion()
91    hold(True)
92    subplot(211)
93   
94    plot(gauge_depth, stages_B, '-b',gauge_depth,stages_F,'-r')
95    title('Stage@Time_%d_ vs Gauge length (m)[red: fric, blue: buildings] ' %t)
96    xlabel('gauge length(m)')
97    ylabel('water depths (m)')
98    #savefig('Comp_Time%d_B_vs_F' %t)
99    hold(False)
100
101print stages_F, " stages"
102print gauge_depth, " gauge depths"
103diff_area_F = trapz(gauge_depth,stages_F)
104diff_area_B = trapz(gauge_depth,stages_B)
105diff_area = abs(diff_area_F) - abs(diff_area_B)
106print diff_area, " <<< diff area*********"
107#savefig('Final_comp_n=%s' %fric)
108subplot(212)
109subplots_adjust(hspace = 0.4)
110plot(gauge_depth, diff, 'g')
111title('Final Differences in water levels')
112xlabel('gauge length(m)')
113ylabel('water differences (m)')
114savefig('Final_Water_diff_n=%s' %fric)
115print "finished"
116
117
Note: See TracBrowser for help on using the repository browser.