GCBM
helper.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_HELPER_H_
2 #define MOJA_MODULES_CBM_HELPER_H_
3 
4 #include <boost/algorithm/string.hpp>
5 
6 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 
8 namespace moja {
9  namespace modules {
10  namespace cbm {
11 
12  class CBM_API Helper {
13  public:
14  Helper() = delete;
15  ~Helper() = delete;
16 
17  static double calculateMerchFactor(double volume, double a, double b);
18 
19  static double calculateNonMerchFactor(
20  double merchStemwood, double a_nonmerch,
21  double b_nonmerch, double k_nonmerch);
22 
23  static double calculateSaplingFactor(double stemwood, double k_sap,
24  double a_sap, double b_sap);
25 
26  static double modelTerm(double vol, double a1, double a2, double a3);
27 
28  static bool runMoss(int gcID, std::string mossLeadingSpecies, std::string speciesName);
29  };
30 
34  inline double Helper::calculateMerchFactor(double volume, double a, double b) {
35  return a * pow(volume, b);
36  }
37 
42  double merchStemwood, double a_nonmerch, double b_nonmerch, double k_nonmerch) {
43 
44  if (merchStemwood > 0.0) {
45  return k_nonmerch + a_nonmerch * pow(merchStemwood, b_nonmerch);
46  }
47 
48  return exp(a_nonmerch);
49  }
50 
55  double stemwood, double k_sap, double a_sap, double b_sap) {
56 
57  if (stemwood > 0.0) {
58  return k_sap + a_sap * pow(stemwood, b_sap);
59  }
60 
61  return exp(a_sap);
62  }
63 
67  inline double Helper::modelTerm(double vol, double a1, double a2, double a3) {
68  return exp(a1 + a2 * vol + a3 * log(vol + 5.0));
69  }
70 
71  inline bool Helper::runMoss(int gcID, std::string mossLeadingSpecies, std::string speciesName) {
72  boost::algorithm::to_lower(mossLeadingSpecies);
73  boost::algorithm::to_lower(speciesName);
74 
75  return (gcID > 0 && boost::contains(speciesName, mossLeadingSpecies));
76  }
77  }
78  }
79 }
80 #endif // MOJA_MODULES_CBM_HELPER_H_
moja::modules::cbm::Helper::runMoss
static bool runMoss(int gcID, std::string mossLeadingSpecies, std::string speciesName)
Definition: helper.h:71
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::Helper::modelTerm
static double modelTerm(double vol, double a1, double a2, double a3)
see equations 4,5,6,7 on page 8 of Boudewyn et al 2007
Definition: helper.h:67
moja::modules::cbm::Helper::calculateNonMerchFactor
static double calculateNonMerchFactor(double merchStemwood, double a_nonmerch, double b_nonmerch, double k_nonmerch)
see equation 2 on page 7 of Boudewyn et al 2007
Definition: helper.h:41
moja::modules::cbm::Helper
Definition: helper.h:12
moja::modules::cbm::Helper::calculateMerchFactor
static double calculateMerchFactor(double volume, double a, double b)
see equation 1 on page 7 of Boudewyn et al 2007
Definition: helper.h:34
moja::modules::cbm::Helper::calculateSaplingFactor
static double calculateSaplingFactor(double stemwood, double k_sap, double a_sap, double b_sap)
page 8 Boudewyn et al equation 3
Definition: helper.h:54
moja
Definition: ageclasshelper.cpp:10