PlantGrowthCommon.h
Go to the documentation of this file.
1/*!
2 * \file PlantGrowthCommon.h
3 * \brief Define some common used function in Plant growth module, e.g., PG_EPIC
4 * \author Zhiqiang Yu, Liang-Jun Zhu
5 * \date June, 2016
6 */
7#ifndef SEIMS_PLANTGROWTH_COMMON_H
8#define SEIMS_PLANTGROWTH_COMMON_H
9
10#include "basic.h"
11#include "BMPText.h"
12#include "seims.h"
13
14//using namespace ccgl;
15
16/*!
17 * \defgroup PlantGrowthCommon
18 * \ingroup common_algorithm
19 * \brief Functions for Plant growth related modules, e.g., PG_EPIC.
20 */
21
22#define MAX_CROP_LAND_USE_ID 97
23#define BARE_SOIL_LAND_USE 98
24#define WATER_LAND_USE_ID 18
25
26/*!
27 * \ingroup PlantGrowthCommon
28 * \brief Get N/P shape parameter, See readplant.f of SWAT
29 */
30void GetNPShapeParameter(FLTPT fr1, FLTPT fr2, FLTPT fr3, FLTPT* shape1, FLTPT* shape2);
31
32/*!
33 * \ingroup PlantGrowthCommon
34 * \brief Computes shape parameters \a shape1 and \a shape2 for the S curve. See ascrv.f of SWAT
35 *
36 * The equation \f$x=\frac{y}{y+exp(S_1+S_2^y)}\f$ give two \f$(x,y)\f$ points along the curve.
37 */
38void GetScurveShapeParameter(FLTPT x_mid, FLTPT x_end, FLTPT y_mid, FLTPT y_end,
39 FLTPT* shape1, FLTPT* shape2);
40
41/*!
42 * \ingroup PlantGrowthCommon
43 * \brief Biomass fraction
44 */
45FLTPT NPBiomassFraction(FLTPT x1, FLTPT x2, FLTPT x3, FLTPT fr_phu);
46
47/*!
48 * \ingroup PlantGrowthCommon
49 * \brief calculate the fraction of nitrogen/phosphorus in the plant biomass
50 *
51 * Plant nitrogen/phosphorus equation, p300 5:2.3.1/p305 5:2.3.19
52 */
53FLTPT GetNPFraction(FLTPT fr1, FLTPT fr3, FLTPT shape1, FLTPT shape2, FLTPT fr_phu);
54
55/*!
56 * \ingroup PlantGrowthCommon
57 * \brief Heat unit accumulation
58 */
59FLTPT DoHeatUnitAccumulation(FLTPT potential_heat_unit, FLTPT t_min, FLTPT t_max, FLTPT t_base);
60
61/*!
62 * \ingroup PlantGrowthCommon
63 * \brief the adjusted radiation-use efficiency by vapor pressure deficit
64 */
65FLTPT RadiationUseEfficiencyAdjustByVPD(FLTPT vpd, FLTPT rad_use_eff_dec_rate_with_vpd);
66
67/*!
68 * \ingroup PlantGrowthCommon
69 * \brief Normalization
70 */
71FLTPT GetNormalization(FLTPT distribution);
72
73/*!
74 * \ingroup PlantGrowthCommon
75 * \brief Is tree or not
76 */
77inline bool IsTree(const int classification) { return classification == 7; }
78
79/*!
80 * \ingroup PlantGrowthCommon
81 * \brief Is annual plant or not
82 */
83inline bool IsAnnual(const int classification) {
84 return classification == CROP_IDC_WARM_SEASON_ANNUAL_LEGUME ||
85 classification == CROP_IDC_COLD_SEASON_ANNUAL_LEGUME ||
86 classification == CROP_IDC_WARM_SEASON_ANNUAL ||
87 classification == CROP_IDC_COLD_SEASON_ANNUAL;
88}
89/*!
90 * \ingroup PlantGrowthCommon
91 * \brief Is legume or not
92 */
93inline bool IsLegume(const int classification) {
94 return classification <= CROP_IDC_PERENNIAL_LEGUME;
95}
96
97/*!
98 * \ingroup PlantGrowthCommon
99 * \brief Is perennial plant or not
100 */
101inline bool IsPerennial(const int classification) {
102 return classification == CROP_IDC_PERENNIAL_LEGUME ||
103 classification == CROP_IDC_PERENNIAL;
104}
105/*!
106 * \ingroup PlantGrowthCommon
107 * \brief Is cool seanon annual plant or not
108 */
109inline bool IsCoolSeasonAnnual(const int classification) {
110 return classification == CROP_IDC_COLD_SEASON_ANNUAL_LEGUME ||
111 classification == CROP_IDC_COLD_SEASON_ANNUAL;
112}
113/*!
114 * \ingroup PlantGrowthCommon
115 * \brief Is grain or not
116 */
117inline bool IsGrain(const int classification) {
118 return classification == CROP_IDC_WARM_SEASON_ANNUAL;
119}
120/*!
121 * \ingroup PlantGrowthCommon
122 * \brief Is plant or not
123 */
124inline bool IsPlant(const int lu_id) {
125 return lu_id <= MAX_CROP_LAND_USE_ID && lu_id != WATER_LAND_USE_ID;
126}
127
128/*!
129 * \ingroup PlantGrowthCommon
130 * \brief Calculates the plant stress factor caused by limited supply of nitrogen or phosphorus.
131 * From ntus.f of SWAT, rev 637
132 */
133void CalPlantStressByLimitedNP(FLTPT u1, FLTPT u2, FLTPT* uu);
134
135#endif /* SEIMS_PLANTGROWTH_COMMON_H */
BMP related const strings.
Basic definitions.
bool IsGrain(const int classification)
Is grain or not.
Definition: PlantGrowthCommon.h:117
bool IsCoolSeasonAnnual(const int classification)
Is cool seanon annual plant or not.
Definition: PlantGrowthCommon.h:109
FLTPT GetNPFraction(FLTPT fr1, FLTPT fr3, FLTPT shape1, FLTPT shape2, FLTPT fr_phu)
calculate the fraction of nitrogen/phosphorus in the plant biomass
FLTPT GetNormalization(FLTPT distribution)
Normalization.
FLTPT DoHeatUnitAccumulation(FLTPT potential_heat_unit, FLTPT t_min, FLTPT t_max, FLTPT t_base)
Heat unit accumulation.
bool IsAnnual(const int classification)
Is annual plant or not.
Definition: PlantGrowthCommon.h:83
bool IsTree(const int classification)
Is tree or not.
Definition: PlantGrowthCommon.h:77
bool IsPerennial(const int classification)
Is perennial plant or not.
Definition: PlantGrowthCommon.h:101
void GetScurveShapeParameter(FLTPT x_mid, FLTPT x_end, FLTPT y_mid, FLTPT y_end, FLTPT *shape1, FLTPT *shape2)
Computes shape parameters shape1 and shape2 for the S curve.
void CalPlantStressByLimitedNP(FLTPT u1, FLTPT u2, FLTPT *uu)
Calculates the plant stress factor caused by limited supply of nitrogen or phosphorus.
FLTPT NPBiomassFraction(FLTPT x1, FLTPT x2, FLTPT x3, FLTPT fr_phu)
Biomass fraction.
bool IsPlant(const int lu_id)
Is plant or not.
Definition: PlantGrowthCommon.h:124
void GetNPShapeParameter(FLTPT fr1, FLTPT fr2, FLTPT fr3, FLTPT *shape1, FLTPT *shape2)
Get N/P shape parameter, See readplant.f of SWAT.
bool IsLegume(const int classification)
Is legume or not.
Definition: PlantGrowthCommon.h:93
FLTPT RadiationUseEfficiencyAdjustByVPD(FLTPT vpd, FLTPT rad_use_eff_dec_rate_with_vpd)
the adjusted radiation-use efficiency by vapor pressure deficit
The SEIMS related definitions and utilities header.