NutrientMovementViaWater.h
Go to the documentation of this file.
1/*!
2 * \file NutrientMovementViaWater.h
3 * \brief Simulates the loss of nitrate and phosphorus via surface runoff,
4 * lateral flow, tile flow, and percolation out of the profile.
5 * Method of SWAT.
6 *
7 * Changelog:
8 * - 1. 2016-05-30 - hr - Initial implementation.
9 * - 2. 2018-05-10 - lj -
10 * -# Reformat, especially naming style (sync update in "text.h").
11 * -# Code optimization, e.g., use multiply instead of divide.
12 * - 3. 2022-08-22 - lj - Change float to FLTPT.
13 *
14 * \author Huiran Gao, Liangjun Zhu
15 */
16#ifndef SEIMS_MODULE_NUTRMV_H
17#define SEIMS_MODULE_NUTRMV_H
18
19#include "SimulationModule.h"
20
21/** \defgroup NutrMV
22 * \ingroup Nutrient
23 * \brief Simulates the loss of nitrate and phosphorus via surface runoff, lateral flow, tile flow, and percolation out of the profile.
24 */
25
26/*!
27 * \class NutrientMovementViaWater
28 * \ingroup NutrMV
29 *
30 * \brief Nutrient removed and loss in surface runoff, lateral flow, tile flow, and percolation out of the profile
31 *
32 */
34public:
36
38
39 void SetValue(const char* key, FLTPT value) OVERRIDE;
40
41 void SetValue(const char* key, int value) OVERRIDE;
42
43 void Set1DData(const char* key, int n, FLTPT* data) OVERRIDE;
44
45 void Set1DData(const char* key, int n, int* data) OVERRIDE;
46
47 void Set2DData(const char* key, int nrows, int ncols, FLTPT** data) OVERRIDE;
48
49 void Set2DData(const char* key, int nrows, int ncols, int** data) OVERRIDE;
50
52
54
56
57 void GetValue(const char* key, FLTPT* value) OVERRIDE;
58
59 void Get1DData(const char* key, int* n, FLTPT** data) OVERRIDE;
60
62
63private:
64 /*!
65 * \brief Calculate the loss of nitrate via surface runoff, lateral flow, tile flow,
66 * and percolation out of the profile.
67 * mainly rewrited from nlch.f of SWAT
68 * 1. nitrate loss with surface flow
69 * 2. nitrate loss with subsurface flow (routing considered)
70 * 3. nitrate loss with percolation
71 */
72 void NitrateLoss(int i);
73
74 /*!
75 * \brief Calculates the amount of phosphorus lost from the soil
76 * profile in runoff and the movement of soluble phosphorus from the first
77 * to the second layer via percolation.
78 * rewrite from solp.f of SWAT
79 */
80 void PhosphorusLoss(int i);
81
82 /*
83 * \brief compute loadings of chlorophyll-a, BOD, and dissolved oxygen to the main channel
84 * rewrite from subwq.f of SWAT
85 */
86 void SubbasinWaterQuality(int i);
87
88 void SumBySubbasin();
89private:
90 /// cell width of grid map (m)
91 FLTPT m_cellWth;
92 /// cell area, ha
93 FLTPT m_cellArea;
94 /// number of cells
95 int m_nCells;
96 /// soil layers
97 int* m_nSoilLyrs;
98 /// maximum soil layers
99 int m_maxSoilLyrs;
100 /// stream link
101 int* m_rchID;
102 /* carbon modeling method
103 * = 0 Static soil carbon (old mineralization routines)
104 * = 1 C-FARM one carbon pool model
105 * = 2 Century model
106 */
107 int m_cbnModel;
108
109 /// input data
110
111 /// factor which converts kg/kg soil to kg/ha
112 FLTPT** m_cvtWt;
113 /// drainage tile flow in soil profile
114 FLTPT m_qtile;
115 /// Phosphorus soil partitioning coefficient
116 FLTPT m_phoskd;
117 /// phosphorus percolation coefficient (0-1)
118 FLTPT m_pperco;
119 /// nitrate percolation coefficient (0-1)
120 FLTPT m_nperco;
121 /// Conversion factor from CBOD to COD
122 FLTPT m_cod_n;
123 /// Reaction coefficient from CBOD to COD
124 FLTPT m_cod_k;
125
126 /// soil loss caused by water erosion in overland
127 FLTPT* m_olWtrEroSed;
128 // fraction of porosity from which anions are excluded
129 FLTPT* m_anionExclFr;
130 // distribution of surface runoff generated
131 FLTPT* m_surfRf;
132 /// initial septic operational condition (active-1, failing-2, non_septic-0)
133 int m_isep_opt;
134 /// soil layer where drainage tile is located
135 int* m_drainLyr;
136 /// crack volume potential of soil
137 FLTPT* m_soilCrk;
138 /// distance to the downstream reach
139 FLTPT* m_distToRch;
140 /// amount of water held in the soil layer at saturation
141 FLTPT** m_soilSat;
142
143 /// lateral flow in soil layer
144 FLTPT** m_subSurfRf;
145 /// percolation from soil layer
146 FLTPT** m_soilPerco;
147 /// bulk density of the soil
148 FLTPT** m_soilBD;
149 /// depth to bottom of soil layer, sol_z in SWAT
150 FLTPT** m_soilDepth;
151
152 /// flow out indexes
153 int** m_flowOutIdx;
154 /// flow out fractions
155 FLTPT** m_flowOutFrac;
156 /**
157 * @brief Routing layers according to the flow direction
158 *
159 * There are not flow relationships within each layer.
160 * The first element in each layer is the number of cells in the layer
161 */
162 int** m_rteLyrs;
163 /// number of routing layers
164 int m_nRteLyrs;
165 /// amount of organic nitrogen in surface runoff
166 FLTPT* m_sedorgn;
167 /// average air temperature
168 FLTPT* m_meanTemp;
169 ///percent organic carbon in soil layer (%)
170 FLTPT** m_soilCbn;
171 /// soil thick of each layer (mm)
172 FLTPT** m_soilThk;
173
174 /// output data
175 /// amount of nitrate transported with lateral flow, kg/ha
176 FLTPT* m_latNO3;
177 /// amount of nitrate percolating past bottom of soil profile, kg/ha
178 FLTPT* m_percoN;
179 /// amount of solute P percolating past bottom of soil profile
180 FLTPT* m_percoP;
181 /// amount of nitrate transported with surface runoff, kg/ha
182 FLTPT* m_surfRfNO3;
183 /// amount of ammonian transported with surface runoff, kg/ha
184 FLTPT* m_surfRfNH4;
185 /// amount of soluble phosphorus in surface runoff
186 FLTPT* m_surfRfSolP;
187 /// carbonaceous oxygen demand of surface runoff
188 FLTPT* m_surfRfCod;
189 /// chlorophyll-a concentration in water yield
190 FLTPT* m_surfRfChlA;
191 /// dissolved oxygen concentration in the surface runoff
192 //FLTPT* m_doxq;
193 /// dissolved oxygen saturation concentration
194 //FLTPT* m_soxy;
195
196 // N and P to channel
197 FLTPT* m_latNO3ToCh; ///< amount of nitrate transported with lateral flow to channel, kg
198 FLTPT* m_surfRfNO3ToCh; ///< amount of nitrate transported with surface runoff to channel, kg
199 FLTPT* m_surfRfNH4ToCh; ///< amount of ammonian transported with surface runoff to channel, kg
200 FLTPT* m_surfRfSolPToCh; ///< amount of soluble phosphorus in surface runoff to channel, kg
201 FLTPT* m_percoNGw; ///< amount of nitrate percolating past bottom of soil profile sum by sub-basin, kg
202 FLTPT* m_percoPGw; ///< amount of solute P percolating past bottom of soil profile sum by sub-basin, kg
203 FLTPT* m_surfRfCodToCh; ///< amount of COD to reach in surface runoff (kg)
204
205 /// subbasin related
206 /// the total number of subbasins
207 int m_nSubbsns;
208 //! subbasin IDs
209 vector<int> m_subbasinIDs;
210 /// subbasin grid (subbasins ID)
211 int* m_subbsnID;
212 /// subbasins information
213 clsSubbasins* m_subbasinsInfo;
214
215 /// input & output
216 /// average annual amount of phosphorus leached into second soil layer
217 FLTPT m_wshdLchP;
218
219 /// amount of nitrogen stored in the nitrate pool in soil layer
220 FLTPT** m_soilNO3;
221 /// amount of phosphorus stored in solution
222 FLTPT** m_soilSolP;
223
224 /* CENTURY C/N cycling model related */
225 /// amount of Carbon lost with sediment, kg/ha, input from NUTRSED module
226 FLTPT* m_sedLossCbn;
227};
228#endif /* SEIMS_MODULE_NUTRMV_H */
Parent class for all modules in SEIMS.
#define OVERRIDE
A compatible reference to override or blank if not supported by the compiler.
Definition: basic.h:160
void Set1DData(const char *key, int n, FLTPT *data) OVERRIDE
Set 1D data, by default, DT_Raster1D, float.
int Execute() OVERRIDE
Execute the simulation. Return 0 for success.
void Set2DData(const char *key, int nrows, int ncols, FLTPT **data) OVERRIDE
Set 2D data, by default, DT_Raster2D, float.
void Set1DData(const char *key, int n, int *data) OVERRIDE
Set 1D data, by default, DT_Raster1D, integer.
void Get1DData(const char *key, int *n, FLTPT **data) OVERRIDE
Get 1D data, by default, DT_Raster1D, float.
void SetValue(const char *key, int value) OVERRIDE
Set data, DT_Single, integer.
void SetSubbasins(clsSubbasins *subbasins) OVERRIDE
Set pointer of clsSubbasins class which contains all subbasins information. Added by LJ,...
void InitialOutputs() OVERRIDE
Initialize output variables.
void Set2DData(const char *key, int nrows, int ncols, int **data) OVERRIDE
Set 2D data, by default, DT_Raster2D, integer.
bool CheckInputData() OVERRIDE
Check the input data.
void GetValue(const char *key, FLTPT *value) OVERRIDE
Get value, DT_Single, float.
void SetValue(const char *key, FLTPT value) OVERRIDE
Set data, DT_Single, float point number (float or double)
Nutrient removed and loss in surface runoff, lateral flow, tile flow, and percolation out of the prof...
Definition: NutrientMovementViaWater.h:33
Manager all Subbasin related parameters and methods.
Definition: clsSubbasin.h:214
Base module for all simulation modules in SEIMS.
Definition: SimulationModule.h:46