Skip to content

Commit f804076

Browse files
committed
0.1.0 WaterMix
1 parent 20e7576 commit f804076

File tree

15 files changed

+650
-0
lines changed

15 files changed

+650
-0
lines changed

libraries/WaterMix/.arduino-ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
16+
compile:
17+
# Choosing to run compilation tests on 2 different Arduino platforms
18+
platforms:
19+
- uno
20+
# - due
21+
# - zero
22+
# - leonardo
23+
- m4
24+
- esp32
25+
# - esp8266
26+
# - mega2560
27+
- rpipico
28+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# These are supported funding model platforms
2+
3+
github: RobTillaart
4+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
name: Arduino-lint
3+
4+
on: [push, pull_request]
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: arduino/arduino-lint-action@v1
11+
with:
12+
library-manager: update
13+
compliance: strict
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
runTest:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: json-syntax-check
15+
uses: limitusus/json-syntax-check@v1
16+
with:
17+
pattern: "\\.json$"
18+

libraries/WaterMix/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change Log WaterMix
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.1.0] - 2023-08-29
10+
- initial version
11+

libraries/WaterMix/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-2023 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libraries/WaterMix/README.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
2+
[![Arduino CI](https://github.com/RobTillaart/WaterMix/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/WaterMix/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/WaterMix/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/WaterMix/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/WaterMix/actions/workflows/jsoncheck.yml)
5+
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/WaterMix.svg)](https://github.com/RobTillaart/WaterMix/issues)
6+
7+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/WaterMix/blob/master/LICENSE)
8+
[![GitHub release](https://img.shields.io/github/release/RobTillaart/WaterMix.svg?maxAge=3600)](https://github.com/RobTillaart/WaterMix/releases)
9+
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/WaterMix.svg)](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

Comments
 (0)