milsol.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * @file tests/plot/milsol.hpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
  11. * Copyright (C) 2009 INRA
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation, either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. */
  26. #ifndef TESTS_PLOT_MILSOL_HPP
  27. #define TESTS_PLOT_MILSOL_HPP 1
  28. #include <tests/plot/climate.hpp>
  29. #include <tests/plot/cohorte.hpp>
  30. #include <vector>
  31. namespace paradevs { namespace tests { namespace plot {
  32. class Milsol
  33. {
  34. public:
  35. Milsol() : count(0), TotalSporeReady(0)
  36. {
  37. p1 = 0.5;
  38. p2 = 1.0;
  39. p3 = 10.0;
  40. p4 = 0.05;
  41. p5 = 0.025;
  42. p6 = 1.5;
  43. p7 = 75.0;
  44. p8 = 150.0;
  45. p9 = 225.0;
  46. p10 = 0.004;
  47. p11 = 0.009;
  48. p12 = 2.0;
  49. p13 = 1.0;
  50. p14 = 0.037;
  51. D0 = 100.0;
  52. D1 = 150.0;
  53. Dc = 100.0;
  54. CUM0 = 6.0;
  55. CUM1 = 10.0;
  56. Topt = 18.0;
  57. Tmin = 3.0;
  58. FACT = 2000.0;
  59. SSA = 1. / 17700;
  60. _total_ready_spore_number_t = 0.0;
  61. _total_ready_spore_number_t2 = 0.0;
  62. _total_ready_spore_number_t3 = 0.0;
  63. _zoospore_number = 0.0;
  64. }
  65. double get_ready_spore_number() const
  66. { return TotalSporeReady; }
  67. virtual void operator()(typename common::DoubleTime::type t)
  68. {
  69. _total_ready_spore_number_t = 0.0;
  70. _climate.get_temperatures(t, _temperatures);
  71. _climate.get_humidities(t, _humidities);
  72. createCohorte();
  73. for (unsigned int i = 0; i < _cohortes.size(); ++i) {
  74. for (unsigned int j = 0; j < 24 ; ++j) {
  75. _cohortes[i].compute(_temperatures[j], _humidities[j]);
  76. _total_ready_spore_number_t += _cohortes[i].sporul();
  77. if (condEndCohorte(i)) {
  78. _cohortes.erase(_cohortes.begin() + i);
  79. i--;
  80. break;
  81. }
  82. }
  83. }
  84. _total_ready_spore_number_t2 = _total_ready_spore_number_t -
  85. _total_ready_spore_number_t3;
  86. _total_ready_spore_number_t3 = _total_ready_spore_number_t;
  87. TotalSporeReady = _total_ready_spore_number_t2;
  88. }
  89. void add_zoospore_number(double n)
  90. { _zoospore_number += n; }
  91. double get_zoospore_number() const
  92. { return _zoospore_number; }
  93. void set_inoculum_primaire_number(double n)
  94. { _zoospore_number = n; }
  95. private:
  96. bool condEndCohorte(int k)
  97. { return (_cohortes[k].age() > p9); }
  98. bool condBeginCohorte()
  99. { return _zoospore_number > 0.0; }
  100. void createCohorte()
  101. {
  102. if (condBeginCohorte()) {
  103. ++count;
  104. _cohortes.push_back(
  105. Cohorte(count, _zoospore_number, p1, p2, p3, p4, p5,
  106. p6, p7,
  107. p8, p9, p10, p11, p12, p13, p14, D0, D1, Dc, CUM0,
  108. CUM1, Topt, Tmin, FACT, SSA));
  109. }
  110. }
  111. double p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14;
  112. double D0, D1, Dc;
  113. double CUM0, CUM1;
  114. double Topt, Tmin;
  115. double FACT, SSA;
  116. std::vector < Cohorte > _cohortes;
  117. std::vector < double > _temperatures;
  118. std::vector < double > _humidities;
  119. int count;
  120. double TotalSporeReady;
  121. double _total_ready_spore_number_t;
  122. double _total_ready_spore_number_t2;
  123. double _total_ready_spore_number_t3;
  124. double _zoospore_number;
  125. Climate _climate;
  126. };
  127. } } } // namespace paradevs tests plot
  128. #endif