JaiaBot 2.0.0
JaiaBot micro-AUV software
 
Loading...
Searching...
No Matches
specific_conductivity.h
Go to the documentation of this file.
1
22double viscosity_ratio(double temperature_celsius)
23{
24 const double A = 1.1278;
25 const double B = 0.001895;
26 const double C = 88.93;
27
28 double delta = 25.0 - temperature_celsius;
29 double log_ratio = (A * delta - B * delta * delta) / (temperature_celsius + C);
30
31 return std::pow(10.0, log_ratio);
32}
33
60double tuned_b(double measured_conductivity, double temperature_celsius)
61{
62 // Normalize inputs
63 // range: ~0.05 to 1.5
64 double ec = measured_conductivity / 100000.0;
65 // range: 0 to 1
66 double t = temperature_celsius / 50.0;
67
68 // Polynomial model: b = intercept + coef1*ec
69 // + coef2*t + coef3*ec*t
70 // + coef4*ec^2 + coef5*t^2
71 double b = 0.67132 + 2.93970 * ec - 0.90973 * t - 11.85994 * ec * ec + 13.66141 * ec * t -
72 2.06555 * t * t + 12.93730 * ec * ec * ec - 26.03585 * ec * ec * t +
73 14.13775 * ec * t * t - 1.48252 * t * t * t;
74 // Clamp - Limit to physical bounds
75 return std::fmax(0.68, std::fmin(b, 0.88));
76}
77
93double calculate_specific_conductivity(const double measured_conductivity,
94 const double temperature_celsius)
95{
96 if (measured_conductivity < 8000.0)
97 {
98 // Linear model for low EC (<8000 µS/cm)
99 return measured_conductivity / (1.0 + 0.0191 * (temperature_celsius - 25.0));
100 }
101 else
102 {
103 double b = tuned_b(measured_conductivity, temperature_celsius);
104 double mu_ratio = viscosity_ratio(temperature_celsius);
105 return measured_conductivity * std::pow(mu_ratio, b);
106 }
107}
double tuned_b(double measured_conductivity, double temperature_celsius)
This function returns the tuning factor 'b' used in conductivity temperature compensation....
double viscosity_ratio(double temperature_celsius)
Calculates the viscosity ratio µ_t / µ_25 using the empirical formula, which models how water's visco...
double calculate_specific_conductivity(const double measured_conductivity, const double temperature_celsius)
Computes specific conductivity at 25 °C using temperature compensation.