I'm working on my own 3D molecule viewer for my AP Chem class. So far everything's going together nicely. There's a couple of things I'm not sure about though...
Is there a certain rule of thumb or standard for what colors each element inside a molecule should be? For example, Jmol renders oxygen red and hydrogen white:
For my app they are currently grey:
Also, how can I check if there are single bonds, double bonds, etc.? As you can see here, I haven't programmed that yet into my app. Tylenol:
I look up coordinates for each molecule in an NCI/CADD group server online database. This database gives me the number of elements, and the X
, Y
, and Z
coordinates for where I should put each element. For example, water:
3
H2O
O -0.0000 -0.0589 -0.0000
H -0.8110 0.4677 0.0000
H 0.8110 0.4677 0.0000
It doesn't tell me anything about where bonds go. More info about .xyz
file format here.
Answer
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.
No comments:
Post a Comment