Ignore:
Timestamp:
Nov 23, 2004, 5:55:46 PM (20 years ago)
Author:
ole
Message:

Played with wind stress + c-extension

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/wind_example_variable.py

    r613 r614  
    99#
    1010from mesh_factory import rectangular
    11 from shallow_water import Domain, Reflective_boundary, Wind_stress
     11from shallow_water import Domain, Dirichlet_boundary, Wind_stress
    1212
    1313#Create basic mesh
    14 N = 80
    15 length = 100
     14N = 120
     15length = 200
    1616points, vertices, boundary = rectangular(N, N, length, length)
    1717
     
    2525
    2626#Set initial conditions
     27h = 1.0
    2728domain.set_quantity('elevation', 0.0)
    28 domain.set_quantity('level', 2.0)
    29 domain.set_quantity('friction', 0.07)
     29domain.set_quantity('level', h)
     30domain.set_quantity('friction', 0.01)
    3031
    3132
     
    3637    """
    3738
    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
    4241
    4342    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 )
    4745
    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)
    5548
    5649
     
    5851    """Rotating field
    5952    """
    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
    6456
    6557    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)
    6861
    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   
    7169
    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
    8772
    8873   
     
    10994######################
    11095# Boundary conditions
    111 Br = Reflective_boundary(domain)
    112 domain.set_boundary({'left': Br, 'right': Br, 'top': Br, 'bottom': Br})
     96#Br = Reflective_boundary(domain)
     97Bd = Dirichlet_boundary([h, 0, 0])
     98domain.set_boundary({'left': Bd, 'right': Bd, 'top': Bd, 'bottom': Bd})
    11399
    114100######################
Note: See TracChangeset for help on using the changeset viewer.