-
Notifications
You must be signed in to change notification settings - Fork 23
/
DistSedDiams.c
executable file
·62 lines (48 loc) · 1.78 KB
/
DistSedDiams.c
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
/*
* SUMMARY: DistSedDiams.c - Distribute the sediment diameters
* USAGE: MWM
*
* AUTHOR: Ed Maurer
* ORG: University of Washington, Department of Civil Engineering
* E-MAIL: [email protected]
* ORIG-DATE: Sep-02
* Last Change: Thu Jun 19 09:27:02 2003 by Ed Maurer <[email protected]>
* DESCRIPTION: For lateral sediment inflow, finds the particle diameters for each
portion. Assumes a lognormal distribution
* DESCRIP-END.
* FUNCTIONS: DistSedDiams()
* COMMENTS:
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "data.h"
#include "channel.h"
#include "constants.h"
/*****************************************************************************
Function name: DistSedDiams()
Purpose : Calculate sediment diameters for NSEDSIZES bins
Required :
Returns : Sediment diameters (mm)
Modifies : none
Comments : to be consistent with FindValue, use the Tukey (1960)
approx to normal CDF -- y is probability, function returns Z(y)
*****************************************************************************/
void DistributeSedimentDiams(float SedDiams[NSEDSIZES])
{
#ifndef NORMALDIST
#define NORMALDIST(mean, stdev, y) (4.91 * stdev * (pow(y,.14) - pow(( 1 - y ),.14)) + mean )
#endif
int i;
float mn,std,z;
float pctfiner;
/* slope of the lognormal curve, log(d) on y-axis, Z on x-axis, is stdev */
mn = log10(DEBRISd50);
std = log10(DEBRISd90)-log10(DEBRISd50)/(NORMALDIST(0,1,0.9)-NORMALDIST(0,1,0.5));
pctfiner = 1.0/(2.0*NSEDSIZES); /* midpoint of finest interval */
for(i=0;i<NSEDSIZES;i++) {
z = NORMALDIST(mn,std,pctfiner);
SedDiams[i] = pow(10,mn+std*z);
pctfiner += 1.0/NSEDSIZES;
}
}