source: anuga_validation/automated_validation_tests/UQ_runup_2006/run_dam.py @ 6056

Last change on this file since 6056 was 6056, checked in by duncan, 15 years ago

Removing dead code and following the style guide.

File size: 4.2 KB
Line 
1"""Script for running a dam break simulation of UQ's dam break tank.
2
3
4Ole Nielsen and Duncan Gray, GA - 2006
5"""
6
7
8#----------------------------------------------------------------------------
9# Import necessary modules
10#----------------------------------------------------------------------------
11
12# Standard modules
13import time
14import sys
15from shutil import copy
16from os import path
17
18# Related major packages
19from anuga.shallow_water import Domain, Reflective_boundary, \
20     Dirichlet_boundary, Time_boundary, File_boundary
21from anuga.abstract_2d_finite_volumes.region import Set_region
22from anuga.fit_interpolate.interpolate import interpolate_sww2csv, \
23     file_function
24from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \
25     copy_code_files
26from anuga.shallow_water.data_manager import csv2dict
27from numerical_tools import  err 
28
29# Application specific imports
30import create_mesh
31import project
32
33def main():     
34    slope= 0
35    friction = 0.01 
36    inital_depth = 0.2
37    gate_position = 0.75
38   
39    return scenario(slope, friction, inital_depth, gate_position)
40           
41
42def scenario(slope, friction, inital_depth, gate_position):
43
44    #-------------------------------------------------------------------------
45    # Create the triangular mesh
46    #-------------------------------------------------------------------------
47
48    create_mesh.generate(project.mesh_filename,
49                         gate_position,
50                         #is_course=True) # this creates the mesh
51                         is_course=False) # this creates the mesh
52
53    head,tail = path.split(project.mesh_filename)
54   
55    #-------------------------------------------------------------------------
56    # Setup computational domain
57    #-------------------------------------------------------------------------
58    domain = Domain(project.mesh_filename, use_cache = False, verbose = False)
59    domain.set_name(project.basename)
60    domain.set_datadir('.')
61    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
62    domain.set_minimum_storable_height(0.001)
63    domain.set_store_vertices_uniquely(True)  # for writting to sww
64
65    #-------------------------------------------------------------------------
66    # Setup initial conditions
67    #-------------------------------------------------------------------------
68
69
70    def elevation_tilt(x, y):
71        return x*slope
72       
73    domain.set_quantity('stage', elevation_tilt)
74    domain.set_quantity('friction', friction) 
75    domain.set_quantity('elevation',elevation_tilt)
76
77    domain.set_region('dam','stage',inital_depth,
78                                 location = 'unique vertices') 
79
80    Br = Reflective_boundary(domain)
81    Bd = Dirichlet_boundary([0,0,0])  # to drain the water out.
82    domain.set_boundary( {'wall': Br, 'edge': Bd} )
83
84    #-------------------------------------------------------------------------
85    # Evolve system through time
86    #-------------------------------------------------------------------------
87    t0 = time.time()
88
89    for t in domain.evolve(yieldstep = 0.1, finaltime = 10):
90        pass
91
92    # Load actual experimental results
93    actual,title_index_dic = csv2dict(project.actual_filename)
94   
95    gauge_locations = [[0.4,0.2]]
96    quantities = ['stage', 'elevation']
97    file_instance = file_function( project.basename +".sww",
98                                      quantities = quantities,
99                                      interpolation_points = gauge_locations,
100                                      verbose = False,
101                                      use_cache = False)
102    # create a list of the simulated_depths at the actual data times.
103    simulated_depths = []
104    for atime in actual['time']:
105        quantities_slice = file_instance(float(atime),
106                                         point_id=0)
107        depth = quantities_slice[0] - quantities_slice[1]
108        simulated_depths.append(depth)
109    flume_depths = actual["0.4:0.2"]
110    flume_depths = [float(i) for i in flume_depths]
111    # calc the norm
112    #print "map(None, simulated_depths, flume_depths)", \
113    #      map(None, simulated_depths, flume_depths)
114    norm = err(simulated_depths,
115               flume_depths, 2, relative = True)  # 2nd norm (rel. RMS
116    return norm
117#-------------------------------------------------------------
118if __name__ == "__main__":
119    main()
120   
Note: See TracBrowser for help on using the repository browser.