Skip to content

Instantly share code, notes, and snippets.

@jarvist
Last active September 9, 2018 00:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jarvist/4570215 to your computer and use it in GitHub Desktop.
Save jarvist/4570215 to your computer and use it in GitHub Desktop.
Calculates vertices of C60 buckyball from the Cartesian coordinates suggested on Wikipedia page, and a bit of permutation magic on the 'generator' thus describe. I'm sure there's a more elegant way to do the +- permutation too.
#See http://en.wikipedia.org/wiki/Truncated_icosahedron
phi = (1+5**0.5)/2 #golden mean
generator= [ [0,1,+3*phi],
[2,1+2*phi,phi],
[1,2+phi,2*phi]]
#From http://blog.adambachman.org/2008/10/simple-permutations-in-python-and-ruby.html
def permutations(li):
""" Return all permutations of a given list. This function
assumes every element of the list is unique. """
if len(li) <= 1: #changing this from 1 --> 2 gives only even (odd?!) permutations of list - JMF
yield li
else:
for el in li:
for p in permutations([e for e in li if not e == el]):
yield [el] + p
for (a,atom) in zip(generator,'CSP'):
print a
for (p,b) in zip(permutations(a),'01100'): #1st, 4th, 5th permutations are even
print p
if (b=='0'):
for a0 in [1,-1]:
for a1 in [1,-1]:
for a2 in [1,-1]:
print atom,a0*p[0],a1*p[1],a2*p[2]
#Visualise result with Pymol & something like:
#alter all, vdw=0.6
#show spheres
#show sticks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment