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