JaiaBot  1.20.1
JaiaBot micro-AUV software
specific_conductivity.h File Reference

Go to the source code of this file.

Functions

double viscosity_ratio (double temperature_celsius)
 Calculates the viscosity ratio µ_t / µ_25 using the empirical formula, which models how water's viscosity changes with temperature. More...
 
double tuned_b (double measured_conductivity, double temperature_celsius)
 This function returns the tuning factor 'b' used in conductivity temperature compensation. It’s based on a polynomial surface fitted to a bunch of known reference solutions (like Hamilton and Atlas Scientific), where we had both measured conductivity and the “true” specific conductivity. More...
 
double calculate_specific_conductivity (const double measured_conductivity, const double temperature_celsius)
 Computes specific conductivity at 25 °C using temperature compensation. More...
 

Function Documentation

◆ calculate_specific_conductivity()

double calculate_specific_conductivity ( const double  measured_conductivity,
const double  temperature_celsius 
)

Computes specific conductivity at 25 °C using temperature compensation.

For measured conductivity values below 8000 µS/cm, this uses a standard linear correction model based on a 1.91%/°C adjustment factor.

For values above 8000 µS/cm, this uses a viscosity-based model with an auto-tuned exponent 'b', derived from empirical data across a wide range of temperatures and conductivities. This approach better captures nonlinear effects at higher ion concentrations.

Parameters
measured_conductivityMeasured conductivity in µS/cm
temperature_celsiusTemperature of the measurement in degrees Celsius
Returns
double Specific conductivity at 25 °C

Definition at line 93 of file specific_conductivity.h.

◆ tuned_b()

double tuned_b ( double  measured_conductivity,
double  temperature_celsius 
)

This function returns the tuning factor 'b' used in conductivity temperature compensation. It’s based on a polynomial surface fitted to a bunch of known reference solutions (like Hamilton and Atlas Scientific), where we had both measured conductivity and the “true” specific conductivity.

The goal was to find a function for 'b' that works well across a wide range of temperatures and conductivities — ideally within 1% error. Rather than hardcode a bunch of if-statements, we fit a 3rd-degree polynomial using Python's scikit-learn (PolynomialFeatures + LinearRegression)

Inputs were normalized EC and temperature, and we calculated 'b' by rearranging:

specific = measured * pow(mu_ratio, b)
 → b = log(expected / measured) / log(mu_ratio)

The resulting fit works surprisingly well — it's smooth, doesn't need special cases, and holds up across all our test solutions from ~13 mS/cm up to 100 mS/cm, and 5°C to 50°C.

If you need to retrain this, check out the script in jaiabot/scripts/util_helpers/test_specific_conductivity.py

Parameters
measured_conductivityMeasured EC in µS/cm
temperature_celsiusTemperature in degrees Celsius
Returns
double Best-fit exponent b for temperature compensation

Definition at line 60 of file specific_conductivity.h.

◆ viscosity_ratio()

double viscosity_ratio ( double  temperature_celsius)

Calculates the viscosity ratio µ_t / µ_25 using the empirical formula, which models how water's viscosity changes with temperature.

The equation is: log10(µ_t / µ_25) = [A(25 - T) - B(25 - T)^2] / (T + C)

This is used in conductivity compensation to adjust for the effect of temperature on ion mobility.

Parameters
temperature_celsiusTemperature in degrees Celsius
Returns
double Viscosity ratio µ_t / µ_25
Note

References:

Definition at line 22 of file specific_conductivity.h.