physics.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef PHYSICS_HPP
  2. #define PHYSICS_HPP
  3. #include <cmath>
  4. #include <cassert>
  5. #include <iostream>
  6. #include <fstream>
  7. using namespace std;
  8. //! The Physics class contains all physical parameters characterising the soil.
  9. //! This class contains only static members.
  10. class Physics{
  11. public:
  12. static constexpr double minimal_height_to_runoff=0.019;
  13. enum Model{BrooksCorey};
  14. //! Set physics model
  15. static void setModel(Model model);
  16. //! Gravity acceleration (m.s^-2)
  17. static double g;
  18. //! Fluid density (g.l^(-1))
  19. static double rho;
  20. //! Porosity of the soil
  21. static double phi;
  22. //! Conductivity of the saturated soil
  23. static double k0;
  24. static double Psec;
  25. //! Characterise the water pressure at the bottom of the overland water
  26. static double nivrivsat;
  27. //! Model used
  28. static Model model;
  29. //! Return the saturation in function of the pressure
  30. static double (*s)(double);
  31. //! Return the derivtive of the saturation in function of the pressure
  32. static double (*ds)(double);
  33. //! Set the saturation and its derivative in function of the pressure
  34. static void (*s_ds)(double,double&,double&);
  35. static double (*s_inv)(double);
  36. //! Return the relative conductivity in function of the pressure
  37. static double (*kr)(double);
  38. //! Return the derivtive of the relative conductivity in function of the pressure
  39. static double (*dkr)(double);
  40. //! Set the relative conductivity and its derivative in function of the pressure
  41. static void (*kr_dkr)(double,double&,double&);
  42. //---------------------
  43. // Models descriptions
  44. //---------------------
  45. //! Datas used to define the model
  46. static double model_data[6];
  47. //! Max model Datas
  48. static const size_t max_model_parameters=6;
  49. //------------------------
  50. // Brooks and Corey model
  51. //------------------------
  52. //model_data[0] -> psat : minimal pressure such that s(psat)=1
  53. //model_data[1] -> sres : residual pressure
  54. //model_data[2] -> lambda
  55. //model_data[3] -> alpha
  56. //! Brooks and Corey saturation map
  57. static double s_BC(double P);
  58. //! Brooks and Corey derivative of the saturation map
  59. static double ds_BC(double P);
  60. //! Brooks and Corey saturation and its derivative setter
  61. static void (s_ds_BC)(double P,double& v,double& dv);
  62. static double s_inv_BC(double s);
  63. //! Brooks and Corey relative conductivity map
  64. static double kr_BC(double P);
  65. //! Brooks and Corey derivative of the relative conductivity map
  66. static double dkr_BC(double P);
  67. //! Brooks and Corey relative conductivity and its derivative setter
  68. static void (kr_dkr_BC)(double P,double& v,double& dv);
  69. static double Psoil(double hsoil,double hov);
  70. static double dPsoil(double hsoil,double hov);
  71. static double invPsoil(double hsoil,double Psol);
  72. static double tilde_a(double l,double hbot);
  73. static double tilde_c (double l,double hbot);
  74. //--------------------
  75. // File input/output
  76. //--------------------
  77. static void save(fstream& file);
  78. static void load(fstream& file);
  79. };
  80. #define Psat Physics::model_data[0]
  81. #endif