Skip to content

Commit 5a46fcf

Browse files
committed
Various utility functions
1 parent 449f48e commit 5a46fcf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

utils.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Utils:
2+
def sgToBrix(sg):
3+
#TODO
4+
pass
5+
6+
def brixToSg(brix):
7+
sg = (brix / (258.6 - ((brix/258.2) * 227.1))) + 1
8+
return sg
9+
10+
def abvCalc(startBrix=None,endBrix=None,startSG=None,endSG=None):
11+
#TODO
12+
pass
13+
14+
def dilution(startConcentration=None, startVolume=None, endConcentration=None, endVolume=None):
15+
# Check if we have the proper variables to solve for
16+
varCount = 0
17+
if startConcentration: varCount +=1
18+
if endConcentration: varCount +=1
19+
if startVolume: varCount +=1
20+
if endVolume: varCount +=1
21+
if varCount != 3:
22+
#TODO Raise Exception
23+
print("Wrong var count")
24+
return None
25+
if not startConcentration:
26+
startConcentration = (endConcentration * endVolume) / startVolume
27+
return startConcentration
28+
if not endConcentration:
29+
endConcentration = (startConcentration * startVolume) / endVolume
30+
return endConcentration
31+
if not startVolume:
32+
startVolume = (endConcentration * endVolume) / startConcentration
33+
return startVolume
34+
if not endVolume:
35+
endVolume = (startConcentration * startVolume) / endConcentration
36+
return endVolume

0 commit comments

Comments
 (0)