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

Last change on this file since 7471 was 7471, checked in by ole, 15 years ago

small fixes

File size: 4.3 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':2,
62                                        'xmomentum': 2,
63                                        'ymomentum': 2,
64                                        'elevation': 1})
65    domain.set_minimum_storable_height(0.001)
66    domain.set_store_vertices_uniquely(True)  # for writting to sww
67
68    #-------------------------------------------------------------------------
69    # Setup initial conditions
70    #-------------------------------------------------------------------------
71
72
73    def elevation_tilt(x, y):
74        return x*slope
75       
76    domain.set_quantity('stage', elevation_tilt)
77    domain.set_quantity('friction', friction) 
78    domain.set_quantity('elevation',elevation_tilt)
79
80    domain.set_region('dam','stage',inital_depth,
81                                 location = 'unique vertices') 
82
83    Br = Reflective_boundary(domain)
84    Bd = Dirichlet_boundary([0,0,0])  # to drain the water out.
85    domain.set_boundary( {'wall': Br, 'edge': Bd} )
86
87    #-------------------------------------------------------------------------
88    # Evolve system through time
89    #-------------------------------------------------------------------------
90    t0 = time.time()
91
92    for t in domain.evolve(yieldstep = 0.1, finaltime = 10):
93        pass
94
95    # Load actual experimental results
96    actual,title_index_dic = csv2dict(project.actual_filename)
97   
98    gauge_locations = [[0.4,0.2]]
99    quantities = ['stage', 'elevation']
100    file_instance = file_function( project.basename +".sww",
101                                      quantities = quantities,
102                                      interpolation_points = gauge_locations,
103                                      verbose = False,
104                                      use_cache = False)
105    # create a list of the simulated_depths at the actual data times.
106    simulated_depths = []
107    for atime in actual['time']:
108        quantities_slice = file_instance(float(atime),
109                                         point_id=0)
110        depth = quantities_slice[0] - quantities_slice[1]
111        simulated_depths.append(depth)
112    flume_depths = actual["0.4:0.2"]
113    flume_depths = [float(i) for i in flume_depths]
114    # calc the norm
115    #print "map(None, simulated_depths, flume_depths)", \
116    #      map(None, simulated_depths, flume_depths)
117    norm = err(simulated_depths,
118               flume_depths, 2, relative = True)  # 2nd norm (rel. RMS
119    return norm
120#-------------------------------------------------------------
121if __name__ == "__main__":
122    main()
123   
Note: See TracBrowser for help on using the repository browser.