-
released this
2026-11-24 07:11:36 +00:00 | 0 commits to main since this releaseThe DOI of this source code: https://doi.org/10.58473/ChengZhuSci0003/05
Introduction: My previous modeling project simulate the net primary production process by using Vensim software. In order to improve it, modeling of net primary production (NPP) is also conducted by using C++ language with specific improvement discussed.
Development language: C++;
All Rights Reserved.
Reference: Liu Huan (2024). Original Review of Biodiversity Conservation Progress in China: The Theories and Cases in Practice. Journal of Environment and Health Science (ISSN 2314-1628). 2024(04). https://doi.org/10.58473/JEHS0012
Copyrights Certificate Registered by Brock Chain Technology: Brock Chain ID. (2a6313a6252f4a61ea5865652b9113e8ace73fdfcc9d7fed88904d8de5441b14) ; Register Time: 2025-11-11 09:55.
Source Code:
// @All rights reserved by Liu Huan. Source from: https://doi.org/10.58473/JEHS0012
#include <iostream>
#include <cmath>
#include <vector>
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<double> 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<double> 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<double> Kv_values(V); vector<double> 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<double> 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;}
Downloads