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

Last change on this file since 6329 was 6329, checked in by rwilson, 15 years ago

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