Changeset 518 for inundation/ga/storm_surge/pyvolution/shallow_water.py
- Timestamp:
- Nov 10, 2004, 5:22:27 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/shallow_water.py
r515 r518 745 745 # 746 746 def 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 749 748 """ 750 749 … … 855 854 856 855 857 856 class 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 858 965 859 966 def wind_stress(domain):
Note: See TracChangeset
for help on using the changeset viewer.