The Chemistry Project - now ChemSi.

ben@Eddie:~/Development/SI/ChemSi$ python
 Welcome to ChemKit (copyright 2015).
 > resultant KI + NaCl
 KI + NaCl -> KCl + NaI
 > set verbose
 Verbose mode on
 > resultant KI + NaCl
 KI + NaCl -> KCl + NaI
 KI: 166.003g/mol
 NaCl: 58.443g/mol
 KCl: 74.551g/mol; 33.21576375817387%
 NaI: 149.894g/mol; 66.78423624182614%
 > mass C8H18O

Recently I have been working on ChemSi, which is the chemical program I mentioned in my last post. I have since written quite a large amount of code for it to utilise an algorithm I came up with last night at about 1:00AM. It is not the smoothest algorithm, and it does get it wrong about 40% of the time. Regardless, it is relatively good for what is needed here.

In an effort for transparency I will explain how the algorithm works. It is based off of displacement reactions - so for addition and other forms it has some issues. It gets the lowest electronegativity (aka the most nucleophilic element) of the elements present in a structure. It works out how many valencies this has, and finds the highest electronegativity. It repeats this until all valencies are filled - but it does mean the original structures are destroyed (so covalent bonds are treated the same as ionic) - meaning a OH group may be split up, often with disastrous results. A better method might be to do a bunch of algorithms and rank their products on how few lone elements they have (for example with ChemSi entering 'C2H4 + H2O' will get you 'CH3OH + C + H2', when it should all be as a single ethanol molecule). It could then work out the most likely product.
Overall it feels like I am making good progress on it. I am hoping to have a fully working product by next friday (which can do percentage yields). Over the summer holidays I may attempt to add a GUI (sort of like IrYdium VLab, only open source, up to date, and with every reactant).

Talking about IrYdium, I have found that many programs which do these sorts of chemical reaction predictions (ie Chemist on Android/iOS, IrYdium) have a very limited range of chemicals and you feel as though they are preprogrammed results. IrYdium for instance seems to only have chemicals for neutralizations and working out how different things affect the rate. If ChemSi does get to the stage of having a GUI I can assure you it will allow for any chemical mixture, at any temperature (but I cannot say it will always be right ;)).