source: production/sydney_2006/run_sydney_smf.py @ 2763

Last change on this file since 2763 was 2640, checked in by sexton, 19 years ago

Update Sydney example post Benfield visit (30 March 2006) to mimic changes from island.py

File size: 7.5 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 a simulated submarine landslide.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Adrian Hitchman and Jane Sexton, GA - 2006
11"""
12
13
14#-------------------------------------------------------------------------------# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20
21# Related major packages
22from pyvolution.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
23from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
24#from pyvolution.data_manager_old import convert_dem_from_ascii2netcdf, dem2pts
25from pyvolution.combine_pts import combine_rectangular_points_files
26from pyvolution.pmesh2domain import pmesh_to_domain_instance
27from pyvolution.quantity import Quantity
28from Numeric import allclose
29
30# Application specific imports
31import project                 # Definition of file names and polygons
32from pyvolution.smf import slump_tsunami  # Function for submarine mudslide
33
34
35#-------------------------------------------------------------------------------
36# Preparation of topographic data
37#
38# Convert ASC 2 DEM 2 PTS using source data and store result in source data
39# Do for coarse and fine data
40# Fine pts file to be clipped to area of interest
41#-------------------------------------------------------------------------------
42
43# filenames
44coarsedemname = project.coarsedemname
45finedemname = project.finedemname
46meshname = project.meshname+'.msh'
47
48# coarse data
49convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True)
50dem2pts(coarsedemname, use_cache=True, verbose=True)
51
52# fine data (clipping the points file to smaller area)
53convert_dem_from_ascii2netcdf(finedemname, use_cache=True, verbose=True)
54dem2pts(finedemname,
55        easting_min=project.eastingmin,
56        easting_max=project.eastingmax,
57        northing_min=project.northingmin,
58        northing_max= project.northingmax,
59        use_cache=True, 
60        verbose=True)
61
62# combining the coarse and fine data
63combine_rectangular_points_files(project.finedemname + '.pts',
64                                 project.coarsedemname + '.pts',
65                                 project.combineddemname + '.pts')
66
67#from pmesh.create_mesh import create_mesh_from_regions
68#new interface
69from pmesh.mesh_interface import create_mesh_from_regions
70
71# original issue to Benfield
72#interior_res = 5000
73#interior_regions = [[project.harbour_polygon_2, interior_res],
74#                    [project.botanybay_polygon_2, interior_res]]
75
76# used for finer mesh
77interior_res1 = 5000
78interior_res2 = 315
79interior_regions = [[project.newpoly1, interior_res1],
80                    [project.south1, interior_res1],
81                    [project.finepolymanly, interior_res2],
82                    [project.finepolyquay, interior_res2]]
83
84print 'number of interior regions', len(interior_regions)
85
86#FIXME: Fix caching of this one once the mesh_interface is ready
87from caching import cache
88
89# original + refined region
90_ = cache(create_mesh_from_regions,
91          project.diffpolygonall,
92          {'boundary_tags': {'bottom': [0], 
93                             'right1': [1], 'right0': [2],
94                             'right2': [3], 'top': [4], 'left1': [5],
95                             'left2': [6], 'left3': [7]},
96           'maximum_triangle_area': 100000,
97           'filename': meshname,           
98           'interior_regions': interior_regions},
99          verbose = True)
100
101#-------------------------------------------------------------------------------                                 
102# Setup computational domain
103#-------------------------------------------------------------------------------                                 
104
105domain = pmesh_to_domain_instance(meshname, Domain,
106                                  use_cache = True,
107                                  verbose = True)
108
109print 'Number of triangles = ', len(domain)
110print 'The extent is ', domain.get_extent()
111print domain.statistics()
112
113domain.set_name(project.basename)
114domain.set_datadir(project.outputdir)
115domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
116
117
118#-------------------------------------------------------------------------------
119# Set up scenario (tsunami_source is a callable object used with set_quantity)
120#-------------------------------------------------------------------------------
121
122tsunami_source = slump_tsunami(length=30000.0,
123                               depth=400.0,
124                               slope=6.0,
125                               thickness=176.0, 
126                               radius=3330,
127                               dphi=0.23,
128                               x0=project.slump_origin[0], 
129                               y0=project.slump_origin[1], 
130                               alpha=0.0, 
131                               domain=domain)
132
133
134#-------------------------------------------------------------------------------                                 
135# Setup initial conditions
136#-------------------------------------------------------------------------------
137
138# apply slump after 30 mins, initialise to water level of tide = 0
139domain.set_quantity('stage', 0.0)
140domain.set_quantity('friction', 0.03) 
141domain.set_quantity('elevation',
142                    filename = project.combineddemname + '.pts',
143                    use_cache = True,
144                    verbose = True)
145
146
147#-------------------------------------------------------------------------------                                 
148# Setup boundary conditions (all reflective)
149#-------------------------------------------------------------------------------
150
151print 'Available boundary tags', domain.get_boundary_tags()
152
153Br = Reflective_boundary(domain)
154Bd = Dirichlet_boundary([0, 0, 0])
155
156# original + refined regions
157#domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
158#                      'right2': Br, 'top': Br, 'left1': Br,
159#                      'left2': Br, 'left3': Br} )
160
161# enforce Dirichlet BC - from 30/03/06 Benfield visit
162domain.set_boundary( {'bottom': Bd, 'right1': Bd, 'right0': Bd,
163                      'right2': Bd, 'top': Bd, 'left1': Bd,
164                      'left2': Bd, 'left3': Bd} )
165
166# increasingly finer interior regions
167#domain.set_boundary( {'bottom': Br, 'right': Br, 'left': Br, 'top': Br} )
168
169
170#-------------------------------------------------------------------------------                                 
171# Evolve system through time
172#-------------------------------------------------------------------------------
173
174import time
175t0 = time.time()
176thisfile = project.integraltimeseries+'.csv'
177fid = open(thisfile, 'w')
178
179for t in domain.evolve(yieldstep = 120, finaltime = 18000):
180    domain.write_time()
181    domain.write_boundary_statistics(tags = 'bottom')
182
183    # calculate integral
184    thisstagestep = domain.get_quantity('stage') 
185    s = '%.2f, %.2f\n' %(t, thisstagestep.get_integral())
186    fid.write(s)
187
188    # add slump after 30 mins
189    if allclose(t, 30*60):
190        slump = Quantity(domain)
191        slump.set_values(tsunami_source)
192        domain.set_quantity('stage', slump + thisstagestep)
193   
194   
195print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.