1 | """Script for running a tsunami inundation scenario for Cairns, QLD Australia. |
---|
2 | |
---|
3 | Source data such as elevation and boundary data is assumed to be available in |
---|
4 | directories specified by project.py |
---|
5 | The output sww file is stored in directory named after the scenario, i.e |
---|
6 | slide or fixed_wave. |
---|
7 | |
---|
8 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
9 | the elevation data and a tsunami wave generated by a submarine mass failure. |
---|
10 | |
---|
11 | Geoscience Australia, 2004-present |
---|
12 | """ |
---|
13 | |
---|
14 | #------------------------------------------------------------------------------ |
---|
15 | # Import necessary modules |
---|
16 | #------------------------------------------------------------------------------ |
---|
17 | # Standard modules |
---|
18 | import os |
---|
19 | import time |
---|
20 | import sys |
---|
21 | |
---|
22 | # Related major packages |
---|
23 | from anuga.interface import create_domain_from_regions |
---|
24 | from anuga.interface import Reflective_boundary |
---|
25 | from anuga.interface import Dirichlet_boundary |
---|
26 | from anuga.interface import Time_boundary |
---|
27 | from anuga.interface import File_boundary |
---|
28 | from anuga.interface import Transmissive_stage_zero_momentum_boundary |
---|
29 | |
---|
30 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf |
---|
31 | from anuga.shallow_water.data_manager import dem2pts |
---|
32 | |
---|
33 | from anuga.shallow_water.smf import slide_tsunami |
---|
34 | |
---|
35 | # Application specific imports |
---|
36 | import project # Definition of file names and polygons |
---|
37 | |
---|
38 | #------------------------------------------------------------------------------ |
---|
39 | # Preparation of topographic data |
---|
40 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
41 | #------------------------------------------------------------------------------ |
---|
42 | # Create DEM from asc data |
---|
43 | convert_dem_from_ascii2netcdf(project.demname, use_cache=True, verbose=True) |
---|
44 | |
---|
45 | # Create pts file for onshore DEM |
---|
46 | dem2pts(project.demname, use_cache=True, verbose=True) |
---|
47 | |
---|
48 | #------------------------------------------------------------------------------ |
---|
49 | # Create the triangular mesh and domain based on |
---|
50 | # overall clipping polygon with a tagged |
---|
51 | # boundary and interior regions as defined in project.py |
---|
52 | #------------------------------------------------------------------------------ |
---|
53 | domain = create_domain_from_regions(project.bounding_polygon, |
---|
54 | boundary_tags={'top': [0], |
---|
55 | 'ocean_east': [1], |
---|
56 | 'bottom': [2], |
---|
57 | 'onshore': [3]}, |
---|
58 | maximum_triangle_area=project.default_res, |
---|
59 | mesh_filename=project.meshname, |
---|
60 | interior_regions=project.interior_regions, |
---|
61 | use_cache=True, |
---|
62 | verbose=True) |
---|
63 | |
---|
64 | # Print some stats about mesh and domain |
---|
65 | print 'Number of triangles = ', len(domain) |
---|
66 | print 'The extent is ', domain.get_extent() |
---|
67 | print domain.statistics() |
---|
68 | |
---|
69 | #------------------------------------------------------------------------------ |
---|
70 | # Setup parameters of computational domain |
---|
71 | #------------------------------------------------------------------------------ |
---|
72 | domain.set_name('cairns_' + project.scenario) # Name of sww file |
---|
73 | domain.set_datadir('.') # Store sww output here |
---|
74 | domain.set_minimum_storable_height(0.01) # Store only depth > 1cm |
---|
75 | |
---|
76 | #------------------------------------------------------------------------------ |
---|
77 | # Setup initial conditions |
---|
78 | #------------------------------------------------------------------------------ |
---|
79 | tide = 0.0 |
---|
80 | domain.set_quantity('stage', tide) |
---|
81 | domain.set_quantity('friction', 0.0) |
---|
82 | domain.set_quantity('elevation', |
---|
83 | filename=project.demname + '.pts', |
---|
84 | use_cache=True, |
---|
85 | verbose=True, |
---|
86 | alpha=0.1) |
---|
87 | |
---|
88 | #------------------------------------------------------------------------------ |
---|
89 | # Setup information for slide scenario (to be applied 1 min into simulation |
---|
90 | #------------------------------------------------------------------------------ |
---|
91 | if project.scenario == 'slide': |
---|
92 | # Function for submarine slide |
---|
93 | tsunami_source = slide_tsunami(length=35000.0, |
---|
94 | depth=project.slide_depth, |
---|
95 | slope=6.0, |
---|
96 | thickness=500.0, |
---|
97 | x0=project.slide_origin[0], |
---|
98 | y0=project.slide_origin[1], |
---|
99 | alpha=0.0, |
---|
100 | domain=domain, |
---|
101 | verbose=True) |
---|
102 | |
---|
103 | #------------------------------------------------------------------------------ |
---|
104 | # Setup boundary conditions |
---|
105 | #------------------------------------------------------------------------------ |
---|
106 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
107 | |
---|
108 | Bd = Dirichlet_boundary([tide, 0, 0]) # Mean water level |
---|
109 | Bs = Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary |
---|
110 | |
---|
111 | if project.scenario == 'fixed_wave': |
---|
112 | # Huge 50m wave starting after 60 seconds and lasting 1 hour. |
---|
113 | Bw = Time_boundary(domain=domain, |
---|
114 | function=lambda t: [(60<t<3660)*50, 0, 0]) |
---|
115 | domain.set_boundary({'ocean_east': Bw, |
---|
116 | 'bottom': Bs, |
---|
117 | 'onshore': Bd, |
---|
118 | 'top': Bs}) |
---|
119 | |
---|
120 | if project.scenario == 'slide': |
---|
121 | # Boundary conditions for slide scenario |
---|
122 | domain.set_boundary({'ocean_east': Bd, |
---|
123 | 'bottom': Bd, |
---|
124 | 'onshore': Bd, |
---|
125 | 'top': Bd}) |
---|
126 | |
---|
127 | #------------------------------------------------------------------------------ |
---|
128 | # Evolve system through time |
---|
129 | #------------------------------------------------------------------------------ |
---|
130 | import time |
---|
131 | t0 = time.time() |
---|
132 | |
---|
133 | from Numeric import allclose |
---|
134 | from anuga.abstract_2d_finite_volumes.quantity import Quantity |
---|
135 | |
---|
136 | if project.scenario == 'slide': |
---|
137 | # Initial run without any event |
---|
138 | for t in domain.evolve(yieldstep=10, finaltime=60): |
---|
139 | print domain.timestepping_statistics() |
---|
140 | print domain.boundary_statistics(tags='ocean_east') |
---|
141 | |
---|
142 | # Add slide to water surface |
---|
143 | if allclose(t, 60): |
---|
144 | domain.add_quantity('stage', tsunami_source) |
---|
145 | |
---|
146 | # Continue propagating wave |
---|
147 | for t in domain.evolve(yieldstep=10, finaltime=5000, |
---|
148 | skip_initial_step=True): |
---|
149 | print domain.timestepping_statistics() |
---|
150 | print domain.boundary_statistics(tags='ocean_east') |
---|
151 | |
---|
152 | if project.scenario == 'fixed_wave': |
---|
153 | # Save every two mins leading up to wave approaching land |
---|
154 | for t in domain.evolve(yieldstep=120, finaltime=5000): |
---|
155 | print domain.timestepping_statistics() |
---|
156 | print domain.boundary_statistics(tags='ocean_east') |
---|
157 | |
---|
158 | # Save every 30 secs as wave starts inundating ashore |
---|
159 | for t in domain.evolve(yieldstep=10, finaltime=10000, |
---|
160 | skip_initial_step=True): |
---|
161 | print domain.timestepping_statistics() |
---|
162 | print domain.boundary_statistics(tags='ocean_east') |
---|
163 | |
---|
164 | print 'That took %.2f seconds' %(time.time()-t0) |
---|