Home > utilities > calc_tauw.m

calc_tauw

PURPOSE ^

DESCRIPTION:

SYNOPSIS ^

function [tauw] = calc_tauw(z0,ncfile,writenetcdf)

DESCRIPTION ^

 DESCRIPTION:
    Function used to calculate Wave Bed Shear Stress, tauw, from the
    bottom orbital velocity (Ubot) and the bottom wave period (TmBot). 
    This function is currently set up to extract these values from SWAN
    output. Currently temperature, salinity and z0 are set to be constant
    accross the domain. Using actual data could improve accuaracy.
    
    REQUIRES FVCOM_TOOLBOX to be in your MATLAB path
 

 INPUT 
   z0           = bed roughness length (z0=d50/12) [mm]
   <=={possibly use constant value 0.05 Soulsby pg. 49}==>
   
   ncfile       = netcdf file containing Ubot & TmBot
                  that was created from swan2netcdf.m
   
   writenetcdf  = accepts either true or false 
                  if 'True' write tauw and fw to netcdf
   
    
   

 OUTPUT:
    tauw = array containing values of tauw at all time for each node in 
    model domain

 EXAMPLE USAGE
    tauw = calc_tauw(z0,'skg4.3.nc',true); 
    

 Author(s):  
    Eric Holmes (University of Massachusetts Dartmouth)

 Revision history
    Initially created 09-24-2010
   
==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [tauw] = calc_tauw(z0,ncfile,writenetcdf) 
0002 
0003 % DESCRIPTION:
0004 %    Function used to calculate Wave Bed Shear Stress, tauw, from the
0005 %    bottom orbital velocity (Ubot) and the bottom wave period (TmBot).
0006 %    This function is currently set up to extract these values from SWAN
0007 %    output. Currently temperature, salinity and z0 are set to be constant
0008 %    accross the domain. Using actual data could improve accuaracy.
0009 %
0010 %    REQUIRES FVCOM_TOOLBOX to be in your MATLAB path
0011 %
0012 %
0013 % INPUT
0014 %   z0           = bed roughness length (z0=d50/12) [mm]
0015 %   <=={possibly use constant value 0.05 Soulsby pg. 49}==>
0016 %
0017 %   ncfile       = netcdf file containing Ubot & TmBot
0018 %                  that was created from swan2netcdf.m
0019 %
0020 %   writenetcdf  = accepts either true or false
0021 %                  if 'True' write tauw and fw to netcdf
0022 %
0023 %
0024 %
0025 %
0026 % OUTPUT:
0027 %    tauw = array containing values of tauw at all time for each node in
0028 %    model domain
0029 %
0030 % EXAMPLE USAGE
0031 %    tauw = calc_tauw(z0,'skg4.3.nc',true);
0032 %
0033 %
0034 % Author(s):
0035 %    Eric Holmes (University of Massachusetts Dartmouth)
0036 %
0037 % Revision history
0038 %    Initially created 09-24-2010
0039 %
0040 %==============================================================================
0041 
0042 %------------------------------------------------------------------------------
0043 % Convert z0 to meters
0044 %------------------------------------------------------------------------------
0045 z0 = z0/1000;
0046 
0047 %------------------------------------------------------------------------------
0048 % Set Ubot & TmBot from netCDF file
0049 %------------------------------------------------------------------------------
0050 nc = netcdf(ncfile,'w');
0051 
0052 nctime=ncdim('time',nc);
0053 nctime = size(nctime);
0054 nctime=nctime(1,1);
0055 ncnode=ncdim('node',nc);
0056 node = size(ncnode);
0057 node = node(1,1);
0058 Ubot = ncvar('Ubot',nc);
0059 Ubot = Ubot.*ones(nctime,node);
0060 TmBot = ncvar('TmBot',nc);
0061 TmBot = TmBot.*ones(nctime,node);
0062 
0063 
0064 
0065 %------------------------------------------------------------------------------
0066 % Set Generic Values to Salinity and Temperature
0067 % This is temporary, it would be better to use actual salinity and
0068 % temperature data.
0069 %------------------------------------------------------------------------------
0070 vectorsize=size(Ubot);
0071 T=zeros(vectorsize);
0072 S=zeros(vectorsize);
0073 
0074 T(:,:)=15;
0075 S(:,:)=30;
0076 
0077 %------------------------------------------------------------------------------
0078 % Call Kinematic Viscosity Routine and Density Routine
0079 %------------------------------------------------------------------------------
0080 nu = SW_Kviscosity(T,S); %
0081 rho = SW_Density(T,S); %
0082 
0083 
0084 %------------------------------------------------------------------------------
0085 % Calculate fwr & fws according to Soulsby pg. 77-79
0086 %------------------------------------------------------------------------------
0087 
0088 %----CONSTANTS-----------------------------------------------------------------
0089 %ks = z0*30.;                    % Nikuradse roughness
0090 A = Ubot.*TmBot/(2.*pi);        % semi-orbital excursion
0091 % r = A/ks;                     % relative roughness
0092 Rw = Ubot.*A./nu;                 % wave Reynolds
0093 %------------------------------------------------------------------------------
0094 fwr = 1.39*(A/z0).^(-0.52);     % case in which flow is rough turbulent
0095                                 % Soulsby (62a)
0096 
0097                                 % Smooth Cases
0098 for i = 1:vectorsize(1,1)
0099     for j = 1:vectorsize(1,2)
0100         if(Rw(i,j) > 5e5)
0101             B=0.0521; N=0.187;  % case in which flow is smooth turbulent
0102         else
0103             B=2; N=0.5;         % case in which flow is laminar
0104         end;
0105     end
0106 end
0107                                 
0108 fws = B*Rw.^(-N);               % smooth bed friction factor Soulsby (63)
0109 
0110 %------------------------------------------------------------------------------
0111 % Choose wave friction factor for current conditions
0112 %------------------------------------------------------------------------------
0113 fw = zeros(vectorsize);
0114 
0115 for i = 1:vectorsize(1,1)
0116     for j = 1:vectorsize(1,2)
0117         fw(i,j) = max(fwr(i,j),fws(i,j));   
0118                                 % wave friction factor
0119     end;
0120 end;
0121 
0122 tauw = 0.5*rho.*fw.*Ubot.*Ubot;    % wave shear stress
0123 %tauw(isnan(tauw)) = 0;
0124 
0125 %------------------------------------------------------------------------------
0126 % Write Values of tauw to ncfile
0127 %------------------------------------------------------------------------------
0128 if (writenetcdf == true)
0129         
0130     nc = netcdf(ncfile,'w');
0131     
0132     nc{'tauw'} = ncfloat('time','node');
0133     nc{'tauw'}.long_name = 'Bed Shear Stress';
0134     nc{'tauw'}.units     = 'N/m^2';
0135     
0136     for i=1:vectorsize(1,1)
0137         nc{'tauw'}(i,1:vectorsize(1,2)) = tauw(i,1:vectorsize(1,2));
0138     end
0139     
0140     close(nc);
0141     
0142 end;
0143 
0144 
0145 
0146 
0147 
0148 
0149 
0150 
0151 
0152 end

Generated on Tue 18-Dec-2012 12:37:31 by m2html © 2005