source: anuga_work/production/australia_ph2/ceduna/run_model.py @ 6291

Last change on this file since 6291 was 6291, checked in by myall, 15 years ago

new area for phase 2. scripts copied from standardised version

File size: 5.7 KB
RevLine 
[6291]1"""Run a tsunami inundation scenario for Busselton, WA, Australia.
2
3The scenario is defined by a triangular mesh created from project.polygon, the
4elevation data is compiled into a pts file through build_elevation.py and a
5simulated tsunami is generated through an sts file from build_boundary.py.
6
7Input: sts file (build_boundary.py for respective event)
8       pts file (build_elevation.py)
9       information from project file
10Outputs: sww file stored in project.output_run_time_dir
11The export_results_all.py and get_timeseries.py is reliant
12on the outputs of this script
13
14Ole Nielsen and Duncan Gray, GA - 2005, Jane Sexton, Nick Bartzis, GA - 2006
15Ole Nielsen, Jane Sexton and Kristy Van Putten - 2008
16"""
17
18#------------------------------------------------------------------------------
19# Import necessary modules
20#------------------------------------------------------------------------------
21
22# Standard modules
23import os
24import time
25
26# Related major packages
27from anuga.interface import create_domain_from_regions
28from anuga.interface import Transmissive_stage_zero_momentum_boundary
29from anuga.interface import Dirichlet_boundary
30from anuga.interface import Reflective_boundary
31from anuga.interface import Field_boundary
32from anuga.interface import create_sts_boundary
33from anuga.interface import csv2building_polygons
34
35from anuga.shallow_water.data_manager import start_screen_catcher
36from anuga.shallow_water.data_manager import copy_code_files
37from anuga.utilities.polygon import read_polygon, Polygon_function
38   
39# Application specific imports
40import project  # Definition of file names and polygons
41
42
43#------------------------------------------------------------------------------
44# Copy scripts to time stamped output directory and capture screen
45# output to file. Copy script must be before screen_catcher
46#------------------------------------------------------------------------------
47copy_code_files(project.output_run, __file__, 
48                os.path.dirname(project.__file__)+os.sep+\
49                project.__name__+'.py' )
50start_screen_catcher(project.output_run, 0, 1)
51
52
53#------------------------------------------------------------------------------
54# Create the computational domain based on overall clipping polygon with
55# a tagged boundary and interior regions defined in project.py along with
56# resolutions (maximal area of per triangle) for each polygon
57#------------------------------------------------------------------------------
58print 'Create computational domain'
59
60# Read in boundary from ordered sts file
61event_sts = create_sts_boundary(project.event_sts)
62
63# Reading the landward defined points, this incorporates the original clipping
64# polygon minus the 100m contour
65landward_boundary = read_polygon(project.landward_boundary)
66
67# Combine sts polyline with landward points
68bounding_polygon_sts = event_sts + landward_boundary
69
70# Number of boundary segments
71N = len(event_sts)-1
72
73# Boundary tags refer to project.landward_boundary
74# 4 points equals 5 segments start at N
75boundary_tags={'back': [N+1, N+2, N+3, N+4, N+5, N+6, N+7],
76               'side': [N, N+8],
77               'ocean': range(N)}
78
79# Build mesh and domain
80domain = create_domain_from_regions(bounding_polygon_sts,
81                                    boundary_tags=boundary_tags,
82                                    maximum_triangle_area=project.bounding_maxarea,
83                                    interior_regions=project.interior_regions,
84                                    mesh_filename=project.meshes,
85                                    use_cache=True,
86                                    verbose=True)
87print domain.statistics()
88
89domain.set_name(project.scenario_name)
90domain.set_datadir(project.output_run) 
91domain.set_minimum_storable_height(0.01)    # Don't store depth less than 1cm
92
93
94#------------------------------------------------------------------------------
95# Setup initial conditions
96#------------------------------------------------------------------------------
97print 'Setup initial conditions'
98
99# Set the initial stage in the offcoast region only
100IC = Polygon_function(project.land_initial_conditions,
101                      default=project.tide,
102                      geo_reference=domain.geo_reference)
103domain.set_quantity('stage', IC, use_cache=True, verbose=True)
104domain.set_quantity('friction', project.friction) 
105domain.set_quantity('elevation', 
106                    filename=project.combined_elevation+'.pts',
107                    use_cache=True,
108                    verbose=True,
109                    alpha=project.alpha)
110
111
112#------------------------------------------------------------------------------
113# Setup boundary conditions
114#------------------------------------------------------------------------------
115print 'Set boundary - available tags:', domain.get_boundary_tags()
116
117Br = Reflective_boundary(domain)
118Bt = Transmissive_stage_zero_momentum_boundary(domain)
119Bf = Field_boundary(project.event_sts+'.sts',
120                    domain, mean_stage=project.tide,
121                    time_thinning=1,
122                    default_boundary=Bd,
123                    boundary_polygon=bounding_polygon_sts,                   
124                    use_cache=True,
125                    verbose=True)
126
127domain.set_boundary({'back': Br,
128                     'side': Bt,
129                     'ocean': Bf}) 
130
131
132#------------------------------------------------------------------------------
133# Evolve system through time
134#------------------------------------------------------------------------------
135t0 = time.time()
136for t in domain.evolve(yieldstep=project.yieldstep, 
137                       finaltime=project.finaltime,
138                       skip_initial_step=False): 
139    print domain.timestepping_statistics()
140    print domain.boundary_statistics(tags='ocean')
141
142print 'Simulation took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.