aboutsummaryrefslogtreecommitdiff
path: root/science/chemicalfun/files/test.py
blob: b9e1b5abc8b136b21875b76fbb9150b4fae50977 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# test from README

import chemicalfun as cf

formulas = ['Ca+2', 'CO3-2', 'H+', 'OH-', 'HCO3-', 'CaCO3', 'H2O']

chemicalReactions = cf.ChemicalReactions(formulas)

reactions = chemicalReactions.generateReactions() # returns the reactions list as a list of tuples ('substance', coefficient)

# can be transformed to a list of dictionaries, with reaction substances as keys and the reaction coefficients as values
reactions_dic = [{el[0]: el[1] for el in r} for r in reactions] 

print(chemicalReactions.printReactions())
print(reactions_dic)