source: anuga_validation/UQ_runup_2006/run_dam.py @ 4678

Last change on this file since 4678 was 4678, checked in by ole, 16 years ago

Added validation scripts and data from UQ (Matt Barnes). It does not run yet.
Also committed work on solitary_wave_runup.py

File size: 5.4 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
23from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \
24     copy_code_files
25import create_mesh
26
27# Application specific imports
28
29
30def main():
31     
32    slopes = [0]
33    frictions = [0.005, 0.01, 0.03] #can enter multiple frictions eg [0.00, 0.01]
34    inital_depths = [0.2] #can enter multiple initial depths eg [0.1, 0.2]
35    gate_positions = [0.75]
36    flume_lengths = [3] #can enter multiple flume lengths eg [3.0, 5.0]
37   
38    for slope in slopes:
39        for friction in frictions:
40            for inital_depth in inital_depths:
41                for flume_length in flume_lengths:
42                    for gate_position in gate_positions:
43                        scenario(slope, friction, inital_depth, gate_position, flume_length)
44           
45
46def scenario(slope, friction, inital_depth, gate_position, flume_length):
47   
48    import project                 # Definition of file names and polygons
49
50    #-------------------------------------------------------------------------
51    # Setup archiving of simulations
52    #-------------------------------------------------------------------------
53
54    id = 'd'+ str(inital_depth) + '_s'+str(slope)+'_g'+ str(gate_position)+ '_n'+ str(friction)
55    copy (project.codedirname, project.outputtimedir + 'project.py')
56    run_name = 'run_dam.py'
57    run_name_out = 'run_dam'+id+'.py'
58
59    copy (project.codedir + run_name, project.outputtimedir + run_name_out)
60    copy (project.codedir + 'create_mesh.py',
61          project.outputtimedir + 'create_mesh.py')
62    print'output dir', project.outputtimedir
63
64    #FIXME this isn't working
65    #normal screen output is stored in
66    screen_output_name = project.outputtimedir + "screen_output.txt"
67    screen_error_name = project.outputtimedir + "screen_error.txt"
68
69    #-------------------------------------------------------------------------
70    # Create the triangular mesh
71    #-------------------------------------------------------------------------
72
73    create_mesh.generate(project.mesh_filename,
74                         gate_position, flume_length,
75                         #is_course=True) # this creates the mesh
76                         is_course=False) # this creates the mesh
77
78    head,tail = path.split(project.mesh_filename)
79    copy (project.mesh_filename,
80          project.outputtimedir + tail )
81    #-------------------------------------------------------------------------
82    # Setup computational domain
83    #-------------------------------------------------------------------------
84    domain = Domain(project.mesh_filename, use_cache = False, verbose = True)
85   
86
87    print 'Number of triangles = ', len(domain)
88    print 'The extent is ', domain.get_extent()
89    print domain.statistics()
90
91   
92    domain.set_name(project.basename + id)
93    domain.set_datadir(project.outputtimedir)
94    domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
95    domain.set_minimum_storable_height(0.001)
96    domain.set_store_vertices_uniquely(True)  # for writting to sww
97
98    #-------------------------------------------------------------------------
99    # Setup initial conditions
100    #-------------------------------------------------------------------------
101
102
103    def elevation_tilt(x, y):
104        return x*slope
105       
106    domain.set_quantity('stage', elevation_tilt)
107    domain.set_quantity('friction', friction) 
108    domain.set_quantity('elevation',elevation_tilt)
109
110    print 'Available boundary tags', domain.get_boundary_tags()
111    domain.set_region('dam','stage',inital_depth,
112                                 location = 'unique vertices') 
113
114    Br = Reflective_boundary(domain)
115    Bd = Dirichlet_boundary([0,0,0])  # to drain the water out.
116    domain.set_boundary( {'wall': Br, 'edge': Bd} )
117
118    #-------------------------------------------------------------------------
119    # Evolve system through time
120    #-------------------------------------------------------------------------
121    t0 = time.time()
122
123    for t in domain.evolve(yieldstep = 0.1, finaltime = 10): #enter timestep and final time
124        domain.write_time()
125   
126        print 'That took %.2f seconds' %(time.time()-t0)
127        print 'finished'
128
129    points = [[0.45, 0.2]]
130             
131
132    #-------------------------------------------------------------------------
133    # Calculate gauge info
134    #-------------------------------------------------------------------------
135    #interpolate_sww2csv(project.outputtimedir + project.basename \
136     #              + id+".sww",
137      #                  points,
138       #                 project.depth_filename + id + '.csv',
139        #                project.velocity_x_filename + id + '.csv',
140         #               project.velocity_y_filename + id + '.csv')
141
142#-------------------------------------------------------------
143if __name__ == "__main__":
144    main()
145   
Note: See TracBrowser for help on using the repository browser.