Ignore:
Timestamp:
Nov 22, 2004, 5:29:10 PM (20 years ago)
Author:
ole
Message:

Work towards wind_field - it now accepts vect values fuctions or scalars

File:
1 edited

Legend:

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

    r610 r612  
    1313#Create basic mesh
    1414N = 80
    15 len = 100
    16 points, vertices, boundary = rectangular(N, N, len, len)
     15length = 100
     16points, vertices, boundary = rectangular(N, N, length, length)
    1717
    1818#Create shallow water domain
     
    3535    Low speeds at center and edges
    3636    """
     37
     38    from math import sqrt, exp, cos, pi
     39
     40    N = len(x)
     41    s = 0*x  #New array
     42
     43    c = (length/2, length/2)
    3744   
    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)
     45    for k in range(N):
     46        r = sqrt((x[k] - c[0])**2 + (y[k] - c[1])**2)
    4247
    43     r /= max(len1,len2)
     48        r /= max(length,length)
    4449
    45     factor = exp( -(r-0.15)**2 )
     50        factor = exp( -(r-0.15)**2 )
    4651       
    47     #print x,y,factor
     52        s[k] = 4000 * factor * (cos(t*2*pi/150) + 2)
    4853
    49     return 4000 * factor * (cos(t*2*pi/150) + 2)
     54    return s
    5055
    5156
     
    5560    from math import sqrt, atan, pi
    5661
    57     c = (len1/2, len2/2)
    58     r = sqrt((x - c[0])**2 + (y - c[1])**2)   
     62    N = len(x)
     63    a = 0*x  #New array
     64
     65    c = (length/2, length/2)
     66    for k in range(N):
     67        r = sqrt((x[k] - c[0])**2 + (y[k] - c[1])**2)
     68
     69        xx = (x[k] - c[0])/length
     70        yy = (y[k] - c[1])/length
     71
     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
    5979   
    60     xx = (x - c[0])/len1
    61     yy = (y - c[1])/len2
     80        #Ensure positive radians   
     81        if angle < 0:
     82            angle += 2*pi
    6283
    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
     84        a[k] = angle/pi*180
     85       
     86    return a
    7687
    7788   
     
    8293def gust(x,y,t):
    8394    from math import sin, pi
     95    from Numeric import zeros, ones, Float
     96
     97    N = len(x)
    8498
    8599    tt = sin(2*pi*t/200)
    86100
    87101    if tt > 0.9:
    88         return 6000*tt
     102        return 6000*tt*ones(N, Float)
    89103    else:
    90         return 0
     104        return zeros(N, Float)
    91105   
    92106domain.forcing_terms.append(Wind_stress(gust, 25))
Note: See TracChangeset for help on using the changeset viewer.