Changeset 518


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

Looked at friction

Location:
inundation/ga/storm_surge/pyvolution
Files:
4 edited

Legend:

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

    r486 r518  
    433433
    434434
     435    def get_centroid_coordinates(self):
     436        """Return all centroid coordinates.
     437        Return all centroid coordinates for all triangles as an Nx2 array
     438        (ordered as x0, y0 for each triangle)       
     439        """
     440        return self.centroid_coordinates
  • inundation/ga/storm_surge/pyvolution/shallow_water.py

    r515 r518  
    745745#
    746746def gravity(domain):
    747     """Implement forcing function for bed slope working with
    748     consecutive data structures of class Volume
     747    """Apply gravitational pull in the presence of bed slope
    749748    """
    750749
     
    855854       
    856855
    857 
     856class Wind_stress:
     857    """Apply wind stress to water momentum
     858    """
     859
     860    def __init__(self, s, phi):
     861        """Initialise windfield from wind speed s [m/s]
     862        and wind direction phi [degrees]
     863       
     864        Inputs v and phi can be either scalars or Python functions, e.g.
     865
     866        W = Wind_stress(10, 178)
     867
     868        #FIXME - 'normal' degrees are assumed for now, i.e. the
     869        vector (1,0) has zero degrees.
     870        We may need to convert from 'compass' degrees later on and also
     871        map from True north to grid north.
     872
     873        Arguments can also be Python functions of x,y,t as in
     874
     875        def speed(x,y,t):
     876            ...
     877            return s
     878       
     879        def angle(x,y,t):
     880            ...
     881            return phi
     882
     883       
     884
     885        and then pass the functions in
     886
     887        W = Wind_stress(speed, angle)
     888
     889        The instantiated object W can be appended to the list of
     890        forcing_terms as in
     891
     892        domain.forcing_terms.append(W)
     893       
     894        """
     895
     896        self.s = s
     897        self.phi = phi
     898
     899        #FIXME: Maybe move to config or read from domain
     900        Cw = 3.0e-3 #Wind stress coefficient
     901        rho_a = 1.2e-3 #Atmospheric density
     902        rho = 1023 #Density of water
     903       
     904        self.const = Cw*rho_a/rho
     905       
     906
     907    def __call__(self, domain):
     908        """Evaluate windfield based on values found in domain
     909        """
     910
     911        from math import pi, cos, sin, sqrt
     912       
     913        xmom_update = domain.quantities['xmomentum'].explicit_update
     914        ymom_update = domain.quantities['ymomentum'].explicit_update   
     915       
     916        N = domain.number_of_elements
     917       
     918        if callable(self.s) or callable(self.phi):
     919            xc = domain.get_centroid_coordinates()
     920            t = domain.time
     921
     922            maxphi = -100
     923            minphi = 100
     924            for k in range(N):
     925                x, y = xc[k,:]   
     926
     927                if callable(self.s):
     928                    s = self.s(x,y,t)
     929                else:
     930                    s = self.s
     931
     932                if callable(self.phi):
     933                    phi = self.phi(x,y,t)
     934                else:
     935                    phi = self.phi                 
     936
     937                #Convert to radians
     938                phi = phi*pi/180
     939       
     940                #Compute velocity vector (u, v)
     941                u = s*cos(phi)
     942                v = s*sin(phi)
     943
     944                #Compute wind stress
     945                S = self.const * sqrt(u**2 + v**2)
     946                xmom_update[k] += S*u
     947                ymom_update[k] += S*v       
     948           
     949               
     950        else:
     951            #Constants
     952           
     953            #Convert to radians
     954            phi = self.phi*pi/180
     955       
     956            #Compute velocity vector (u, v)
     957            u = self.s*cos(phi)
     958            v = self.s*sin(phi)
     959
     960            #Compute wind stress
     961            S = self.const * sqrt(u**2 + v**2)
     962            xmom_update += S*u
     963            ymom_update += S*v       
     964       
    858965       
    859966def wind_stress(domain):
  • inundation/ga/storm_surge/pyvolution/shallow_water_ext.c

    r515 r518  
    168168      if (h >= eps) {
    169169        S = -g * eta[k]*eta[k] * sqrt((uh[k]*uh[k] + vh[k]*vh[k]));
    170         S /= pow(h, 7.0/3);      //Expensive
    171         //S /= h*h*(1 + h/3.0 - h*h/9.0);  //FIXME: Use a Taylor expansion
    172         //FIXME: This will save a lot of time
     170        S /= pow(h, 7.0/3);      //Expensive (on Ole's home computer)
     171        //S /= h*h*(1 + h/3.0 - h*h/9.0); //FIXME: Could use a Taylor expansion
     172
    173173
    174174        //Update momentum
  • inundation/ga/storm_surge/pyvolution/treenode.py

    r482 r518  
    3939
    4040
     41    #Make treenode elements appear as sequences such thta on
     42    #can iterate over them             
    4143    def __iter__(self):
    4244        self.index = -1   # incremented on first call to next()
Note: See TracChangeset for help on using the changeset viewer.