- Timestamp:
- Nov 23, 2004, 5:55:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/wind_example_variable.py
r613 r614 9 9 # 10 10 from mesh_factory import rectangular 11 from shallow_water import Domain, Reflective_boundary, Wind_stress11 from shallow_water import Domain, Dirichlet_boundary, Wind_stress 12 12 13 13 #Create basic mesh 14 N = 8015 length = 10014 N = 120 15 length = 200 16 16 points, vertices, boundary = rectangular(N, N, length, length) 17 17 … … 25 25 26 26 #Set initial conditions 27 h = 1.0 27 28 domain.set_quantity('elevation', 0.0) 28 domain.set_quantity('level', 2.0)29 domain.set_quantity('friction', 0.0 7)29 domain.set_quantity('level', h) 30 domain.set_quantity('friction', 0.01) 30 31 31 32 … … 36 37 """ 37 38 38 from math import sqrt, exp, cos, pi 39 40 N = len(x) 41 s = 0*x #New array 39 from math import pi 40 from Numeric import sqrt, exp, cos 42 41 43 42 c = (length/2, length/2) 44 45 for k in range(N): 46 r = sqrt((x[k] - c[0])**2 + (y[k] - c[1])**2) 43 r = sqrt((x - c[0])**2 + (y - c[1])**2)/length 44 factor = exp( -(r-0.15)**2 ) 47 45 48 r /= max(length,length) 49 50 factor = exp( -(r-0.15)**2 ) 51 52 s[k] = 4000 * factor * (cos(t*2*pi/150) + 2) 53 54 return s 46 #return 9000 * factor 47 return 4000 * factor * (cos(t*2*pi/150) + 2) 55 48 56 49 … … 58 51 """Rotating field 59 52 """ 60 from math import sqrt, atan, pi 61 62 N = len(x) 63 a = 0*x #New array 53 54 from math import pi 55 from Numeric import sqrt, exp, cos, arctan2, choose, less 64 56 65 57 c = (length/2, length/2) 66 for k in range(N): 67 r = sqrt((x[k] - c[0])**2 + (y[k] - c[1])**2) 58 xx = (x - c[0])/length 59 yy = (y - c[1])/length 60 angle = arctan2(yy,xx) 68 61 69 xx = (x[k] - c[0])/length 70 yy = (y[k] - c[1])/length 62 #Take normal direction (but reverse direction every 50 seconds) 63 #if sin(t*2*pi/100) < 0: 64 # sgn = -1 65 #else: 66 # sgn = 1 67 #angle += sgn*pi/2 68 angle -= pi/2 71 69 72 angle = atan(yy/xx) 73 74 if xx < 0: 75 angle+=pi #atan in ]-pi/2; pi/2[ 76 77 #Take normal direction 78 angle -= pi/2 79 80 #Ensure positive radians 81 if angle < 0: 82 angle += 2*pi 83 84 a[k] = angle/pi*180 85 86 return a 70 #Convert to degrees and return 71 return angle/pi*180 87 72 88 73 … … 109 94 ###################### 110 95 # Boundary conditions 111 Br = Reflective_boundary(domain) 112 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br}) 96 #Br = Reflective_boundary(domain) 97 Bd = Dirichlet_boundary([h, 0, 0]) 98 domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd}) 113 99 114 100 ######################
Note: See TracChangeset
for help on using the changeset viewer.