source: production/merimbula_2005/run_new_meribula_weed.py @ 2622

Last change on this file since 2622 was 2622, checked in by steve, 18 years ago

Updated merimbula viewer

File size: 9.2 KB
Line 
1"""
2Main meribula script using new interface
3"""
4
5#-------------------------------
6# Module imports
7#-------------------------------
8import sys, os
9from pyvolution.shallow_water import Domain, Reflective_boundary,\
10     File_boundary, Transmissive_Momentum_Set_Stage_boundary,\
11     Wind_stress
12from pyvolution.util import file_function
13from pyvolution.mesh_factory import rectangular_cross
14from pyvolution.pmesh2domain import pmesh_to_domain_instance
15from utilities.polygon import Polygon_function, read_polygon
16from Numeric import array, zeros, Float, allclose
17import project
18from caching import cache
19
20
21
22
23#-------------------------------
24# Domain
25#-------------------------------
26print 'Creating domain from', project.mesh_filename
27
28domain = cache(pmesh_to_domain_instance,
29               (project.mesh_filename, Domain),
30               dependencies = [project.mesh_filename])
31
32domain.check_integrity()
33print 'Number of triangles = ', len(domain)
34print 'The extent is ', domain.get_extent()
35
36
37
38#-------------------------------
39# Initial Conditions
40#-------------------------------
41print 'Initial values'
42
43domain.set_quantity('elevation',
44                    filename = project.bathymetry_filename[:-4] + '.xya',
45                    alpha = 10.0,
46                    verbose = True,
47                    use_cache = True)
48
49domain.set_quantity('stage', 0.0)
50
51#-------------------------------
52# Setup Friction (due to weeds)
53#-------------------------------
54def image_points_to_northing_eastings(points):
55    #print points
56    n = len(points)
57    #print n
58    z = []
59    for i in range(n):
60        #print i
61        z.append([0,0])
62        z[i][0] = 755471.4 + (points[i][0] + 3250.)/1.125
63        z[i][1] = 5910260.0 + (points[i][1] + 1337.)/1.12
64    #print z
65    return z
66
67#------------------------------------------
68# Set friction for different bed types
69#------------------------------------------
70#   Sand bed
71w = 0.01
72#   Saltmarsh
73g = 0.060
74#   Paddle weed
75y = 0.025
76#   Eel grass
77r = 0.035
78#   Mangroves
79c = 0.065
80#   Strap weed
81b = 0.040
82
83#-----------------------------------------------
84#   Set the whole region to a constant value
85#-----------------------------------------------
86weed_zoneall = image_points_to_northing_eastings([[-2269,-1337],[1894,-1339],[1894,2946],[-2669,2946]])
87
88#---------------------------------------
89#       Read friction polygon boundaries
90#---------------------------------------
91weed_zone47 = image_points_to_northing_eastings(read_polygon('weed_zone.047',split=' '))
92weed_zone2   = image_points_to_northing_eastings(read_polygon('weed_zone.002',split=' '))
93weed_zone12  = image_points_to_northing_eastings(read_polygon('weed_zone.012',split=' '))
94weed_zone35  = image_points_to_northing_eastings(read_polygon('weed_zone.035',split=' '))
95weed_zone8   = image_points_to_northing_eastings(read_polygon('weed_zone.008',split=' '))
96weed_zone10  = image_points_to_northing_eastings(read_polygon('weed_zone.010',split=' '))
97weed_zone13  = image_points_to_northing_eastings(read_polygon('weed_zone.013',split=' '))
98weed_zone15  = image_points_to_northing_eastings(read_polygon('weed_zone.015',split=' '))
99weed_zone19  = image_points_to_northing_eastings(read_polygon('weed_zone.019',split=' '))
100weed_zone18  = image_points_to_northing_eastings(read_polygon('weed_zone.018',split=' '))
101weed_zone24  = image_points_to_northing_eastings(read_polygon('weed_zone.024',split=' '))
102weed_zone26  = image_points_to_northing_eastings(read_polygon('weed_zone.026',split=' '))
103weed_zone27  = image_points_to_northing_eastings(read_polygon('weed_zone.027',split=' '))
104weed_zone32  = image_points_to_northing_eastings(read_polygon('weed_zone.032',split=' '))
105weed_zone31  = image_points_to_northing_eastings(read_polygon('weed_zone.031',split=' '))
106weed_zone33  = image_points_to_northing_eastings(read_polygon('weed_zone.033',split=' '))
107weed_zone34  = image_points_to_northing_eastings(read_polygon('weed_zone.034',split=' '))
108weed_zone36  = image_points_to_northing_eastings(read_polygon('weed_zone.036',split=' '))
109weed_zone37  = image_points_to_northing_eastings(read_polygon('weed_zone.037',split=' '))
110weed_zone38  = image_points_to_northing_eastings(read_polygon('weed_zone.038',split=' '))
111weed_zone40  = image_points_to_northing_eastings(read_polygon('weed_zone.040',split=' '))
112weed_zone41  = image_points_to_northing_eastings(read_polygon('weed_zone.041',split=' '))
113weed_zone42  = image_points_to_northing_eastings(read_polygon('weed_zone.042',split=' '))
114weed_zone43  = image_points_to_northing_eastings(read_polygon('weed_zone.043',split=' '))
115weed_zone44  = image_points_to_northing_eastings(read_polygon('weed_zone.044',split=' '))
116weed_zone45  = image_points_to_northing_eastings(read_polygon('weed_zone.045',split=' '))
117weed_zone46  = image_points_to_northing_eastings(read_polygon('weed_zone.046',split=' '))
118weed_zone1   = image_points_to_northing_eastings(read_polygon('weed_zone.001',split=' '))
119weed_zone20  = image_points_to_northing_eastings(read_polygon('weed_zone.020',split=' '))
120weed_zone21  = image_points_to_northing_eastings(read_polygon('weed_zone.021',split=' '))
121weed_zone22  = image_points_to_northing_eastings(read_polygon('weed_zone.022',split=' '))
122weed_zone23  = image_points_to_northing_eastings(read_polygon('weed_zone.023',split=' '))
123weed_zone25  = image_points_to_northing_eastings(read_polygon('weed_zone.025',split=' '))
124weed_zone16  = image_points_to_northing_eastings(read_polygon('weed_zone.016',split=' '))
125weed_zone17  = image_points_to_northing_eastings(read_polygon('weed_zone.017',split=' '))
126weed_zone3   = image_points_to_northing_eastings(read_polygon('weed_zone.003',split=' '))
127weed_zone6   = image_points_to_northing_eastings(read_polygon('weed_zone.006',split=' '))
128weed_zone7   = image_points_to_northing_eastings(read_polygon('weed_zone.007',split=' '))
129weed_zone9   = image_points_to_northing_eastings(read_polygon('weed_zone.009',split=' '))
130weed_zone4   = image_points_to_northing_eastings(read_polygon('weed_zone.004',split=' '))
131weed_zone39  = image_points_to_northing_eastings(read_polygon('weed_zone.039',split=' '))
132weed_zone28  = image_points_to_northing_eastings(read_polygon('weed_zone.028',split=' '))
133weed_zone29  = image_points_to_northing_eastings(read_polygon('weed_zone.029',split=' '))
134weed_zone30  = image_points_to_northing_eastings(read_polygon('weed_zone.030',split=' '))
135weed_zone5   = image_points_to_northing_eastings(read_polygon('weed_zone.005',split=' '))
136weed_zone11  = image_points_to_northing_eastings(read_polygon('weed_zone.011',split=' '))
137weed_zone14  = image_points_to_northing_eastings(read_polygon('weed_zone.014',split=' '))
138
139domain.set_quantity('friction',Polygon_function([  \
140    (weed_zone15,  g), (weed_zone19, c), (weed_zone18, g), (weed_zone24, c), \
141      (weed_zone26,  r), (weed_zone27, g), (weed_zone32, c), (weed_zone31, g), \
142      (weed_zone33,  r), (weed_zone34, g), (weed_zone36, r), (weed_zone37, g), \
143      (weed_zone38,  g), (weed_zone40, r), (weed_zone41, b), (weed_zone42, r), \
144      (weed_zone43,  r), (weed_zone44, r), (weed_zone45, b), (weed_zone46, r), \
145      (weed_zone1,   w), (weed_zone20, w), (weed_zone21, w), (weed_zone22, w), \
146      (weed_zone23,  w), (weed_zone25, w), (weed_zone16, w), (weed_zone17, w), \
147      (weed_zone3,   w), (weed_zone6,  w), (weed_zone7,  w), (weed_zone9,  w), \
148      (weed_zone4,   b), (weed_zone39, b), (weed_zone28, r), (weed_zone29, b), \
149      (weed_zone30,  b), (weed_zone5,  b), (weed_zone11, b), (weed_zone14, b) ]))
150
151
152#---------------------------------------------
153# Wind field
154# Format is time [DD/MM/YY hh:mm:ss], speed [m/s] direction (degrees)
155# This method is linearly interpolating the bearings and so will lead to
156# close to bearing = 0 and 360!
157#---------------------------------------------
158filename = project.original_wind_filename[:-4]+'.tms'
159print 'Wind field from ',filename
160wind = file_function(filename, domain=domain, quantities=['speed','bearing'])
161domain.forcing_terms.append(Wind_stress(wind))
162
163
164
165#-------------------------------
166# Boundary conditions
167#-------------------------------
168print 'Boundaries'
169
170#   Tidal cycle recorded at Eden as open
171print 'Open sea boundary condition from ',project.boundary_filename
172from pyvolution.util import file_function
173tide_function = file_function(project.boundary_filename[:-4] + '.tms', domain,
174                         verbose = True)
175Bts = Transmissive_Momentum_Set_Stage_boundary(domain, tide_function)
176
177#   All other boundaries are reflective
178Br = Reflective_boundary(domain)
179
180domain.set_boundary({'exterior': Br, 'open': Bts})
181
182#-------------------------------
183# Setup domain runtime parameters
184#-------------------------------
185domain.visualise = False
186domain.visualise_color_stage = True
187
188base = os.path.basename(sys.argv[0])
189domain.filename, _ = os.path.splitext(base)
190domain.default_order = 2
191domain.store = True    #Store for visualisation purposes
192
193
194
195#-------------------------------
196# Evolve
197#-------------------------------
198import time
199t0 = time.time()
200yieldstep = 10
201finaltime = 60
202
203
204for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime):
205    domain.write_time()
206    print wind(t)
207
208print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.