// @All rights reserved by Liu Huan. Source from: https://doi.org/10.58473/JEHS0012 #include #include #include using namespace std; int main() { // Definition of Variables; double NPP, APAR, LUE, WLF, FPARA, LU, RPAR; vector DR(90), FPARA_daily(90), VDR(90); double TDR, WB, Precipitation, E, Ev, Kv, LSP; double a, s, r; int V, P, n; cout << "=== Calculator of NPP for multiple plant species ===" << endl; // To input the species amount; cout << "Please input the species amount n (integer): "; cin >> n; // To input the water balance parameters; cout << "Please input the parameter a: "; cin >> a; cout << "Please input the parameter s: "; cin >> s; cout << "Please input the parameter r: "; cin >> r; // To input the LSP, V, P; cout << "Please input the parameter LSP: "; cin >> LSP; cout << "Please input the parameter V (integer): "; cin >> V; cout << "Please input the parameter P (integer): "; cin >> P; // To input the RPAR, Precipitation; cout << "Please input the parameter RPAR: "; cin >> RPAR; cout << "Please input the parameter Precipitation: "; cin >> Precipitation; // To input the variable of Percentage; vector Percentage(n); cout << "\n Please intut " << n << " species' Percentage:" << endl; for(int i = 0; i < n; i++) { cout << "Percentage[" << (i+1) << "]: "; cin >> Percentage[i]; } // To input the 90 days' DR; cout << "\n Please input 90 days' DR: " << endl; for(int i = 0; i < 90; i++) { cout << "The" <<" "<<(i+1) <<" "<< "day's DR: "; cin >> DR[i]; } // To input the 90 days' FPARA; cout << "\n Please input 90 days' FPARA: " << endl; for(int i = 0; i < 90; i++) { cout << "The" <<" "<< (i+1) <<" "<< "day's FPARA: "; cin >> FPARA_daily[i]; } // To input m value under P types of different pressure; vector m_values(P); cout << "\n Please input " << P << " amount of m value:" << endl; for(int i = 0; i < P; i++) { cout << "m[" << (i+1) << "]: "; cin >> m_values[i]; } // To calculate the final m that is the sum of m values (in total P amount); double m = 0; for(int i = 0; i < P; i++) { m += m_values[i]; } // To input Kv value under V types of different frequencies; vector Kv_values(V); vector Ev_values(V); cout << "\n Please input " << V << " amount of Kv values: " << endl; for(int i = 0; i < V; i++) { cout << "Kv[" << (i+1) << "]: "; cin >> Kv_values[i]; } // To calculate VDR; for(int i = 0; i < 90; i++) { if(DR[i] > LSP) { VDR[i] = LSP; } else { VDR[i] = DR[i]; } } // To calculate LU; LU = 0; for(int i = 0; i < 90; i++) { LU += VDR[i] * FPARA_daily[i]; } // To calculate TDR; TDR = 0; for(int i = 0; i < 90; i++) { TDR += DR[i]; } // To calculate WB and WLF; WB = (a * Precipitation) / (s * TDR / (s + r)); if(WB > 1) { WLF = 1; } else { WLF = WB; } // To calculate Ev and E; double Ev_sum = 0; for(int i = 0; i < V; i++) { Kv = Kv_values[i]; Ev_values[i] = exp(-Kv * m); Ev_sum += Ev_values[i]; } E = Ev_sum / V; // To calculate LUEn and LUE; vector LUEn(n); LUE = 0; for(int i = 0; i < n; i++) { // To input the LUE parameters for each species; cout << "\n Please input the " << (i+1) << " species' LUE parameters: " << endl; double y0, a0, x0, b0; cout << "y0[" << (i+1) << "]: "; cin >> y0; cout << "a0[" << (i+1) << "]: "; cin >> a0; cout << "x0[" << (i+1) << "]: "; cin >> x0; cout << "b0[" << (i+1) << "]: "; cin >> b0; double ln_value = log(E / x0) / b0; LUEn[i] = y0 + a0 * exp(-0.5 * pow(ln_value, 2)); LUE += LUEn[i] * Percentage[i]; } // To calculate APAR and NPP; APAR = LU * RPAR; NPP = APAR * LUE * WLF; cout << "\n=== final results ===" << endl; cout << "Net Primary Production (NPP): " << NPP << endl; return 0; }