[4023] | 1 | """Script for running a tsunami inundation scenario for Cairns, QLD Australia. |
---|
[4021] | 2 | |
---|
| 3 | Source data such as elevation and boundary data is assumed to be available in |
---|
| 4 | directories specified by project.py |
---|
[4023] | 5 | The output sww file is stored in directory named after the scenario, i.e |
---|
[4063] | 6 | slide or fixed_wave. |
---|
[4021] | 7 | |
---|
| 8 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
[4023] | 9 | the elevation data and a tsunami wave generated by a submarine mass failure. |
---|
[4021] | 10 | |
---|
[6889] | 11 | Geoscience Australia, 2004-present |
---|
[4021] | 12 | """ |
---|
| 13 | |
---|
[4100] | 14 | #------------------------------------------------------------------------------ |
---|
[4021] | 15 | # Import necessary modules |
---|
[4100] | 16 | #------------------------------------------------------------------------------ |
---|
[4021] | 17 | # Standard modules |
---|
| 18 | import os |
---|
| 19 | import time |
---|
| 20 | import sys |
---|
| 21 | |
---|
| 22 | # Related major packages |
---|
[6889] | 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 | |
---|
[4100] | 30 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf |
---|
| 31 | from anuga.shallow_water.data_manager import dem2pts |
---|
[4021] | 32 | |
---|
[6889] | 33 | from anuga.shallow_water.smf import slide_tsunami |
---|
| 34 | |
---|
[4021] | 35 | # Application specific imports |
---|
| 36 | import project # Definition of file names and polygons |
---|
| 37 | |
---|
[4100] | 38 | #------------------------------------------------------------------------------ |
---|
[4021] | 39 | # Preparation of topographic data |
---|
| 40 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
[4100] | 41 | #------------------------------------------------------------------------------ |
---|
| 42 | # Create DEM from asc data |
---|
[6889] | 43 | convert_dem_from_ascii2netcdf(project.demname, use_cache=True, verbose=True) |
---|
[4021] | 44 | |
---|
[4100] | 45 | # Create pts file for onshore DEM |
---|
[6889] | 46 | dem2pts(project.demname, use_cache=True, verbose=True) |
---|
[4021] | 47 | |
---|
[4100] | 48 | #------------------------------------------------------------------------------ |
---|
[6889] | 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 |
---|
[4100] | 52 | #------------------------------------------------------------------------------ |
---|
[6889] | 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) |
---|
[4021] | 63 | |
---|
[6889] | 64 | # Print some stats about mesh and domain |
---|
[4021] | 65 | print 'Number of triangles = ', len(domain) |
---|
| 66 | print 'The extent is ', domain.get_extent() |
---|
| 67 | print domain.statistics() |
---|
[6889] | 68 | |
---|
| 69 | #------------------------------------------------------------------------------ |
---|
| 70 | # Setup parameters of computational domain |
---|
| 71 | #------------------------------------------------------------------------------ |
---|
[7077] | 72 | domain.set_name('cairns_X' + project.scenario) # Name of sww file |
---|
[6889] | 73 | domain.set_datadir('.') # Store sww output here |
---|
| 74 | domain.set_minimum_storable_height(0.01) # Store only depth > 1cm |
---|
[4100] | 75 | |
---|
| 76 | #------------------------------------------------------------------------------ |
---|
[4021] | 77 | # Setup initial conditions |
---|
[4100] | 78 | #------------------------------------------------------------------------------ |
---|
[4021] | 79 | tide = 0.0 |
---|
| 80 | domain.set_quantity('stage', tide) |
---|
| 81 | domain.set_quantity('friction', 0.0) |
---|
| 82 | domain.set_quantity('elevation', |
---|
[6889] | 83 | filename=project.demname + '.pts', |
---|
[4100] | 84 | use_cache=True, |
---|
| 85 | verbose=True, |
---|
| 86 | alpha=0.1) |
---|
[4021] | 87 | |
---|
[4100] | 88 | #------------------------------------------------------------------------------ |
---|
[4063] | 89 | # Setup information for slide scenario (to be applied 1 min into simulation |
---|
[4100] | 90 | #------------------------------------------------------------------------------ |
---|
[6889] | 91 | if project.scenario == 'slide': |
---|
[4100] | 92 | # Function for submarine slide |
---|
[4063] | 93 | tsunami_source = slide_tsunami(length=35000.0, |
---|
| 94 | depth=project.slide_depth, |
---|
[4021] | 95 | slope=6.0, |
---|
[4063] | 96 | thickness=500.0, |
---|
| 97 | x0=project.slide_origin[0], |
---|
| 98 | y0=project.slide_origin[1], |
---|
[4021] | 99 | alpha=0.0, |
---|
| 100 | domain=domain, |
---|
| 101 | verbose=True) |
---|
| 102 | |
---|
[4100] | 103 | #------------------------------------------------------------------------------ |
---|
[4021] | 104 | # Setup boundary conditions |
---|
[4100] | 105 | #------------------------------------------------------------------------------ |
---|
[4021] | 106 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
| 107 | |
---|
[7077] | 108 | Bd = Dirichlet_boundary([tide, 0, 0]) # Mean water level |
---|
[6889] | 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]) |
---|
[4100] | 115 | domain.set_boundary({'ocean_east': Bw, |
---|
[6889] | 116 | 'bottom': Bs, |
---|
[4100] | 117 | 'onshore': Bd, |
---|
[6889] | 118 | 'top': Bs}) |
---|
[4021] | 119 | |
---|
[6889] | 120 | if project.scenario == 'slide': |
---|
| 121 | # Boundary conditions for slide scenario |
---|
[4100] | 122 | domain.set_boundary({'ocean_east': Bd, |
---|
| 123 | 'bottom': Bd, |
---|
| 124 | 'onshore': Bd, |
---|
| 125 | 'top': Bd}) |
---|
[4021] | 126 | |
---|
[4100] | 127 | #------------------------------------------------------------------------------ |
---|
[4021] | 128 | # Evolve system through time |
---|
[4100] | 129 | #------------------------------------------------------------------------------ |
---|
[4021] | 130 | import time |
---|
| 131 | t0 = time.time() |
---|
| 132 | |
---|
| 133 | from Numeric import allclose |
---|
| 134 | from anuga.abstract_2d_finite_volumes.quantity import Quantity |
---|
| 135 | |
---|
[6889] | 136 | if project.scenario == 'slide': |
---|
[7077] | 137 | # Initial run without any event |
---|
[6889] | 138 | for t in domain.evolve(yieldstep=10, finaltime=60): |
---|
| 139 | print domain.timestepping_statistics() |
---|
| 140 | print domain.boundary_statistics(tags='ocean_east') |
---|
[4021] | 141 | |
---|
[7077] | 142 | # Add slide to water surface |
---|
[4023] | 143 | if allclose(t, 60): |
---|
[7077] | 144 | domain.add_quantity('stage', tsunami_source) |
---|
[4021] | 145 | |
---|
[7077] | 146 | # Continue propagating wave |
---|
[6889] | 147 | for t in domain.evolve(yieldstep=10, finaltime=5000, |
---|
[4023] | 148 | skip_initial_step = True): |
---|
[6889] | 149 | print domain.timestepping_statistics() |
---|
| 150 | print domain.boundary_statistics(tags='ocean_east') |
---|
[4021] | 151 | |
---|
[6889] | 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') |
---|
[4021] | 157 | |
---|
[6889] | 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') |
---|
[4021] | 163 | |
---|
| 164 | print 'That took %.2f seconds' %(time.time()-t0) |
---|