source: production/sydney_2006/run_sydney_smf.py @ 2350

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

tidying up scripts for Sydney tsunami scenario

File size: 5.7 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 Adrian Hitchman 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 pyvolution.combine_pts import combine_rectangular_points_files
25from caching import cache
26import project
27from math import pi, sin
28from smf import slump_tsunami, slide_tsunami, Double_gaussian
29from pyvolution.least_squares import fit_to_mesh_file, DEFAULT_ALPHA
30
31# Data preparation
32# Convert ASC 2 DEM 2 PTS using source data and store result in source data
33# Do for coarse and fine data
34# Fine pts file to be clipped to area of interest
35coarsedemname = project.coarsedemname
36finedemname = project.finedemname
37meshname = project.meshname+'.msh'
38
39# coarse data
40cache(convert_dem_from_ascii2netcdf, coarsedemname, {'verbose': True},
41      dependencies = [coarsedemname + '.asc'],
42      verbose = True)
43      #evaluate = True)
44
45cache(dem2pts, coarsedemname, {'verbose': True},
46      dependencies = [coarsedemname + '.dem'],     
47      verbose = True)
48
49# fine data
50cache(convert_dem_from_ascii2netcdf, finedemname, {'verbose': True},
51      dependencies = [finedemname + '.asc'],
52      verbose = True)
53      #evaluate = True)
54
55# clipping the fine data
56cache(dem2pts, finedemname, {'verbose': True,
57      'easting_min': project.eastingmin,
58      'easting_max': project.eastingmax,
59      'northing_min': project.northingmin,
60      'northing_max': project.northingmax},
61      dependencies = [finedemname + '.dem'],
62      #evaluate = True,
63      verbose = True)
64
65# combining the coarse and fine data
66combine_rectangular_points_files(project.finedemname + '.pts',
67                                 project.coarsedemname + '.pts',
68                                 project.combineddemname + '.pts')
69                                 
70# Create Triangular Mesh
71# Overall clipping polygon and interior regions defined in project.py
72from pmesh.create_mesh import create_mesh_from_regions
73
74# for whole region
75interior_res = 5000 # maximal area of per triangle
76interior_regions = [[project.harbour_polygon_2, interior_res],
77                    [project.botanybay_polygon_2, interior_res]] 
78
79m = cache(create_mesh_from_regions,
80            project.diffpolygonall,
81            {'boundary_tags': {'bottom': [0], 
82                            'right1': [1], 'right0': [2],
83                            'right2': [3], 'top': [4], 'left1': [5],
84                            'left2': [6], 'left3': [7]},
85            'resolution': 100000,
86            'filename': meshname,           
87            'interior_regions': interior_regions},
88            #evaluate=True,   
89            verbose = True)
90
91#Add elevation data to the mesh - this is in place of set_quantity
92#mesh_elevname = 'elevation.msh'   
93#cache(fit_to_mesh_file,(meshname, project.combineddemname + '.pts',
94#                        mesh_elevname, DEFAULT_ALPHA),
95#      {'verbose': True, 'expand_search': True, 'precrop': True},
96#      dependencies = [meshname],
97#      #evaluate = True,   
98#      verbose = False)
99#meshname = mesh_elevname
100
101# Setup domain
102domain = cache(pmesh_to_domain_instance, (meshname, Domain),
103               dependencies = [meshname],                     
104               verbose = True)
105
106# This section replaced with fit_to_mesh_file above
107domain.set_quantity('elevation',
108                     filename = project.combineddemname + '.pts',
109#                     filename = project.finedemname + '.pts',
110                     use_cache = True,
111                     verbose = True)
112
113         
114       
115print 'Number of triangles = ', len(domain)
116print 'The extent is ', domain.get_extent()
117
118domain.set_name(project.basename)
119domain.set_datadir(project.outputdir)
120domain.store = True
121domain.quantities_to_be_stored = ['stage', 'xmomentum', 'ymomentum']
122
123# slump parameters, wid=len
124len = 30000.0
125dep = 400.0
126#thk = 120.0 for scenario 1 and 176 for scenario 2 rang 0.2-0.44 of depth
127thk = 0.44*dep
128rad = 3330
129dp = 0.23
130th = 6
131alpha = 0.0
132x0 = project.x0 # slump origin
133y0 = project.y0
134# Setup Initial conditions
135t = slump_tsunami(length=len, depth=dep, slope=th, thickness=thk, \
136                  radius=rad, dphi=dp, x0=x0, y0=y0, alpha=alpha)
137domain.set_quantity('stage', t)
138domain.set_quantity('friction', 0)
139   
140# Setup Boundary Conditions
141print domain.get_boundary_tags()
142
143Br = Reflective_boundary(domain)
144Bt = Transmissive_boundary(domain)
145Bd = Dirichlet_boundary([0,0,0])
146# 10 min square wave starting at 1 min, 6m high
147Bw = Time_boundary(domain=domain,
148                   f=lambda t: [(6<t<606)*6, 0, 0])
149
150domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
151                      'right2': Br, 'top': Br, 'left1': Br,
152                      'left2': Br, 'left3': Br} )
153
154# Evolve
155import time
156t0 = time.time()
157
158for t in domain.evolve(yieldstep = 120, finaltime = 18000): 
159    domain.write_time()
160    domain.write_boundary_statistics(tags = 'bottom')     
161   
162print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.