|
| 1 | + |
| 2 | +[](https://github.com/marketplace/actions/arduino_ci) |
| 3 | +[](https://github.com/RobTillaart/WaterMix/actions/workflows/arduino-lint.yml) |
| 4 | +[](https://github.com/RobTillaart/WaterMix/actions/workflows/jsoncheck.yml) |
| 5 | +[](https://github.com/RobTillaart/WaterMix/issues) |
| 6 | + |
| 7 | +[](https://github.com/RobTillaart/WaterMix/blob/master/LICENSE) |
| 8 | +[](https://github.com/RobTillaart/WaterMix/releases) |
| 9 | +[](https://registry.platformio.org/libraries/robtillaart/WaterMix) |
| 10 | + |
| 11 | + |
| 12 | +# WaterMix |
| 13 | + |
| 14 | +Arduino library for mixing water with different temperatures. |
| 15 | + |
| 16 | + |
| 17 | +## Description |
| 18 | + |
| 19 | +**Warning: Experimental** |
| 20 | + |
| 21 | +Experimental library for elementary math of mixing water with different temperatures. |
| 22 | + |
| 23 | +The library does some indicative math of mixing a volume of water with temperature T1 |
| 24 | +with a another volume with temperature temperature T2. |
| 25 | +In fact the library will work for any single liquid (TODO: liquidMix class). |
| 26 | + |
| 27 | +The library uses a generic volume parameter instead of gallons or liters as |
| 28 | +this way any user selected unit can be used. |
| 29 | +However you must use the chosen units consistently as you cannot use different |
| 30 | +units simultaneously. |
| 31 | + |
| 32 | +To use different units for volume you can get some help of the volume conversion |
| 33 | +library named **VolumeConverter** to convert the units. |
| 34 | + |
| 35 | +The temperature unit can also be chosen by the user and can be Kelvin, Celsius, |
| 36 | +Fahrenheit or other. |
| 37 | +However you must use the chosen units consistently as you cannot use different |
| 38 | +units simultaneously. Check **Temperature** library below. |
| 39 | + |
| 40 | +This library could be useful e.g. by doing "water math" for aquaria or cooking. |
| 41 | +Also the library is well suited for basic educational purposes. |
| 42 | + |
| 43 | + |
| 44 | +#### Accuracy |
| 45 | + |
| 46 | +The working range for temperature is not tested with real water. |
| 47 | +It is expected to work (roughly) for water with a range from 5°C to 80°C. |
| 48 | +In the (0.1.0) math it is assumed there is no expansion so the mass / volume is |
| 49 | +identical for "both volumes of waters". |
| 50 | + |
| 51 | +Of course this is incorrect, therefore it is expected to have a difference |
| 52 | +between the theoretical values and doing the mixing in practice. |
| 53 | +However the delta's are expected to be small, less than 1% in many cases. |
| 54 | +Given the accuracy of volume measurement and temperature measurement, |
| 55 | +this delta is often acceptable. |
| 56 | + |
| 57 | +TODO: |
| 58 | +- investigate in the effect of the volume expansion and contraction of |
| 59 | + the water due to the temperature delta, and how to handle it. |
| 60 | + |
| 61 | + |
| 62 | +#### Related |
| 63 | + |
| 64 | +- https://github.com/RobTillaart/Temperature |
| 65 | +- https://github.com/RobTillaart/VolumeConverter |
| 66 | +- https://github.com/RobTillaart/weight |
| 67 | + |
| 68 | + |
| 69 | +## Interface |
| 70 | + |
| 71 | +```cpp |
| 72 | +#include "WaterMix.h" |
| 73 | +``` |
| 74 | + |
| 75 | +#### Constructor |
| 76 | + |
| 77 | +- **WaterMix()** constructor, starts with no water of 0° |
| 78 | +- **void begin()** resets to no water of 0°. |
| 79 | +- **void add(float volume, float temperature)** add an amount of water |
| 80 | +with temperature to the "WaterMix". |
| 81 | +- **void sub(float volume)** subtract a volume from the "WaterMix". |
| 82 | +Temperature won't change. |
| 83 | +- **void div(float nr)** divide the amount of liquid, same temperature. |
| 84 | +- **void mul(float nr)** multiply the amount of liquid, same temperature. |
| 85 | +- **float volume()** get the current volume. |
| 86 | +- **float temperature()** get the current temperature. |
| 87 | + |
| 88 | + |
| 89 | +## Volumetric Coefficient of Expansion |
| 90 | + |
| 91 | +The VCE is not supported in the library. |
| 92 | + |
| 93 | +It is useful as background information as the theoretical volumes calculated in this |
| 94 | +library will differ from reality due to the VCE effect. |
| 95 | +This difference depends on the liquid used and the delta temperature. |
| 96 | + |
| 97 | + |
| 98 | +#### Water |
| 99 | + |
| 100 | +The VCE of water depends on the temperature, doing the math needs to be investigated. |
| 101 | + |
| 102 | +Source: - https://www.engineeringtoolbox.com/water-density-specific-weight-d_595.html |
| 103 | + |
| 104 | +| Temp °C | density | % wrt 4°C | V.C.E (\*10<sup>-4</sup>) | Notes | |
| 105 | +|:---------:|:------------|:----------:|:---------------------------|:--------| |
| 106 | +| 0.1 | 0,9998495 | 0,0125 | -0.68 | note negative value |
| 107 | +| 1 | 0,9999017 | 0,0073 | -0.50 | note negative value |
| 108 | +| 4 | 0,9999749 | 0,0000 | 0.003 | |
| 109 | +| 10 | 0,9997000 | 0,0275 | 0.88 | |
| 110 | +| 15 | 0,9991026 | 0,0873 | 1.51 | |
| 111 | +| 20 | 0,9982067 | 0,1771 | 2.07 | |
| 112 | +| 25 | 0,9970470 | 0,2937 | 2.57 | |
| 113 | +| 30 | 0,9956488 | 0,4345 | 3.03 | |
| 114 | +| 35 | 0,9940326 | 0,5978 | 3.45 | |
| 115 | +| 40 | 0,9922152 | 0,7821 | 3.84 | |
| 116 | +| 45 | 0,9902100 | 0,9861 | 4.20 | |
| 117 | +| 50 | 0,9880400 | 1,2079 | 4.54 | |
| 118 | +| 55 | 0,9856900 | 1,4492 | 4.86 | |
| 119 | +| 60 | 0,9832000 | 1,7062 | 5.16 | |
| 120 | +| 65 | 0,9805500 | 1,9810 | 5.44 | |
| 121 | +| 70 | 0,9777600 | 2,2720 | 5.71 | |
| 122 | +| 75 | 0,9748400 | 2,5784 | 5.97 | |
| 123 | +| 80 | 0,9717900 | 2,9003 | 6.21 | |
| 124 | +| 85 | 0,9686100 | 3,2381 | 6.44 | |
| 125 | +| 90 | 0,9653100 | 3,5911 | 6.66 | |
| 126 | +| 95 | 0,9618900 | 3,9594 | 6.87 | |
| 127 | +| 100 | 0,9583500 | 4,3434 | 7.03 | |
| 128 | + |
| 129 | + |
| 130 | +#### Other liquids |
| 131 | + |
| 132 | +Unknown if these liquids are expanding linear or not. |
| 133 | + |
| 134 | +Source: - https://www.engineeringtoolbox.com/cubical-expansion-coefficients-d_1262.html |
| 135 | +(extended table) |
| 136 | + |
| 137 | +| Liquid | V.C.E. per °C | V.C.E. per °F | |
| 138 | +|:--------------------------------------|:----------------|:----------------| |
| 139 | +| Acetone | 0.00143 | 0.00794 | |
| 140 | +| Alcohol, ethyl (ethanol) | 0.00109 | 0.000606 | |
| 141 | +| Alcohol, methyl (methanol,CH3OH) | 0.00149 | 0.000828 | |
| 142 | +| Calcium Chloride, 5.8% | 0.00025 | 0.00014 | |
| 143 | +| Engine oil | 0.0007 | 0.00039 | |
| 144 | +| Ethylene glycol | 0.00057 | 0.000312 | |
| 145 | +| Gasoline | 0.00095 | 0.000528 | |
| 146 | +| Glycerine (glycerol) | 0.00050 | 0.000278 | |
| 147 | +| Oil (unused engine oil) | 0.00070 | 0.000389 | |
| 148 | +| Olive oil | 0.00070 | 0.000389 | |
| 149 | +| Paraffin oil | 0.000764 | 0.000424 | |
| 150 | +| Petroleum | 0.0010 | 0.00056 | |
| 151 | +| Potassium chloride, 24.3% | 0.00035 | 0.000194 | |
| 152 | +| Sodium | 0.00027 | 0.00015 | |
| 153 | +| Sodium chloride, 20.6% | 0.00041 | 0.000228 | |
| 154 | + |
| 155 | + |
| 156 | +## Future |
| 157 | + |
| 158 | +#### Must |
| 159 | + |
| 160 | +- update documentation |
| 161 | + |
| 162 | + |
| 163 | +#### Should |
| 164 | + |
| 165 | +- create base class **LiquidMix** and derive a specific **WaterMix** from it. |
| 166 | + - code is quite identical |
| 167 | + - **WaterMix** can include specific heat, VCE etc. |
| 168 | +- include expansion of water VCE effect due to heat. |
| 169 | + - 4°C is smallest for water. |
| 170 | + - must use defined liquid and temp scale. |
| 171 | + - or add an expansion function? |
| 172 | + - needs investigation |
| 173 | + |
| 174 | + |
| 175 | +#### Could |
| 176 | + |
| 177 | +- performance measurements |
| 178 | +- cool(time) == depends on many factors |
| 179 | + - need to configure curve constant (only option). |
| 180 | + - must use defined liquid and temp scale. |
| 181 | +- energy functions to calculate how hot an amount of water |
| 182 | + should be to reach a certain temperature. |
| 183 | + - Think Aquaria or cooking. |
| 184 | +- add "unit string" + Printable interface? |
| 185 | + - -idem Temp scale? |
| 186 | +- extend unit tests |
| 187 | +- rename to **LiquidMix** class |
| 188 | + - WaterMixCelsius as derived class? |
| 189 | + - WaterMixFahrenheit as derived class? etc. |
| 190 | +- catch temperature below zero? |
| 191 | + - must use defined liquid and temp scale. |
| 192 | +- library can be used for water and salinity too |
| 193 | + - other linear related things. |
| 194 | +- **void AddEnergy(float joule)** to raise temperature (joule) |
| 195 | + - must use defined liquid and temp scale. |
| 196 | + - specific heat needed. |
| 197 | + |
| 198 | + |
| 199 | +#### Wont |
| 200 | + |
| 201 | + |
| 202 | +## Support |
| 203 | + |
| 204 | +If you appreciate my libraries, you can support the development and maintenance. |
| 205 | +Improve the quality of the libraries by providing issues and Pull Requests, or |
| 206 | +donate through PayPal or GitHub sponsors. |
| 207 | + |
| 208 | +Thank you, |
| 209 | + |
0 commit comments