-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFunction_WilcockCrowe_vectorized_spatial.m
96 lines (76 loc) · 2.4 KB
/
Function_WilcockCrowe_vectorized_spatial.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function [qbtN,pbiN,tausg_star,taussrgstar] = Function_WilcockCrowe_vectorized_spatial(Di,DimeanN,piN,DgN,...
R,g,ustar,gsd_MG,nodes_N,t,tau_crit_factor)
% Compute total transport and bedload frequencies, using Wilcock and Crowe,
% 2003.
% The function needs six inputs to run:
% 1. Di: particle sizes. (in m??)
% 2. pi: bed surface frequencies.
% 3. Dg: geometrical mean size (m)
% 4. R: specifig gravity of sediment (Specific density???)
% 5. g: acceleration of gravity
% 6. ustar: shear velocity
format long e
%% SUBROUTINE: GSD Parameters: Dg and sg
% Grain classes
%MG = length(piN);
%% Allocating variables
%FacN = zeros(nodes_N,MG+1);
Wi_star = zeros(nodes_N,gsd_MG);
pbiN = zeros(nodes_N,gsd_MG);
psiN = log(transpose(repmat(Di,[1 nodes_N])))./log(2);
% Reconstructing cumulative function
FacN = [zeros(nodes_N,1), cumsum(piN,2)];
% sand content (%)
logicArray(:,:) = (psiN(:,1:end-1) <= 1) .* (psiN(:,2:end) > 1);
Fs = sum(...
logicArray .* ((FacN(:,2:end) - FacN(:,1:end-1)) ...
./(psiN(:,2:end) - psiN(:,1:end-1)) ...
.*(psiN(:,1:end-1) - 1) + FacN(:,1:end-1)...
),2);
zeroArray = zeros(1,nodes_N);
Fs(isnan(Fs)) = zeroArray(isnan(Fs));
%% dimensionless critical shear stress
taussrgstar = tau_crit_factor * (0.021 + 0.015*exp(-20*Fs));
%% Shear stresses
tausg_star = ustar(:).^2./(R*g.*DgN(:)./1000);
%% Hiding/Exposure coefficients
phisg0 = tausg_star./taussrgstar;
diff = DimeanN./repmat(DgN,[1 gsd_MG]);
b = 0.67./(1 + exp(1.5 - diff));
phi_i = repmat(phisg0,[1 gsd_MG]).*diff.^(-b);
Wi_star(phi_i < 1.35) = 0.002*phi_i(phi_i < 1.35).^7.5;
Wi_star(phi_i >= 1.35) = 14*(1 - 0.894./phi_i(phi_i >= 1.35).^0.5).^4.5;
% excess shearstress logical
excessTauLogic = tausg_star > taussrgstar;
% Sediment trasport rate of the ith fraction and total load (dimensional)
qbiN = repmat(excessTauLogic,[1 gsd_MG]) .* (Wi_star .* piN .* repmat(ustar,[1 gsd_MG]).^3) ./ (R*g);
qbtN = sum(qbiN,2);
%qbtN MINIMUM 0
qbtN(qbtN<0)=0;
% Sediment transport rate frequencies
for n=1:nodes_N
if qbtN(n) > 0
pbiN(n,:) = qbiN(n,:)./qbtN(n);
else
pbiN(n,:) = 0;
qbtN(n) = 0;
end
end
%BREAK if problem
if isnan(sum(pbiN(:)))
disp('isnan(pbiN)')
disp(t)
keyboard
end
%BREAK if problem
if isnan(sum(qbtN(:)))
disp('isnan(qbtN)')
disp(t)
keyboard
end
%BREAK if problem
if isnan(sum(qbiN(:)))
disp('isnan(qbi)')
disp(t)
keyboard
end