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

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

Committed wind field with examples.
This may need a C-implementation for speed.

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