forked from jhamman/DHSVM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FinalMassBalance.c
executable file
·171 lines (152 loc) · 7.99 KB
/
FinalMassBalance.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* SUMMARY: MassBalance.c - calculate basin-wide mass balance
* USAGE: Part of DHSVM
*
* AUTHOR: Mark Wigmosta
* ORG: Battelle - Pacific Northwest National Laboratory
* E-MAIL: [email protected]
* ORIG-DATE: Oct-96
* DESCRIPTION: Calculate water and sediment mass balance errors
*
* DESCRIP-END.
* FUNCTIONS: FinalMassBalance()
* COMMENTS:
* $Id: FinalMassBalance.c,v 1.18 2004/08/18 01:01:28 colleen Exp $
* Modification made on 2013/1/11
* $Id: FinalMassBalance.c, v 4.0 Ning Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include "settings.h"
#include "data.h"
#include "DHSVMerror.h"
#include "functions.h"
#include "constants.h"
/*****************************************************************************
Aggregate()
Calculate the average values for the different fluxes and state variables
over the basin. Only the runoff is calculated as a total volume instead
of an average. In the current implementation the local radiation
elements are not stored for the entire area. Therefore these components
are aggregated in AggregateRadiation() inside MassEnergyBalance().
The aggregated values are set to zero in the function RestAggregate,
which is executed at the beginning of each time step.
*****************************************************************************/
void FinalMassBalance(FILES * Out, AGGREGATED * Total, WATERBALANCE * Mass,
OPTIONSTRUCT * Options, float roadarearatio)
{
float NewWaterStorage; /* water storage at the end of the time step */
float Output; /* total water flux leaving the basin; */
float MassError; /* mass balance error m */
float Input;
float MWMMassError;
float SedInput, SedOutput, SedMassError;
NewWaterStorage = Total->Soil.IExcess + Total->Road.IExcess +
Total->CanopyWater + Total->SoilWater +
Total->Snow.Swq + Total->Soil.SatFlow + Total->Soil.DetentionStorage;
Output = Mass->CumChannelInt + ( Mass->CumRoadInt -
Mass->CumCulvertReturnFlow ) + Mass->CumET;
Input = Mass->CumPrecipIn + Mass->CumSnowVaporFlux -
Mass->CumCulvertReturnFlow;
MassError = (NewWaterStorage - Mass->StartWaterStorage) +
Output - Input;
/* Print the runoff final balance results to the screen */
fprintf(stderr, "\n ******************************** Depth");
fprintf(stderr, "\n Runoff Final Mass Balance mm");
fprintf(stderr, "\n ******************************** ------------");
fprintf(stderr, "\n Total Inflow ................... %12.3f", Input*1000);
fprintf(stderr, "\n Precip/Inflow .............. %12.3f", Mass->CumPrecipIn*1000);
fprintf(stderr, "\n SnowVaporFlux .............. %12.3f", Mass->CumSnowVaporFlux*1000);
fprintf(stderr, "\n Total Outflow .................. %12.3f", Output*1000);
fprintf(stderr, "\n ET ......................... %12.3f", Mass->CumET*1000);
fprintf(stderr, "\n ChannelInt ................. %12.3f", Mass->CumChannelInt*1000);
fprintf(stderr, "\n RoadInt .................... %12.3f", (Mass->CumRoadInt -
Mass->CumCulvertReturnFlow) * 1000);
fprintf(stderr, "\n Storage Change ................. %12.3f", (NewWaterStorage - Mass->StartWaterStorage)*1000);
fprintf(stderr, "\n Initial Storage ............ %12.3f", Mass->StartWaterStorage*1000);
fprintf(stderr, "\n Final Storage .............. %12.3f", NewWaterStorage*1000);
fprintf(stderr, "\n Final SWQ .............. %12.3f", Total->Snow.Swq*1000);
fprintf(stderr, "\n Final Soil Moisture .... %12.3f", (Total->SoilWater + Total->Soil.SatFlow)*1000);
fprintf(stderr, "\n Final Surface .......... %12.3f", (Total->Soil.IExcess +
Total->CanopyWater + Total->Soil.DetentionStorage)*1000);
fprintf(stderr, "\n Final Road Surface ..... %12.3f\n", Total->Road.IExcess*1000);
fprintf(stderr, "\n Mass added to glacier .......... %12.3f\n", Total->Snow.Glacier*1000);
fprintf(stderr, " ******************************************************");
fprintf(stderr, "\n Mass Error (mm)................. %12.3f", MassError*1000);
if(Options->Sediment){
fprintf(stderr, "\nFinal Sediment Mass Balance\n");
if (Options->MassWaste){
MWMMassError = Mass->CumMassWasting - Mass->CumSedimentToChannel -
Mass->CumMassDeposition;
/* These are totals, not averages */
fprintf(stderr, " \nTotal Mass Wasting\n");
fprintf(stderr, " MassWasted (m3): %.2e\n", Mass->CumMassWasting);
fprintf(stderr, " SedimentToChannel (m3): %.2e\n",
Mass->CumSedimentToChannel);
fprintf(stderr, " MassDepostion (m3): %.2e\n", Mass->CumMassDeposition);
fprintf(stderr, " Mass Error (m3): %e\n", MWMMassError);
}
/* These are averages */
if (Options->InitSedFlag){
fprintf(stderr, " \nAverage Surface Erosion\n");
fprintf(stderr, " Surface Erosion (mm): %.2e\n",
Mass->CumSedimentErosion);
fprintf(stderr, " Surface Erosion (kg/hectare): %.2e\n",
Mass->CumSedimentErosion * PARTDENSITY * (float)MMTOM * 10000.);
}
if (Options->RoadRouting){
fprintf(stderr, " \nBasin Average Road Surface Erosion\n");
fprintf(stderr, " Road Surface Erosion (mm): %.2e\n",
Mass->CumRoadErosion * 1000.);
fprintf(stderr, " Road Surface Erosion (kg/hectare): %.2e\n",
Mass->CumRoadErosion * PARTDENSITY * 10000.);
fprintf(stderr, "Road Sediment to Hillslope (mm): %.2e\n",
Mass->CumRoadSedHill * 1000.);
/* roadarearatio is used to convert basin average road erosion to
road erosion averaged over the road surface area */
fprintf(stderr, " \nAverage Road Surface Erosion\n");
fprintf(stderr, " Road Surface Erosion (mm): %.2e\n",
Mass->CumRoadErosion/roadarearatio * 1000.);
fprintf(stderr, " Road Surface Erosion (kg/hectare): %.2e\n",
Mass->CumRoadErosion/roadarearatio * PARTDENSITY * 10000.);
fprintf(stderr, "Road Sediment to Hillslope (mm): %.2e\n",
Mass->CumRoadSedHill/roadarearatio * 1000.);
}
/* These are totals */
SedInput = Mass->CumDebrisInflow +
(Mass->CumSedOverlandInflow - Mass->CumCulvertSedToChannel) +
Mass->CumSedOverroadInflow;
/* NOTE: CulvertSedToChannel + CulvertReturnSedFlow = CulvertSedFlow */
SedOutput = Mass->CumSedimentOutflow -
(Mass->CumCulvertSedToChannel + Mass->CumCulvertReturnSedFlow) ;
SedMassError = (Total->ChannelSedimentStorage +
Total->ChannelSuspendedSediment -
Mass->StartChannelSedimentStorage) +
SedOutput - SedInput;
fprintf(stderr, " \nChannel Erosion");
fprintf(stderr, " \nInflow %.2e:\n", SedInput);
fprintf(stderr, " DebrisInflow (kg): %e\n", Mass->CumDebrisInflow);
fprintf(stderr, " OverlandInflow (kg): %e\n",
Mass->CumSedOverlandInflow);
fprintf(stderr, " OverroadInflow (kg): %e\n",
Mass->CumSedOverroadInflow);
if (Options->ChannelRouting){
fprintf(stderr, " \nOutflow %.2e:\n", SedOutput);
fprintf(stderr, " SedimentOutflow (kg): %e\n", Mass->CumSedimentOutflow);
fprintf(stderr, " CulvertReturnSedFlow (kg): %e\n",
Mass->CumCulvertReturnSedFlow);
fprintf(stderr, " CulvertSedToChannel (kg): %e\n",
Mass->CumCulvertSedToChannel);
fprintf(stderr, " \nStorage:\n");
fprintf(stderr, " Initial Storage (kg): %e\n",
Mass->StartChannelSedimentStorage);
fprintf(stderr, " End of Run Storage (kg): %e\n",
Total->ChannelSedimentStorage + Total->ChannelSuspendedSediment);
fprintf(stderr, " \tFinal Bed Storage (kg): %e\n",
Total->ChannelSedimentStorage);
fprintf(stderr, " \tFinal Suspended Sediment (kg): %e\n",
Total->ChannelSuspendedSediment);
fprintf(stderr, " \nMass Error (kg): %e\n", SedMassError);
}
}
}