source: documentation/user_manual/examples/runsydney.py @ 2497

Last change on this file since 2497 was 2497, checked in by ole, 18 years ago

Updates from Wednesday meeting (Howard and Ole)

File size: 5.3 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#-------------------------------------------------------------------------------
15# Import necessary modules
16#-------------------------------------------------------------------------------
17
18# Standard modules
19import os
20import time
21
22# Related major packages
23from pyvolution.shallow_water import Domain, Reflective_boundary
24from pyvolution.data_manager import convert_dem_from_ascii2netcdf, dem2pts
25from pyvolution.combine_pts import combine_rectangular_points_files
26from pyvolution.pmesh2domain import pmesh_to_domain_instance
27from pmesh.mesh_interface import create_mesh_from_regions
28
29# Application specific imports
30import project                           # Definition of file names and polygons
31from pyvolution.smf import slump_tsunami # Function for submarine mudslide
32
33
34
35#-------------------------------------------------------------------------------   
36# Prepare bathymetric data
37#-------------------------------------------------------------------------------
38
39# filenames
40coarsedemname = project.coarsedemname + '.pts'
41finedemname = project.finedemname + '.pts'
42combineddemname = project.combineddemname + '.pts'
43meshname = project.meshname+'.msh'
44
45
46# combining the coarse and fine data
47combine_rectangular_points_files(finedemname,
48                                 coarsedemname,
49                                 combineddemname)
50
51
52
53#-------------------------------------------------------------------------------   
54# Setup computational domain
55#-------------------------------------------------------------------------------
56
57# Interior regions and mesh resolutions
58interior_res = 5000
59interior_regions = [[project.harbour_polygon_2, interior_res],
60                    [project.botanybay_polygon_2, interior_res]]
61
62
63create_mesh_from_regions(project.diffpolygonall,
64                         boundary_tags= {'bottom': [0], 
65                                         'right1': [1],
66                                         'right0': [2],
67                                         'right2': [3],
68                                         'top': [4],
69                                         'left1': [5],
70                                         'left2': [6],
71                                         'left3': [7]},
72                         maximum_triangle_area=100000,
73                         filename=meshname,           
74                         interior_regions=interior_regions)
75
76
77
78domain = pmesh_to_domain_instance(meshname, Domain,
79                                  use_cache = True,
80                                  verbose = True)
81
82print 'Number of triangles = ', len(domain)
83print 'The extent is ', domain.get_extent()
84
85domain.set_name(project.basename)
86domain.set_datadir(project.outputdir)
87domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
88
89
90#-------------------------------------------------------------------------------
91# Set up scenario (tsunami_source is a callable object used with set_quantity)
92#-------------------------------------------------------------------------------
93
94tsunami_source = slump_tsunami(length=30000.0,
95                               depth=400.0,
96                               slope=6.0,
97                               thickness=176.0, 
98                               radius=3330,
99                               dphi=0.23,
100                               x0=project.slump_origin[0], 
101                               y0=project.slump_origin[1], 
102                               alpha=0.0, 
103                               domain=domain)
104
105
106#-------------------------------------------------------------------------------
107# Setup initial conditions
108#-------------------------------------------------------------------------------
109
110domain.set_quantity('stage', tsunami_source)
111domain.set_quantity('friction', 0.0) 
112domain.set_quantity('elevation',
113                    filename = combineddemname,
114                    use_cache = True,
115                    verbose = True)
116
117
118#-------------------------------------------------------------------------------
119# Setup boundary conditions (all reflective)
120#-------------------------------------------------------------------------------
121
122print 'Available boundary tags', domain.get_boundary_tags()
123
124Br = Reflective_boundary(domain)
125domain.set_boundary( {'bottom': Br, 'right1': Br, 'right0': Br,
126                      'right2': Br, 'top': Br, 'left1': Br,
127                      'left2': Br, 'left3': Br} )
128
129
130#-------------------------------------------------------------------------------
131# Evolve system through time
132#-------------------------------------------------------------------------------
133
134import time
135t0 = time.time()
136
137for t in domain.evolve(yieldstep = 120, duration = 18000):
138    print domain.timestepping_statistics()
139    print domain.boundary_statistics(tags = 'bottom')   
140   
141print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.