source: trunk/anuga_core/source/anuga_validation_tests/Analytical_exact/lake_at_rest_varying_width/numerical_varying_width.py @ 8878

Last change on this file since 8878 was 8878, checked in by mungkasi, 11 years ago

Adding lake at rest with varying width and bottom.

File size: 4.9 KB
Line 
1"""Simple water flow example using ANUGA
2
3Water driven up a linear slope and time varying boundary,
4similar to a beach environment
5"""
6
7#------------------------------------------------------------------------------
8# Import necessary modules
9#------------------------------------------------------------------------------
10import sys
11import anuga
12from anuga import Domain as Domain
13from math import cos
14from numpy import zeros, ones, array, interp, polyval
15from time import localtime, strftime, gmtime
16from scipy.interpolate import interp1d
17#from balanced_dev import *
18
19
20#-------------------------------------------------------------------------------
21# Copy scripts to time stamped output directory and capture screen
22# output to file
23#-------------------------------------------------------------------------------
24time = strftime('%Y%m%d_%H%M%S',localtime())
25
26#output_dir = 'varying_width'+time
27output_dir = '.'
28output_file = 'varying_width'
29
30#anuga.copy_code_files(output_dir,__file__)
31#start_screen_catcher(output_dir+'_')
32
33
34#------------------------------------------------------------------------------
35# Setup domain
36#------------------------------------------------------------------------------
37dx = 1.
38dy = dx
39L = 1500.
40W = 60.
41
42# structured mesh
43points, vertices, boundary = anuga.rectangular_cross(int(L/dx), int(W/dy), L, W, (0.,-W/2.))
44
45#domain = anuga.Domain(points, vertices, boundary)
46domain = Domain(points, vertices, boundary) 
47
48domain.set_name(output_file)               
49domain.set_datadir(output_dir) 
50
51#------------------------------------------------------------------------------
52# Setup Algorithm, either using command line arguments
53# or override manually yourself
54#------------------------------------------------------------------------------
55from anuga.utilities.argparsing import parse_standard_args
56alg, cfl = parse_standard_args()
57domain.set_flow_algorithm(alg)
58domain.set_CFL(cfl)
59
60#------------------------------------------------------------------------------
61# Setup initial conditions
62#------------------------------------------------------------------------------
63domain.set_quantity('friction', 0.0)
64domain.set_quantity('stage', 12.0)
65XX = array([0.,50.,100.,150.,250.,300.,350.,400.,425.,435.,450.,470.,475.,500.,
66            505.,530.,550.,565.,575.,600.,650.,700.,750.,800.,820.,900.,950.,
67            1000.,1500.])
68ZZ = array([0.,0.,2.5,5.,5.,3.,5.,5.,7.5,8.,9.,9.,9.,9.1,9.,9.,6.,5.5,5.5,5.,
69            4.,3.,3.,2.3,2.,1.2,0.4,0.,0.])
70WW = array([40.,40.,30.,30.,30.,30.,25.,25.,30.,35.,35.,40.,40.,40.,45.,45.,50.,
71            45.,40.,40.,30.,40.,40.,5.,40.,35.,25.,40.,40.])/2.
72
73print "Start here"
74def bed_elevation(x,y):
75    z = 25.*ones(len(x), float)
76    for i in range(len(XX)-1):
77        for j in range(len(x)):
78            if XX[i] <= x[j] <= XX[i+1]:
79                v1 = [XX[i+1]-XX[i], WW[i+1]-WW[i]]
80                v2 = [XX[i+1]-x[j], WW[i+1]-abs(y[j])]
81                xp = v1[0]*v2[1] - v1[1]*v2[0]
82                #if 0.0 <= abs(y[j]) <= interp1d([XX[i],XX[i+1]], [WW[i],WW[i+1]])(y[j]):
83                if xp >= 0:
84                    z[j] = interp1d([XX[i],XX[i+1]], [ZZ[i],ZZ[i+1]])(x[j])
85    return z
86domain.set_quantity('elevation', bed_elevation)
87print "Start now"
88
89#-----------------------------------------------------------------------------
90# Setup boundary conditions
91#------------------------------------------------------------------------------
92from math import sin, pi, exp
93Br = anuga.Reflective_boundary(domain)      # Solid reflective wall
94#Bt = anuga.Transmissive_boundary(domain)    # Continue all values on boundary
95#Bd = anuga.Dirichlet_boundary([1,0.,0.]) # Constant boundary values
96
97# Associate boundary tags with boundary objects
98domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
99
100
101#===============================================================================
102##from anuga.visualiser import RealtimeVisualiser
103##vis = RealtimeVisualiser(domain)
104##vis.render_quantity_height("stage", zScale =h0*500, dynamic=True)
105##vis.colour_height_quantity('stage', (0.0, 0.5, 1.0))
106##vis.start()
107#===============================================================================
108
109
110#------------------------------------------------------------------------------
111# Produce a documentation of parameters
112#------------------------------------------------------------------------------
113parameter_file=open('parameters.tex', 'w')
114parameter_file.write('\\begin{verbatim}\n')
115from pprint import pprint
116pprint(domain.get_algorithm_parameters(),parameter_file,indent=4)
117parameter_file.write('\\end{verbatim}\n')
118parameter_file.close()
119
120#------------------------------------------------------------------------------
121# Evolve system through time
122#------------------------------------------------------------------------------
123for t in domain.evolve(yieldstep = 0.1, finaltime = 5.0):
124    #print domain.timestepping_statistics(track_speeds=True)
125    print domain.timestepping_statistics()
126    #vis.update()
127
128
129#test against know data
130   
131#vis.evolveFinished()
132
Note: See TracBrowser for help on using the repository browser.