Chemistry - How should elements be colored? And how many bonds does an atom have?
Solution 1:
For the coloring part I would suggest you look at the CPK coloring convention.
As for the decision whether a bond is a single or a double bond: You could make this decision based on the bond length between two atoms. But you will need to find typical values for single, double and triple bonds for every combination of elements which seems a bit too much trouble. On the other hand, the depiction of double and triple bonds is used mostly for bonds between carbon, oxygen, sulfur, phosphorus and nitrogen (for other elements like metals the bond order is not readily identifiable, so I would leave those as single bonds). So, the amount of data to be collected might not be that large.
A very naive way to make the decision how many bonds an atom has could be the following (though this might not be very efficient):
- calculate the distances between the atoms
- for each element set a maximum distance another atom can be away from an atom of the element in question to be considered a bonding partner
- for each element set a maximum number of bonds $N_{\mathrm{max}}$ an atom of this element can have, e.g. 4 for carbon, 4 for nitrogen, 3 for oxygen, etc. (for metals this might be a bit difficult to decide)
- for each atom in the system order the list of atoms within bonding distance from lowest to highest distance. From this list choose only the first to $N_{\mathrm{max}}$th atoms as bonding partners. Then look whether some of the bonding partners qualify for double or triple bonds - if so you have to kick out some of the bonding members from the end of your bond candidates so that you don't exceed your maximum bond number.
There will be better ways out there to do this but this one worked for me in the process of creating "static" pictures of molecules.
Update:
You asked what size you should use for your atoms. Again, there is no definite answer to this - use whatever looks best for you. Nevertheless, I found that the sizes calculated according to the following formula give rather good looking atom size ratios for the different elements (maybe you have to multiply the resultant values by a constant to give good default sizes):
\begin{equation} \text{size} = \frac{1}{2 \sqrt{2}} \cdot \sqrt[6 \,]{\text{atomic number}} \ . \end{equation}
Furthermore, here is a nice source for some typical bond distances. Other good resources would be the CRC Handbook of Chemistry and Physics or the book by Holleman and Wiberg if you can lay your hands on them. Those might come in handy if you try to adapt my method and look for values for the maximum bond distances. Another advice concerning the maximum bond distances would be that typical values for the bond lengths of bonds containing (transition) metals are between 200 and 300 pm, so a value of 350 or 400 pm might be a good choice for the maximum bond distance for those species.
Concerning the maximum bond number each element can have: here, the typical rules for drawing Lewis structures apply. You can find good resources for this on this site, e.g. here, and in every introductory general chemistry text. But you should be mindful of some special cases. You should not forget the cationic forms of the elements, when thinking about their maximum bond number. For example, carbon usually has 4 bonds, but there are very rare cases where it comes with 5 bonds ($\ce{CH5^{+}}$) although those are practically not important and some not so rare cases where it has 3 bonds (carbenes, carbocations, carbanions), so you might consider a maximum bond number of 5 for carbon, although for nearly all practical purposes 4 might do. Another example is oxygen. It usually has 2 bonds but when it is protonated or in Meerwein's reagent ($\ce{Me3O^{+}BF4^{-}}$) it has 3 bonds. Transition metals are very flexible when it comes to the number of bonds they have - it can be everything from 1 to 6 sometimes even more, so you should choose a high number, e.g. 8, for them.
Solution 2:
To extend on Philipp's excellent answer, I'd like to offer some advice on judging bond orders. Pekka Pyykkö and Michiko Atsumi published covalent (single-, double-, triple-) bond radii for (almost) the entire periodic table in Chem. Eur. J. 2009, 15, 12770-12779. It is summarised in figure 3. These are obtained from experimental or theoretical data. The figure itself can be found on Pyykkö's homepage as a pdf-file. This version has been extended to include tetrahedral covalent radii. I include a screenshot for reference.
Another interesting and comprehensive publication for sizes of atoms is the list of Van der Waals radii of elements by S. S. Batsanov published in Inorg. Mat. 2001, 37 (9), 871-885. A mirror of the publisher's pdf can be found here. This is probably also a good starting point for deciding the default size of your atoms. Additionally it might help you identify weak interactions.
One last word on colouring: the mentioned CPK colouring scheme is widely known and many chemists understand it intuitively now, but it is not uncommon that programs specify their own schemes. That mostly depends of the background you would like to use. One of the most common deviations is carbon, which originally used black, but nowadays often is displayed grey because many viewers prefer dark backgrounds. Also frequently changed is the colour for hydrogen when using light backgrounds as white doesn't identify as well then.