source: inundation/ga/storm_surge/pyvolution/wind_example_rot.py @ 546

Last change on this file since 546 was 527, checked in by ole, 20 years ago

Wind fields

File size: 2.1 KB
Line 
1"""Example of shallow water wave equation.
2
3Flat bed with rotational wind stress
4
5"""
6
7######################
8# Module imports
9#
10from mesh_factory import rectangular
11from shallow_water import Domain, Reflective_boundary, Wind_stress
12
13#Create basic mesh
14N = 80
15len = 100
16points, vertices, boundary = rectangular(N, N, len, len)
17
18#Create shallow water domain
19domain = Domain(points, vertices, boundary)
20domain.smooth = True
21domain.visualise = False
22domain.store = True
23domain.default_order=2
24domain.set_name('wind_rotation')
25
26#Set initial conditions
27domain.set_quantity('elevation', 0.0)
28domain.set_quantity('level', 2.0)
29domain.set_quantity('friction', 0.0)
30
31
32#Variable windfield implemented using functions
33def speed(x,y,t):
34    """Large speeds halfway between center and edges
35    Low speeds at center and edges
36    """
37   
38    from math import sqrt, exp, cos, pi
39   
40    c = (len1/2, len2/2)
41    r = sqrt((x - c[0])**2 + (y - c[1])**2)
42
43    r /= max(len1,len2)
44
45    factor = exp( -(r-0.15)**2 )
46       
47    #print x,y,factor
48
49    return 4000 * factor * (cos(t*2*pi/150) + 2)
50
51
52def phi(x,y,t):
53    """Rotating field
54    """
55    from math import sqrt, atan, pi
56
57    c = (len1/2, len2/2)
58    r = sqrt((x - c[0])**2 + (y - c[1])**2)   
59   
60    xx = (x - c[0])/len1
61    yy = (y - c[1])/len2
62
63    angle = atan(yy/xx)
64
65    if xx < 0:
66        angle+=pi #atan in ]-pi/2; pi/2[
67
68    #Take normal direction
69    angle -= pi/2
70   
71    #Ensure positive radians   
72    if angle < 0:
73        angle += 2*pi
74
75    return angle/pi*180
76
77   
78domain.forcing_terms.append( Wind_stress(speed, phi) )
79
80
81#Add lateral wind gusts bearing 25 deg
82def gust(x,y,t): 
83    from math import sin, pi
84
85    tt = sin(2*pi*t/200)
86
87    if tt > 0.9:
88        return 6000*tt
89    else:
90        return 0
91   
92domain.forcing_terms.append(Wind_stress(gust, 25))
93
94
95######################
96# Boundary conditions
97Br = Reflective_boundary(domain)
98domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
99
100######################
101#Evolution
102for t in domain.evolve(yieldstep = 0.5, finaltime = 1000):
103    domain.write_time()
104
105print 'Done'   
106
Note: See TracBrowser for help on using the repository browser.