source: production/sydney_2006/run_sydney_smf.py @ 3031

Last change on this file since 3031 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
RevLine 
[2240]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,
[2407]8the elevation data and a simulated submarine landslide.
[2240]9
[2407]10Ole Nielsen and Duncan Gray, GA - 2005 and Adrian Hitchman and Jane Sexton, GA - 2006
[2240]11"""
12
13
[2407]14#-------------------------------------------------------------------------------# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
[2240]18import os
19import time
20
[2407]21# Related major packages
[2640]22from pyvolution.shallow_water import Domain, Reflective_boundary, Dirichlet_boundary
[2407]23from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
[2640]24#from pyvolution.data_manager_old import convert_dem_from_ascii2netcdf, dem2pts
[2407]25from pyvolution.combine_pts import combine_rectangular_points_files
[2292]26from pyvolution.pmesh2domain import pmesh_to_domain_instance
[2640]27from pyvolution.quantity import Quantity
28from Numeric import allclose
[2240]29
[2407]30# Application specific imports
31import project                 # Definition of file names and polygons
[2460]32from pyvolution.smf import slump_tsunami  # Function for submarine mudslide
[2407]33
34
35#-------------------------------------------------------------------------------
36# Preparation of topographic data
37#
[2292]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
[2407]41#-------------------------------------------------------------------------------
42
43# filenames
[2292]44coarsedemname = project.coarsedemname
45finedemname = project.finedemname
[2240]46meshname = project.meshname+'.msh'
47
[2292]48# coarse data
[2407]49convert_dem_from_ascii2netcdf(coarsedemname, use_cache=True, verbose=True)
50dem2pts(coarsedemname, use_cache=True, verbose=True)
[2240]51
[2407]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)
[2240]61
[2292]62# combining the coarse and fine data
63combine_rectangular_points_files(project.finedemname + '.pts',
64                                 project.coarsedemname + '.pts',
65                                 project.combineddemname + '.pts')
[2407]66
[2456]67#from pmesh.create_mesh import create_mesh_from_regions
[2640]68#new interface
[2456]69from pmesh.mesh_interface import create_mesh_from_regions
[2407]70
[2640]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]]
[2350]75
[2640]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
[2407]86#FIXME: Fix caching of this one once the mesh_interface is ready
87from caching import cache
[2456]88
[2640]89# original + refined region
[2407]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]},
[2456]96           'maximum_triangle_area': 100000,
[2407]97           'filename': meshname,           
[2456]98           'interior_regions': interior_regions},
[2407]99          verbose = True)
[2350]100
[2640]101#-------------------------------------------------------------------------------                                 
[2407]102# Setup computational domain
[2640]103#-------------------------------------------------------------------------------                                 
[2407]104
105domain = pmesh_to_domain_instance(meshname, Domain,
106                                  use_cache = True,
107                                  verbose = True)
108
[2240]109print 'Number of triangles = ', len(domain)
110print 'The extent is ', domain.get_extent()
[2640]111print domain.statistics()
[2240]112
113domain.set_name(project.basename)
114domain.set_datadir(project.outputdir)
[2407]115domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
[2240]116
[2407]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
[2640]134#-------------------------------------------------------------------------------                                 
[2407]135# Setup initial conditions
136#-------------------------------------------------------------------------------
137
[2640]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) 
[2407]141domain.set_quantity('elevation',
142                    filename = project.combineddemname + '.pts',
143                    use_cache = True,
144                    verbose = True)
[2240]145
[2407]146
147#-------------------------------------------------------------------------------                                 
148# Setup boundary conditions (all reflective)
149#-------------------------------------------------------------------------------
150
151print 'Available boundary tags', domain.get_boundary_tags()
152
[2240]153Br = Reflective_boundary(domain)
[2640]154Bd = Dirichlet_boundary([0, 0, 0])
[2292]155
[2640]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} )
[2407]160
[2640]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
[2407]170#-------------------------------------------------------------------------------                                 
171# Evolve system through time
172#-------------------------------------------------------------------------------
173
[2240]174import time
175t0 = time.time()
[2640]176thisfile = project.integraltimeseries+'.csv'
177fid = open(thisfile, 'w')
[2240]178
[2640]179for t in domain.evolve(yieldstep = 120, finaltime = 18000):
[2240]180    domain.write_time()
[2640]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)
[2240]193   
[2640]194   
[2240]195print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.