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

Last change on this file since 7750 was 7750, checked in by hudson, 14 years ago

Updated validation suite to work with new API - confirmed that Patong passes.

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.utilities.file_utils import copy_code_files, load_csv_as_dict
25from numerical_tools import  err 
26
27# Application specific imports
28import create_mesh
29import project
30
31def main():     
32    slope= 0
33    friction = 0.01 
34    inital_depth = 0.2
35    gate_position = 0.75
36   
37    return scenario(slope, friction, inital_depth, gate_position)
38           
39
40def scenario(slope, friction, inital_depth, gate_position):
41
42    #-------------------------------------------------------------------------
43    # Create the triangular mesh
44    #-------------------------------------------------------------------------
45
46    create_mesh.generate(project.mesh_filename,
47                         gate_position,
48                         #is_course=True) # this creates the mesh
49                         is_course=False) # this creates the mesh
50
51    head,tail = path.split(project.mesh_filename)
52   
53    #-------------------------------------------------------------------------
54    # Setup computational domain
55    #-------------------------------------------------------------------------
56    domain = Domain(project.mesh_filename, use_cache = False, verbose = False)
57    domain.set_name(project.basename)
58    domain.set_datadir('.')
59    domain.set_quantities_to_be_stored({'stage':2,
60                                        'xmomentum': 2,
61                                        'ymomentum': 2,
62                                        'elevation': 1})
63    domain.set_minimum_storable_height(0.001)
64    domain.set_store_vertices_uniquely(True)  # for writting to sww
65
66    #-------------------------------------------------------------------------
67    # Setup initial conditions
68    #-------------------------------------------------------------------------
69
70
71    def elevation_tilt(x, y):
72        return x*slope
73       
74    domain.set_quantity('stage', elevation_tilt)
75    domain.set_quantity('friction', friction) 
76    domain.set_quantity('elevation',elevation_tilt)
77
78    domain.set_region('dam','stage',inital_depth,
79                                 location = 'unique vertices') 
80
81    Br = Reflective_boundary(domain)
82    Bd = Dirichlet_boundary([0,0,0])  # to drain the water out.
83    domain.set_boundary( {'wall': Br, 'edge': Bd} )
84
85    #-------------------------------------------------------------------------
86    # Evolve system through time
87    #-------------------------------------------------------------------------
88    t0 = time.time()
89
90    for t in domain.evolve(yieldstep = 0.1, finaltime = 10):
91        pass
92
93    # Load actual experimental results
94    actual,title_index_dic = load_csv_as_dict(project.actual_filename)
95   
96    gauge_locations = [[0.4,0.2]]
97    quantities = ['stage', 'elevation']
98    file_instance = file_function( project.basename +".sww",
99                                      quantities = quantities,
100                                      interpolation_points = gauge_locations,
101                                      verbose = False,
102                                      use_cache = False)
103    # create a list of the simulated_depths at the actual data times.
104    simulated_depths = []
105    for atime in actual['time']:
106        quantities_slice = file_instance(float(atime),
107                                         point_id=0)
108        depth = quantities_slice[0] - quantities_slice[1]
109        simulated_depths.append(depth)
110    flume_depths = actual["0.4:0.2"]
111    flume_depths = [float(i) for i in flume_depths]
112    # calc the norm
113    #print "map(None, simulated_depths, flume_depths)", \
114    #      map(None, simulated_depths, flume_depths)
115    norm = err(simulated_depths,
116               flume_depths, 2, relative = True)  # 2nd norm (rel. RMS
117    return norm
118#-------------------------------------------------------------
119if __name__ == "__main__":
120    main()
121   
Note: See TracBrowser for help on using the repository browser.