source: anuga_core/documentation/user_manual/demos/cairns/runcairns.py @ 7077

Last change on this file since 7077 was 7077, checked in by ole, 14 years ago

Updated runcairns to use add_quantity - also made slide the default event.

File size: 7.1 KB
RevLine 
[4023]1"""Script for running a tsunami inundation scenario for Cairns, QLD Australia.
[4021]2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
[4023]5The output sww file is stored in directory named after the scenario, i.e
[4063]6slide or fixed_wave.
[4021]7
8The scenario is defined by a triangular mesh created from project.polygon,
[4023]9the elevation data and a tsunami wave generated by a submarine mass failure.
[4021]10
[6889]11Geoscience Australia, 2004-present
[4021]12"""
13
[4100]14#------------------------------------------------------------------------------
[4021]15# Import necessary modules
[4100]16#------------------------------------------------------------------------------
[4021]17# Standard modules
18import os
19import time
20import sys
21
22# Related major packages
[6889]23from anuga.interface import create_domain_from_regions
24from anuga.interface import Reflective_boundary
25from anuga.interface import Dirichlet_boundary
26from anuga.interface import Time_boundary
27from anuga.interface import File_boundary
28from anuga.interface import Transmissive_stage_zero_momentum_boundary
29
[4100]30from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
31from anuga.shallow_water.data_manager import dem2pts
[4021]32
[6889]33from anuga.shallow_water.smf import slide_tsunami 
34
[4021]35# Application specific imports
36import 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]43convert_dem_from_ascii2netcdf(project.demname, use_cache=True, verbose=True)
[4021]44
[4100]45# Create pts file for onshore DEM
[6889]46dem2pts(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]53domain = 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]65print 'Number of triangles = ', len(domain)
66print 'The extent is ', domain.get_extent()
67print domain.statistics()
[6889]68                                   
69#------------------------------------------------------------------------------
70# Setup parameters of computational domain
71#------------------------------------------------------------------------------
[7077]72domain.set_name('cairns_X' + project.scenario) # Name of sww file
[6889]73domain.set_datadir('.')                       # Store sww output here
74domain.set_minimum_storable_height(0.01)      # Store only depth > 1cm
[4100]75
76#------------------------------------------------------------------------------
[4021]77# Setup initial conditions
[4100]78#------------------------------------------------------------------------------
[4021]79tide = 0.0
80domain.set_quantity('stage', tide)
81domain.set_quantity('friction', 0.0) 
82domain.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]91if 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]106print 'Available boundary tags', domain.get_boundary_tags()
107
[7077]108Bd = Dirichlet_boundary([tide, 0, 0]) # Mean water level
[6889]109Bs = Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary
110
111if 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]120if 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]130import time
131t0 = time.time()
132
133from Numeric import allclose
134from anuga.abstract_2d_finite_volumes.quantity import Quantity
135
[6889]136if 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]152if 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           
164print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.