source: anuga_work/production/busselton/standardised_version/run_model.py @ 6312

Last change on this file since 6312 was 6312, checked in by rwilson, 16 years ago

Checked in to get a copy on nautilus for final testing.

File size: 6.3 KB
Line 
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
41import build_urs_boundary as bub
42
43
44#-------------------------------------------------------------------------------
45# Perform (as much as possible) a sanity check on values from import of project.
46#-------------------------------------------------------------------------------
47
48#-------------------------------------------------------------------------------
49# Copy scripts to time stamped output directory and capture screen
50# output to file. Copy script must be before screen_catcher
51#-------------------------------------------------------------------------------
52
53copy_code_files(project.output_run, __file__, 
54                os.path.join(os.path.dirname(project.__file__),
55                             project.__name__+'.py'))
56start_screen_catcher(project.output_run, 0, 1)
57
58#-------------------------------------------------------------------------------
59# Create the computational domain based on overall clipping polygon with
60# a tagged boundary and interior regions defined in project.py along with
61# resolutions (maximal area of per triangle) for each polygon
62#-------------------------------------------------------------------------------
63
64print 'Create computational domain'
65
66# Create the STS file
67bub.build_urs_boundary(os.path.join(project.muxhome, 'mux'),
68                       project.mux_input_filename,
69                       os.path.join(project.event_folder,
70                                    project.scenario_name))
71
72# Read in boundary from ordered sts file
73event_sts = create_sts_boundary(project.event_sts)
74
75# Reading the landward defined points, this incorporates the original clipping
76# polygon minus the 100m contour
77landward_boundary = read_polygon(project.landward_boundary)
78
79# Combine sts polyline with landward points
80bounding_polygon_sts = event_sts + landward_boundary
81
82# Number of boundary segments
83N = len(event_sts) - 1
84
85# Boundary tags refer to project.landward_boundary
86# 4 points equals 5 segments start at N
87boundary_tags={'back': [N+1, N+2, N+3, N+4, N+5, N+6, N+7],
88               'side': [N, N+8],
89               'ocean': range(N)}
90
91# Build mesh and domain
92domain = create_domain_from_regions(bounding_polygon_sts,
93                                    boundary_tags=boundary_tags,
94                                    maximum_triangle_area=project.bounding_maxarea,
95                                    interior_regions=project.interior_regions,
96                                    mesh_filename=project.meshes,
97                                    use_cache=True,
98                                    verbose=True)
99print domain.statistics()
100
101domain.set_name(project.scenario_name)
102domain.set_datadir(project.output_run) 
103domain.set_minimum_storable_height(0.01)    # Don't store depth less than 1cm
104
105#-------------------------------------------------------------------------------
106# Setup initial conditions
107#-------------------------------------------------------------------------------
108
109print 'Setup initial conditions'
110
111# Set the initial stage in the offcoast region only
112IC = Polygon_function(project.land_initial_conditions,
113                      default=project.tide,
114                      geo_reference=domain.geo_reference)
115domain.set_quantity('stage', IC, use_cache=True, verbose=True)
116domain.set_quantity('friction', project.friction) 
117domain.set_quantity('elevation', 
118                    filename=project.combined_elevation+'.pts',
119                    use_cache=True,
120                    verbose=True,
121                    alpha=project.alpha)
122
123#-------------------------------------------------------------------------------
124# Setup boundary conditions
125#-------------------------------------------------------------------------------
126
127print 'Set boundary - available tags:', domain.get_boundary_tags()
128
129Br = Reflective_boundary(domain)
130Bt = Transmissive_stage_zero_momentum_boundary(domain)
131Bd = Dirichlet_boundary([kwargs['tide'], 0, 0])
132Bf = Field_boundary(project.event_sts+'.sts',
133                    domain, mean_stage=project.tide,
134                    time_thinning=1,
135                    default_boundary=Bd,
136                    boundary_polygon=bounding_polygon_sts,                   
137                    use_cache=True,
138                    verbose=True)
139
140domain.set_boundary({'back': Br,
141                     'side': Bt,
142                     'ocean': Bf}) 
143
144#-------------------------------------------------------------------------------
145# Evolve system through time
146#-------------------------------------------------------------------------------
147
148t0 = time.time()
149for t in domain.evolve(yieldstep=project.yieldstep, 
150                       finaltime=project.finaltime,
151                       skip_initial_step=False): 
152    print domain.timestepping_statistics()
153    print domain.boundary_statistics(tags='ocean')
154
155print 'Simulation took %.2f seconds' % (time.time()-t0)
Note: See TracBrowser for help on using the repository browser.