-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsw_visc.m
71 lines (58 loc) · 1.65 KB
/
sw_visc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function visc = sw_visc(S,T,P)
% SW_VISC kinematic viscosity
%===========================================================================
% SW_VISC $Revision: 0.0 $ $Date: 1998/01/19 $
% Copyright (C) Ayal Anis 1998.
%
% USAGE: visc = sw_visc(S,T,P)
%
% DESCRIPTION:
% Calculates kinematic viscosity of sea-water.
% based on Dan Kelley's fit to Knauss's TABLE II-8
%
% INPUT: (all must have same dimensions)
% S = salinity [psu (PSS-78) ]
% T = temperature [degree C (IPTS-68)]
% P = pressure [db]
% (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) )
%
% OUTPUT:
% visc = kinematic viscosity of sea-water [m^2/s]
%
% visc(40.,40.,1000.)=8.200167608E-7
%
% DISCLAIMER:
% This software is provided "as is" without warranty of any kind.
%=========================================================================
% CALLER: general purpose
% CALLEE: sw_dens.m
%-------------
% CHECK INPUTS
%-------------
if nargin ~= 3
error('sw_visc.m: Must pass 3 parameters ')
end
% CHECK S,T dimensions and verify consistent
[ms,ns] = size(S);
[mt,nt] = size(T);
% CHECK THAT S & T HAVE SAME SHAPE
if (ms~=mt) | (ns~=nt)
error('check_stp: S & T must have same dimensions')
end %if
% LET sw_dens.m DO DIMENSION CHECKING FOR P
% IF ALL ROW VECTORS ARE PASSED THEN LET US PRESERVE SHAPE ON RETURN.
Transpose = 0;
if ms == 1 % row vector
T = T(:);
S = S(:);
Transpose = 1;
end %if
%------
% BEGIN
%------
visc = 1e-4*(17.91-0.5381*T+0.00694*T.^2+0.02305*S)./sw_dens(S,T,P);
if Transpose
visc = visc';
end %if
return
%=========================================================================