[Cpp]
// Frequency analysis. h
Void PinLvFenXi ()
{
Using namespace std;
Const int NYear = EndYear-1862 + 1, // survey validation period (1862-2000)
L = 1, // number of serious floods in the actual measurement period
A = 2, // number of serious floods during the verification period and the actual measurement period
YearSuperYearW [a] = {1903,197 5}, // year of extraordinary floods
SuperYearW [a] = {21000,123 00}; // extraordinary flood Value
Int order; // the serial number of the descending order.
Double AverageMaxYearW [J] = {0 },
HundredYearW [J] = {0}, // design value for a hundred-year extreme value in different years
K, // model Ratio Coefficient
Cv = 0; // Approximate Unbiased Estimation of the coefficient of variation
Ofstream outfile;
Outfile. open ("outfile_YearW_P.txt ");
Outfile <setw (10) <"year" <setw (10) <"maximum 1 day"
<Setw (10) <"descending sequence number" <setw (10) <"empirical frequency" <endl;
Outfile <"survey validation period:" <endl;
For (int M = 0; M <a; M ++) // The maximum empirical frequency of 1-day serious floods
Outfile <setw (10) <YearSuperYearW [M] <setw (10) <SuperYearW [M]
<Setw (10) <M + 1 <setw (10) <(double) (M + 1)/(NYear + 1) <endl;
Outfile <"actual measurement period:" <endl;
For (int I = 0; I <Y; I ++)
{// Maximum 1-day flood measurement empirical frequency
For (int M = 0; M <a; M ++)
If (StartYear + I = YearSuperYearW [M])
{
Outfile <setw (10) <YearSuperYearW [M] <setw (10) <SuperYearW [M]
<Setw (10) <"included in the extraordinary flood" <endl;
I ++;
M = 0; // re-test I ++
}
If (I = Y) break;
AverageMaxYearW [0] + = MaxYearW [I] [0];
Outfile <setw (10) <StartYear + I <setw (10) <MaxYearW [I] [0];
Order = 1; // sorted in descending order from 1 (ignore L serious floods)
For (int j = 0; j <Y; j ++)
If (MaxYearW [I] [0] <MaxYearW [j] [0]) order ++;
Outfile <setw (10) <order-L <setw (10) <(double) (order-L)/(Y + 1) <endl;
}
AverageMaxYearW [0] * = (NYear-a)/(Y-L ));
For (int M = 0; M <a; M ++)
AverageMaxYearW [0] + = SuperYearW [M];
AverageMaxYearW [0]/= NYear; // obtain the annual average of the maximum 1-day flood
For (int I = 0; I <Y; I ++)
{// Calculate the variation coefficient of the maximum 1-day flood
For (int M = 0; M <a; M ++)
If (StartYear + I = YearSuperYearW [M])
{
I ++;
M = 0; // re-test I ++
}
If (I = Y) break;
Cv + = pow (MaxYearW [I] [0]-AverageMaxYearW [0], 2 );
}
Cv * = (NYear-a)/(Y-L ));
For (int M = 0; M <a; M ++)
Cv + = pow (SuperYearW [M]-AverageMaxYearW [0], 2 );
Cv = pow (Cv/(NYear-1), 0.5)/AverageMaxYearW [0];
Outfile <endl <setw (10) <"year ";
For (int k = 1; k <J; k ++) // other years of extreme flood experience frequency
Outfile <setw (7) <"maximum" <NumJ [k] <"Daily"
<Setw (10) <"descending sequence number" <setw (10) <"empirical frequency ";
Outfile <endl;
For (int I = 0; I <Y; I ++)
{// Calculate the empirical frequency
Outfile <setw (10) <StartYear + I;
For (int k = 1; k <J; k ++)
{
Outfile <setw (10) <MaxYearW [I] [k];
Order = 1; // sorted in descending order starting from 1
For (int j = 0; j <Y; j ++)
If (MaxYearW [I] [k] <MaxYearW [j] [k]) order ++;
Outfile <setw (10) <order <setw (10) <(double) order/(Y + 1 );
}
Outfile <endl;
}
Outfile. close ();
For (int k = 1; k <J; k ++)
{// Calculate the multi-year average value of other Annual Extreme Values
For (int I = 0; I <Y; I ++)
AverageMaxYearW [k] + = MaxYearW [I] [k];
AverageMaxYearW [k]/= Y;
}
Cout <"Annual Extreme frequency Series Frequency Analysis -- initial values of the theoretical frequency curve parameters are as follows:" <endl;
For (int k = 0; k <J; k ++)
{// Calculate the coefficient of variation of other Annual Extreme Values
If (k! = 0)
{
Cv = 0;
For (int I = 0; I <Y; I ++)
{
K = MaxYearW [I] [k]/AverageMaxYearW [k];
Cv + = pow (K-1, 2 );
}
Cv = pow (Cv/(Y-1), 0.5 );
}
Cout <"Max" <NumJ [k] <"day" <"multi-year average =" <AverageMaxYearW [k] <endl
<"Coefficient of variation Approximate Unbiased Estimation Cv =" <Cv <endl;
}
// Evaluate the design flood process line
Double ClassicalMonthQ [31], // typical monthly flood traffic
ForcastQ [31], // design the flood process
MaxClassicalYearW [J], // extreme flood of typical floods
RatioW [J]; // same frequency ratio
Int date [J]; // records the typical annual extreme time period and determines whether the period is inclusive.
Ifstream infile;
Infile. open ("infile_ClassicalWprocess.txt ");
For (int I = 0; I <31; I ++)
Infile> ClassicalMonthQ [I];
Infile. close ();
Outfile. open ("outfile_ForecastWprocess.txt ");
For (int k = 0; k <J; k ++)
{// Calculate the extreme flood volume of a typical flood
MaxClassicalYearW [k] = 0; // Initialization
For (int j = 0; j <31-NumJ [k] + 1; j ++)
{
Temp_W = 0; // Initialization
For (int n = 0; n <NumJ [k]; n ++)
Temp_W + = ClassicalMonthQ [j + n];
If (temp_W> MaxClassicalYearW [k])
{
MaxClassicalYearW [k] = temp_W; // (m3/s * month)
Date [k] = j;
}
}
Cout <"Max" <NumJ [k] <"date period: January 1, August 1975"
<Date [k] + 1 <"to" <date [k] + NumJ [k] <"day" <endl;
}
Cout <"determines whether a typical flood is suitable Based on the Inclusion relationship of the preceding time period! "
<"Enter 1 if applicable; otherwise, disable it! "<Endl;
Cin> order;
If (order = 1)
{
Cout <"input design value for a hundred years from the theoretical frequency curve:" <endl;
For (int k = 0; k <J; k ++)
{// Same frequency amplification ratio
Cout <"Max" <NumJ [k] <"day"
<"Typical flood:" <MaxClassicalYearW [k]
<"Design flood :";
Cin> HundredYearW [k];
If (k = 0) RatioW [k] = HundredYearW [k]/MaxClassicalYearW [k];
Else RatioW [k] = (HundredYearW [k]-HundredYearW [k-1])/(MaxClassicalYearW [k]-MaxClassicalYearW [k-1]);
}
For (int k = 0; k <J; k ++)
{// Design flood process
For (int I = date [k]; I <date [k] + NumJ [k]; I ++)
{
If (k = 0) ForcastQ [I] = ClassicalMonthQ [I] * RatioW [k];
Else if (I <date [k-1] | I> = date [k-1] + NumJ [k-1])
ForcastQ [I] = ClassicalMonthQ [I] * RatioW [k];
}
}
Outfile <setw (10) <"typical flood" <setw (10) <"design flood" <endl;
For (int I = date [J-1]; I <date [J-1] + NumJ [J-1]; I ++)
Outfile <setw (10) <ClassicalMonthQ [I] <setw (10) <ForcastQ [I] <endl;
Outfile. close ();
Cout <"frequency analysis has ended. Please disable it! "<Endl;
Cin> Cv; // pause the Console
}
}
By: Superwen_go