dispersion.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @file tests/plot/dispersion.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. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #ifndef TESTS_PLOT_DISPERSION_HPP
  26. #define TESTS_PLOT_DISPERSION_HPP 1
  27. #include <cmath>
  28. #define SCALE 4
  29. namespace paradevs { namespace tests { namespace plot {
  30. class KleinDispersionFunction
  31. {
  32. public:
  33. KleinDispersionFunction()
  34. {
  35. }
  36. virtual double operator()(
  37. typename common::DoubleTime::type t,
  38. const paradevs::tests::boost_graph::Point& source,
  39. const paradevs::tests::boost_graph::Point& destination,
  40. double wind_speed,
  41. double wind_direction) const
  42. {
  43. double distance = std::sqrt(
  44. (destination._x - source._x) * (destination._x - source._x) +
  45. (destination._y - source._y) * (destination._y - source._y));
  46. double r, rt;
  47. r = distance * SCALE / 100;
  48. if (r <= 1.5) {
  49. rt = 0.340 - 0.405 * r + 0.128 * std::pow (r, 2.0);
  50. } else if (r <= 50) {
  51. rt = 0.03985 / (1.0 + std::pow (r, 3.12) / 3.80);
  52. } else { // r > 50m
  53. double rr, gamma, K;
  54. rr = 50;
  55. gamma = -2.29;
  56. //valeur la plus lourde -2.14, + legere - 2.56
  57. K = (0.03985 / (1.0 + std::pow (rr, 3.12) / 3.80)) / std::pow (1.0 + rr, gamma);
  58. rt = K * std::pow (1.0 + r, gamma);
  59. // std::cout << _index << "\t" << t << "\t" << r << "\t" << K << "\t" << rr << "\t" << rt << "\t" << value << std::endl;
  60. }
  61. return rt;
  62. }
  63. };
  64. class Plume2dDispersionFunction
  65. {
  66. public:
  67. Plume2dDispersionFunction()
  68. {
  69. }
  70. virtual double operator()(
  71. typename common::DoubleTime::type t,
  72. const paradevs::tests::boost_graph::Point& source,
  73. const paradevs::tests::boost_graph::Point& destination,
  74. double wind_speed,
  75. double wind_direction) const
  76. {
  77. paradevs::tests::boost_graph::Point destination1(destination);
  78. paradevs::tests::boost_graph::Point destination2;
  79. //Changement de repère centré en (source._x, source._y)
  80. destination1._x -= source._x;
  81. destination1._y -= source._y;
  82. //Rotation des axes d'angle wind_direction
  83. destination2._x = destination1._x * std::cos(wind_direction) +
  84. destination1._y * std::sin(wind_direction);
  85. destination2._y = -destination1._x * std::sin(wind_direction) +
  86. destination1._y * std::cos(wind_direction);
  87. if (destination2._x > 0) {
  88. // double sigma_y = 0.0787*x/(std::pow(1+x/707,0.135));
  89. // double sigma_z = 0.0475*x/(std::pow(1+x/707, 0.465));
  90. double sigma_y = 0.08 * destination2._x * SCALE *
  91. std::pow(1 + 0.0001 * destination2._x * SCALE, -0.5);
  92. double sigma_z = 0.06 * destination2._x * SCALE *
  93. std::pow(1 + 0.0015 * destination2._x * SCALE , -0.5);
  94. double h = 20;
  95. double disp = 1. / (2 * M_PI * wind_speed * sigma_y * sigma_z) *
  96. std::exp(-0.5 * std::pow(h / sigma_z, 2)) *
  97. std::exp(-0.5 * std::pow(destination2._y * SCALE / sigma_y, 2));
  98. return disp * 3600 * 24 * 1e4;
  99. } else {
  100. return 0.0;
  101. }
  102. }
  103. };
  104. } } } // namespace paradevs tests plot
  105. #endif