source: production/sydney_2006/run_sydney.py @ 2985

Last change on this file since 2985 was 2188, checked in by sexton, 19 years ago

update Sydney scenario to allow switching between clipping regions. BC = 10min square wave at 6m height on right hand boundary.

File size: 5.1 KB
Line 
1"""Script for running a tsunami inundation scenario for Sydney, NSW, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputdir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and boundary data obtained from a tsunami simulation done with MOST.
9
10Ole Nielsen, GA - 2005 and Jane Sexton, GA - 2006
11"""
12
13tide = 0       #Australian Height Datum (mean sea level)
14
15import os
16import time
17
18
19from pyvolution.shallow_water import Domain, Reflective_boundary, File_boundary,\
20     Dirichlet_boundary, Time_boundary, Transmissive_boundary
21from pyvolution.data_manager import convert_dem_from_ascii2netcdf,\
22     dem2pts
23from pyvolution.pmesh2domain import pmesh_to_domain_instance
24from caching import cache
25import project
26from math import pi, sin
27
28#Data preparation
29#Convert ASC 2 DEM 2 PTS using source data and store result in source data
30demname = project.demname
31meshname = project.meshname+'.msh'
32
33cache(convert_dem_from_ascii2netcdf, demname, {'verbose': True},
34      dependencies = [demname + '.asc'],
35      verbose = True)
36      #evaluate = True)
37
38cache(dem2pts, demname, {'verbose': True},
39      dependencies = [demname + '.dem'],     
40      verbose = True)
41
42#this allows the user to switch between different clipping polygons
43print 'Which total zone are you interested in?'
44mytest = int(raw_input('0 = all, 1 = harbour and 2 = botany bay     '))
45
46#Create Triangular Mesh
47from pmesh.create_mesh import create_mesh_from_regions
48
49if mytest == 0:
50    # for whole region
51    south = project.south
52    north = project.north
53    west = project.west
54    east = project.east
55
56    interior_regions = [[project.harbour_polygon, 25000],
57                        [project.botanybay_polygon, 25000]] # maximal area of per triangle
58                       
59    m = cache(create_mesh_from_regions,
60              project.polygonall,
61              {'boundary_tags': {'bottom': [0], 'top': [2],
62                                 'right': [1], 'left': [3]},
63               'resolution': 100000,
64               'filename': meshname,           
65               'interior_regions': interior_regions},
66              evaluate=True,   
67              verbose = True)
68    #import sys; sys.exit()
69
70if mytest == 1:
71    # for harbour region
72    south = project.hsouth
73    north = project.hnorth
74    west = project.hwest
75    east = project.heast
76
77    #interior_regions = [[project.harbour_polygon, 25000]] # maximal area of per triangle
78                       
79    m = cache(create_mesh_from_regions,
80              project.polygon_h,
81              {'boundary_tags': {'bottom': [0], 'top': [2],
82                                 'right': [1], 'left': [3]},
83               'resolution': 50000,
84               'filename': meshname},           
85     #          'interior_regions': interior_regions},
86              evaluate=True, 
87              verbose = True)
88
89if mytest == 2:
90    # for botany bay region
91    south = project.bsouth
92    north = project.bnorth
93    west = project.bwest
94    east = project.beast
95
96    #interior_regions = [[project.botanybay_polygon, 25000]] # maximal area of per triangle
97                       
98    m = cache(create_mesh_from_regions,
99              project.polygon_bb,
100              {'boundary_tags': {'bottom': [0], 'top': [2],
101                                 'right': [1], 'left': [3]},
102               'resolution': 50000,
103               'filename': meshname},
104     #          'interior_regions': interior_regions},
105              evaluate=True, 
106              verbose = True)
107   
108#Setup domain
109
110domain = cache(pmesh_to_domain_instance, (meshname, Domain),
111               dependencies = [meshname],                     
112               verbose = True)               
113
114
115domain.set_name(project.basename)
116domain.set_datadir(project.outputdir)
117domain.store = True
118
119#domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
120domain.quantities_to_be_stored = ['stage']
121       
122print 'Number of triangles = ', len(domain)
123print 'The extent is ', domain.get_extent()
124
125
126
127#Setup Initial Conditions
128domain.set_quantity('friction', 0)
129domain.set_quantity('stage', tide)
130domain.set_quantity('elevation',
131                    filename = demname + '.pts',
132                    use_cache = True,
133                    verbose = True)
134
135
136
137#Setup Boundary Conditions
138print domain.get_boundary_tags()
139
140Br = Reflective_boundary(domain)
141Bt = Transmissive_boundary(domain)
142Bd = Dirichlet_boundary([0,0,0])
143# 10 min square wave starting at 1 min, 6m high
144Bw = Time_boundary(domain=domain,
145                   f=lambda t: [(60<t<660)*6, 0, 0])
146
147
148domain.set_boundary( {'top': Br, 'bottom': Br, 'right': Bw, 'left': Br} )
149
150
151#Evolve
152import time
153t0 = time.time()
154
155for t in domain.evolve(yieldstep = 1, finaltime = 3600):
156    domain.write_time()
157    domain.write_boundary_statistics(tags = 'right') #quantities = 'stage')       
158
159print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.