ChemKit Developments

Recently I have been continuing development of ChemKit. It is now able to calculate Gibbs free energy and predict the temperatures at which different changes and reactions will occur, while also being able to calculate the atomic orbital energy levels.

In order to calculate the Gibb's free energy I required the entropy and enthalpy changes of the reaction. While it may be possible to calculate the enthalpy change by storing the relatively simple bond enthalpies (or using the atomic orbitals and working out the bond energies) it proved harder to do so for the entropy changes so I took the lazier option to just store the compounds in data tables. This allows the program to calculate the entropy and enthalpy changes, and hence predict the temperature at which a reaction will go using the typical Gibb's energy equation;

\Delta G = \Delta H - T\Delta S

This proved relatively useful. As shown below it allows for relatively accurate prediction of reactions;

> set temp 300
> gibbs H2O(l) -> H2O(g)
Entropy Change of Reaction: 118.78Jmol-1K-1
Enthalpy Change of Reaction: 44.01kJmol-1
Gibbs Free Energy at 300.0K: 8.376kJmol-1
Will reaction go?: No
Temperature: 370.516922041K
ln K: -3.35980746089
> set temp 400
> gibbs H2O(l) -> H2O(g)
Entropy Change of Reaction: 118.78Jmol-1K-1
Enthalpy Change of Reaction: 44.01kJmol-1
Gibbs Free Energy at 400.0K: -3.502kJmol-1
Will reaction go?: Yes
Temperature: 370.516922041K
ln K: 1.05354993983

As you can see, it says the reaction (more a state change in this case, I chose the state change because it is a well known one) will not occur at 300 kelvin, but will at 400 kelvin. As we know, water boils at 373.15 kelvin (100\circ C), so this seems likely. It further predicts that the temperature at which it will finally go is 370.5K - this is slightly below the temperature normally considered to be the boiling point however given the use of average data it is relatively close.

After writing this I decided to calculate the atomic orbital energies. As currently ChemKit uses electronegativites (which are based on the lowest occupied atomic orbital... kind of) it already sort of uses the energies to predict reaction products. Adding a calculator to work them out, however, makes the change more visible. For this I used the following equation;

E = -R_{y}\frac{Z^{2}}{n^2}

Where R_{y} is the Rydberg Constant for eV (13.6eV essentially the energy of a ground state electron in hydrogen), Z is the nuclear charge and $n$ is the principal quantum number. By adjusting the nuclear charge to take into account the electron shielding this produces some relatively accurate numbers;

> element Na
=== Sodium (Na) ===
Atomic Number: 11
Atomic Mass: 22.98977
Electronegativity: 0.9
1s0 (-1646.29eV): 2
2s0 (-275.515eV): 2
2p-1 (-166.67eV): 2
2p0 (-166.67eV): 2
2p1 (-166.67eV): 2
3s0 (-1.512eV): 1

> element F
=== Fluorine (F) ===
Atomic Number: 9
Atomic Mass: 18.9984
Electronegativity: 4.0
1s0 (-1102.062eV): 2
2s0 (-166.67eV): 2
2p-1 (-85.036eV): 2
2p0 (-85.036eV): 2
2p1 (-85.036eV): 1

> element H
=== Hydrogen (H) ===
Atomic Number: 1
Atomic Mass: 1.00794
Electronegativity: 2.1
1s0 (-13.606eV): 1


As you can see from this, the highest energy orbital in fluorine is -85.0eV, in sodium it is -1.5eV and in hydrogen it is -13.6eV. This means that as electrons will tend to have a higher probability in an area of lower energy the position in which an electron will have a higher probability in NaH is closer to the Hydrogen, while in HF it is closer to the fluorine - the electron wants to be in a lower energy state.

I am going to continue developing ChemKit as my primary project from now on (it can still be found on my github), and I will hopefully come out with the aforementioned Lorentz Transformation post within the week.

Cherenkov Radiation

Cherenkov radiation is the blue glow that is often seen radiating off of nuclear reactors as shown above. It occurs when a charged particle (in the form of beta radiation) is emitted from a nuclear reactor travelling faster than the speed of light in the medium surrounding it. In the case of a nuclear reactors this medium is generally water.

In water the speed of light is lower than the speed of light in a vacuum - it is 2.25x10^8m/s compared to 3x10^8. This means that if a particle is emitted from the nuclear reactor it is moving faster than the speed of light in water. As these particles generally travel very fast and are polar they are not refracted instantly, and this means that you can end up with particles of beta radiation (which are electrons) travelling faster than the speed of light in the water.  This means that as the electron travels it partially polarises the water and causes a disruption in the electromagnetic field. At lower velocities the field can respond elastically and not much happens, but at such high velocities the disturbance cannot respond quickly, and a shockwave of light builds up.

Cherenkov Radiation is blue because the the majority of the light given out is high energy. This means that it has high frequencies (E=hf) and to our eyes the blue cones are much more receptive to blue light than violet light. This means that the light appears blue to us, and not violet.





Chemiosmosis is one of the main unifying things between most types of life - it is present in all types of cell - prokaryotic, eukaryotic, and all subdivisions of these. It is, in its most essential form, a way of generating ATP. ATP is the major energy currency in living cells, as it is the thing which powers all cellular activities. For example, the sodium potassium pump which is used to maintain a concentration gradient of sodium and potassium by pumping sodium out of cells and potassium in relies on ATP. Another name for ATP is adenosine triphosphate, and it is formed when a phosphate group is attached onto a molecule of ADP - adenosine diphosphate - and it is this phosphate group which is removed to provide the energy. Due to the unstable nature of this bond ATP is very short lived, and so is not a useful energy storage for long periods of time unlike starch and glucose which are very stable and can last for a long time - like a potato.
This ATP is therefore very useful, and it is generated much like a hydroelectric dam. In a hydroelectric dam, water moves over a turbine and this turns a generator and electricity is produced, while in chemiosmosis protons (H+ ions) move across a semi permeable membrane and turn ATP synthase. ATP synthase is an enzyme on the membrane which is spun by the incoming protons and this spinning leads to the binding of an inorganic phosphate group (PO4) to ADP to produce ATP.
It is believed that this mechanism may suggest an origin of life. In alkaline water vents proton gradients exist naturally and it is not a big jump to assume that it is possible that proto cells made of iron may have formed naturally on these vents which may have been the precursors to modern cells - as these protocells adapted to the surroundings they may have evolved a basic ATP synthase which and pumping mechanisms which allowed them to generate their energy portably, thereby giving the first cell its ability to live separately, and therefore allowing the development of life as we know it.

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 ;)).

p53: The Gene that Cracked the Cancer Code

Recently I have been reading the book titled 'p53: The Gene that Cracked the Cancer Code' by Sue Armstrong. I am now reading 'General Chemistry' by Linus Pauling (do not expect a review on this one, it isn't really that sort of book - regardless, it is a very good textbook) and 'The Little Book of String Theory' Steven S. Gubser.

p53: The Gene that Cracked the Cancer Code


Price (as of writing): £16.99 on Amazon

Publisher Synopsis: 

All of us have lurking in our DNA a most remarkable gene, which has a crucial job - it protects us from cancer. Known simply as p53, this gene constantly scans our cells to ensure that they grow and divide without mishap, as part of the routine maintenance of our bodies. If a cell makes a mistake in copying its DNA during the process of division, p53 stops it in its tracks, summoning a repair team before allowing the cell to carry on dividing. If the mistake is irreparable and the rogue cell threatens to grow out of control, p53 commands the cell to commit suicide. Cancer cannot develop unless p53 itself is damaged or prevented from functioning normally.

Perhaps unsurprisingly, p53 is the most studied single gene in history.

This book tells the story of medical science's mission to unravel the mysteries of this crucial gene, and to get to the heart of what happens in our cells when they turn cancerous. Through the personal accounts of key researchers, p53: The Gene that Cracked the Cancer Code reveals the fascination of the quest for scientific understanding, as well as the huge excitement of the chase for new cures - the hype, the enthusiasm, the lost opportunities, the blind alleys, and the thrilling breakthroughs. And as the long-anticipated revolution in cancer treatment tailored to each individual patient's symptoms begins to take off at last, p53 remains at the cutting edge.

This timely tale of scientific discovery highlights the tremendous recent advances made in our understanding of cancer, a disease that affects more than one in three of us at some point in our lives.


This is a very interesting book, of which just the first few pages proposes new questions I had not thought of such as "Why so few?". Generally we assume that there are so many people with cancer that it is very common, but when you look into what actually causes cancer it is amazing how so few people get it in the first place. Billions of cell divisions go on in your body every day, and it is very rare that any of these will turn cancerous. This book explores this idea and the help that p53 provides in preventing cancers from spreading. To put it simply using an analogy this book uses a lot more proficiently than I can, p53 is a checkpoint in the synthesis stage of interphase in the mitotic cycle. It prevents damaged DNA to duplicate.

As well as explaining how p53 works and what it does, it also gives some insight into the researchers in this field and their struggles against large businesses, such as the Tobacco industry when research was published about smoking causing cancer. It almost turns into an espionage novel at that point! Overall this is a very good book, and one I would strongly recommend.

Some Project Updates.

Since I began this blog I have mentioned many projects I planned to start, but have not yet followed up on them. I thought I would take this time to just give a brief overview of the main ones: SERO, Coulomb, and DeepNeurone. I am also going to talk about a new project of mine.


Recently my internet connection dropped out so I had a chance to work on DeepNeurone. Unfortunately due to the scope of the project it is unlikely I will get a working worm brain, let alone a human brain. I have, however, managed to write a computer program which is able to have neurones, synapses, spikes, rebalancing and reduction. If you look at the largeish output file below you can see the output of one of the runs.

In the run I aimed to create 50 neurones with synapses between them. The program prints out this layout but it is largely rubbish - it is just a random network the machine came up with. It then generates the thing you see in the file. This takes about 5 minutes to run. In initial runs it generally worked itself to a stable area (after about 30 runs) in which the most neurones it could fire were firing, but every neurone fired another which fired another which fired the original - basically, it wasn't moving. Then I thought that maybe it needs some random firings added in - so I made it randomly flip a neurone every once in a while. This produces the pattern you see.



This has largely gone on the back burner - I do not have the time, energy, or money to work on this project. It does not seem to have much use at the moment, as any components for it I am able to fabricate will generally not be powerful enough. Maybe in the future.


Yet again, mainly on the back burner. I might revisit this, but the majority of the code has just become unorganised. The simulation basically devolved very inaccurately due to the floating point issues I ran into.

And finally, some good news - TBD CHemkit.

The final entry on this list is a new project. I have no idea what to call it yet, but it is quite an interesting idea. I do chemistry, and occasionally I need to balance an equation, calculate a reactions products or do atom economy/percentage yield calculations. This can get a bit overwhelming (and I have a paper shortage :D), but the majority of tools I have found are generally either expensive or just drawing tools. My idea is to write a custom built chemistry program whereby you can enter some products, some reactants, and it can calculate the molar ratios. It can then operate on this and work out atom economies, etc. Eventually I hope to make it be able to work out reaction products (but this could be hard - I can see how I could do it for simple compounds, but as you get larger it would be difficult). I have no idea if this will be a command line program, a website (might be nice?) or a GUI app. Should be fun regardless.

Life on the Edge: The Coming of Age of Quantum Biology

I know I said I would do books two at a time, but this one took me about 20 days to read (due to circumstances out of my control), and so I am going to do it standalone.

Life on the Edge: The Coming of Age of Quantum Biology.



Price (As of writing): £13.60 in Amazon (reduced from £20)

Publishers Synopsis: 

Life is the most extraordinary phenomenon in the known universe; but how does it work? Even in this age of cloning and synthetic biology, the remarkable truth remains: nobody has ever made anything living entirely out of dead material. Life remains the only way to make life. Are we missing a vital ingredient in its creation?

Like Richard Dawkins' The Selfish Gene, which provided a new perspective on how evolution works, Life on the Edge alters our understanding of life's dynamics. Bringing together first-hand experience of science at the cutting edge with unparalleled gifts of exposition and explanation, Jim Al-Khalili and Johnjoe Macfadden reveal the hitherto missing ingredient to be quantum mechanics and the strange phenomena that lie at the heart of this most mysterious of sciences. Drawing on recent ground-breaking experiments around the world, they show how photosynthesis relies on subatomic particles existing in many places at once, while inside enzymes, those workhorses of life that make every molecule within our cells, particles vanish from one point in space and instantly materialize in another.

Each chapter in Life on the Edge opens with an engaging example that illustrates one of life’s puzzles – How do migrating birds know where to go? How do we really smell the scent of a rose? How do our genes manage to copy themselves with such precision? – and then reveals how quantum mechanics delivers its answer. Guiding the reader through the maze of rapidly unfolding discovery, Al-Khalili and McFadden communicate vividly the excitement of this explosive new field of quantum biology, with its potentially revolutionary applications, and also offer insights into the biggest puzzle of all: what is life? As they brilliantly demonstrate here, life lives on the quantum edge.


This is possibly one of the best written books I have ever read. It is written in a nice easy to read manner that still pushes across the complexity of the topic. It is a relatively large book (not as long as some, but certainly longer than The Sixth Extinction and Nothing) but I felt a sort of conciseness while reading it - it never appeared to drag on any longer than it needed to. The chapter on photosynthesis and others had nice analogies and anecdotes to go along with them such as the anecdote about the MIT Researchers trying to make a Quantum Computer. This book really opened my mind to biology and the interlinking of the sciences. It also explains the Quantum stuff very well to someone who may not have read about it before. I would recommend it to anyone who enjoys biology or physics.

The Sixth Extinction - An Unnatural History & Nothing

Apparently I am far too lazy to keep this up to date, and therefore I will probably be coupling books up. Coulomb is slightly delayed, largely because I got bored with it - I will post the source code on github in a few days should anyone wish to look. S.E.R.O. is coming along well and I am tying it into Elora, which is basically Hermoine reinvented - it learns from me and the internet.

In the mean time I have been reading a bunch of books, namely 'The Sixth Extinction' by Elizabeth Kolbert and 'Nothing' by the NewScientist people. I am moving on to now read 'Life on the Edge - The Coming of Age of Quantum Biology' by Jim Al-Khalili and Johnjoe McFadden. Onto the reviews I suppose;

The Sixth Extinction


Price (As of writing): £8.99 on Waterstones.

Publishers Synopsis: 

Over the last half a billion years, there have been five mass extinctions of life on earth. Scientists around the world are currently monitoring the sixth, predicted to be the most devastating extinction event since the asteroid impact that wiped out the dinosaurs. Elizabeth Kolbert combines brilliant field reporting, the history of ideas and the work of geologists, botanists and marine biologists to tell the gripping stories of a dozen species - including the Panamanian golden frog and the Sumatran rhino - some already gone, others at the point of vanishing. The sixth extinction is likely to be mankind's most lasting legacy and Elizabeth Kolbert's book urgently compels us to rethink the fundamental question of what it means to be human.


A very nice book. Covers some very interesting topics in very accessible ways and the author has a nice way of moving between topics - it all seems very fluid. Would prefer it if it went a bit more indepth into some areas, and some sections drag on a bit, but both are easily solvable - you can google for more information if necessary and the sections aren't so long that it gets unbearable if you aren't so interested in one. My favourite section was probably 'The Original Penguin'. I would recommend this book to anyone interested about biology, extinction, and ecology.

Nothing (2013 edition)


Price: £6.39

Publisher's Synopsis

Zero, zip, nada, zilch. It's all too easy to ignore the fascinating possibilities of emptiness and non-existence, and we may well wonder what there is to say about nothing. But scientists have known for centuries that nothing is the key to understanding absolutely everything, from why particles have mass to the expansion of the universe - so without nothing we'd be precisely nowhere.

Absolute zero (the coldest cold that can exist) and the astonishing power of placebos, light bulbs, superconductors, vacuums, dark energy, 'bed rest' and the birth of time - all are different aspects of the concept of nothing. The closer we look, the bigger the subject gets. Why do some animals spend all day doing nothing? What happens in our brains when we try to think about nothing?

With chapters by 20 science writers, including top names such as Ian Stewart, Marcus Chown, Helen Pilcher, Nigel Henbest, Michael Brooks, Linda Geddes, Paul Davies, Jo Marchant and David Fisher, this fascinating and intriguing book revels in a subject that has tantalised the finest minds for centuries, and shows there's more to nothing than meets the eye.


The book covers a lot - from the physical concepts such as the vacuum (and energy stored within) to animals doing nothing. It covers each in a nice amount of detail, and due to the multitude of authors writing it ends up being a very nice reading experience - you never have to 'put up' with the same author for too long. I would recommend it to anyone who wants to get into any sort of science.