physics.hpp 2.8 KB

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