source: inundation/analytical solutions/Analytical_solution_circular_hydraulic_jump.py @ 1889

Last change on this file since 1889 was 1876, checked in by steve, 20 years ago

fixed problem with BC for circular hydraulic jump.

File size: 4.6 KB
Line 
1"""Example of shallow water wave equation analytical solution of the
2circular hydraulic jump experimental data treated as a two-dimensional solution.
3
4   Copyright 2005
5   Christopher Zoppou, Stephen Roberts
6   Geoscience Australia, ANU
7"""
8
9#-------------------------------
10# Set up path and module imports
11import sys
12from os import sep
13sys.path.append('..'+sep+'pyvolution')
14
15from shallow_water import Domain, Dirichlet_Discharge_boundary
16from shallow_water import Transmissive_Momentum_Set_Stage_boundary, Dirichlet_boundary
17from math import pi, sqrt
18from mesh_factory import strang_mesh
19
20#---------
21# Geometry
22bed = ([.519, .519, .519, .519, .5192, .5194, .5196, .520, .5207, .5215, .5233, .5233])
23distance = ([.08, .10, .11, .16, .21, .26, .31, .36, .41, .46, .50, .52])
24n_bed = 12
25
26#---------
27# Case A.4
28Q = 9.985/1000.0
29wh0 = Q/(2.0*pi*0.1)
30h0 = bed[2] + 0.005
31wh1 = -Q/(2.0*pi*0.5)
32h1 = 0.562
33Manning = 0.009
34
35#------------------
36# Set up the domain
37# Strang_domain will search through the file and test to see if there are
38# two or three entries. Two entries are for points and three for triangles.
39points, elements = strang_mesh('circular.pt')
40domain = Domain(points, elements)
41
42print "Number of triangles = ", len(domain)
43
44#----------------------
45# Set a default tagging
46
47
48for id, face in domain.boundary:
49    domain.boundary[(id,face)] = 'outer'
50    point = domain.get_vertex_coordinate(id,(face+1)%3)
51    radius2 = point[0]*point[0] + point[1]*point[1]
52    typical_outer = (id,face)
53    if radius2 < 0.1:
54        domain.boundary[(id,face)] = 'inner'
55        typical_inner = (id,face)
56
57
58#-------------------------------------
59# Provide file name for storing output
60#domain.visualise = True
61domain.store = True
62domain.format = 'sww'
63domain.filename = 'circular_second_order'
64
65#------------------------------------------
66# Reduction operation for get_vertex_values
67from util import mean
68domain.reduction = mean
69#domain.reduction = min  #Looks better near steep slopes
70
71#---------------------------
72# Function for bed-elevation
73def bed_z(x,y):
74    n = x.shape[0]
75    z = 0*x
76    for i in range(n):
77        r = sqrt(x[i]*x[i]+y[i]*y[i])
78        for j in range(n_bed-1):
79            if distance[j] <= r:
80                if distance[j+1] > r:
81                    z[i] = bed[0]
82                    #bed[j] + (bed[j+1] - bed[j])/(distance[j+1] - distance[j])*(r - distance[j])
83    return z
84domain.set_quantity('elevation', bed_z)
85
86#---------
87# Friction
88domain.set_quantity('friction', Manning)
89
90#---------------------------------
91# Function for initial water depth
92def level(x,y):
93    z = bed_z(x,y)
94    n = x.shape[0]
95    w = 0*x
96    for i in range(n):
97        w[i] = h0
98        h = w[i] - z[i]
99    return w
100
101
102def outflow_height(t):
103    return [h1, 0 , 0]
104
105
106domain.set_quantity('stage', level)
107
108#---------------------------
109# Set up boundary conditions
110DD_BC_INNER = Dirichlet_Discharge_boundary(domain, h0, wh0)
111DD_BC_OUTER = Dirichlet_Discharge_boundary(domain, h1, wh1)
112
113domain.set_boundary({'inner': DD_BC_INNER, 'outer': DD_BC_OUTER})
114
115#------------------
116# Order of accuracy
117domain.default_order = 1
118domain.CFL = 0.75
119#domain.beta_w = 0.5
120#domain.beta_h = 0.2
121domain.smooth = True
122
123
124
125
126domain.initialise_visualiser()
127    #domain.visualiser.coloring['stage'] = True
128domain.visualiser.scale_z['stage'] = 2.0
129domain.visualiser.scale_z['elevation'] = 0.05
130
131
132from realtime_visualisation_new import Visualiser
133#vxmom = Visualiser(domain,title='xmomentum',scale_z=10.0)
134#vymom = Visualiser(domain,title='ymomentum',scale_z=10.0)
135
136
137#----------
138# Evolution
139import time
140
141t0 = time.time()
142for t in domain.evolve(yieldstep = .01, finaltime = 10):
143    domain.write_time()
144    #vxmom.update_quantity('xmomentum')
145    #vymom.update_quantity('ymomentum')
146    print 'outer stage      ',domain.quantities['stage'].get_values(location='centroids',indices=[typical_outer[0]])
147    print '      radial mom ',sqrt(domain.quantities['xmomentum'].get_values(location='centroids',indices=[typical_outer[0]])[0]**2 +
148                                   domain.quantities['ymomentum'].get_values(location='centroids',indices=[typical_outer[0]])[0]**2)
149    print 'inner stage      ',domain.quantities['stage'].get_values(location='centroids',indices=[typical_inner[0]])
150    print '      radial mom ',sqrt(domain.quantities['xmomentum'].get_values(location='centroids',indices=[typical_inner[0]])[0]**2 +
151                                   domain.quantities['ymomentum'].get_values(location='centroids',indices=[typical_inner[0]])[0]**2)
152
153
154print 'That took %.2f seconds' %(time.time()-t0)
Note: See TracBrowser for help on using the repository browser.