Real gas blender

Current contents of cylinder: bar of trimix /.
Target contents of cylinder (leave He part 0 to mix nitrox): bar of trimix /.
First top up gas: trimix /.
Second top up gas: trimix (will not be used if target is nitrox) /.
Final top up gas: trimix /.

This calculation takes into account corrections for real gases. It does not use the van der Waals equation as that does not give quantitatively good results in the regime relevant to diving cylinders. Rather it uses the same polynomial fit as Subsurface. Code available on GitHub.
Note that this calculation is only as good as the assumption that everything happens at room temperature. So fill slowly and wait for it to cool down. Another assumption is that the percentual composition does not change upon chanes of perssure, i.e. we assume all components compress in the same way.