This script was written to generate multiplication tables for symmetry elements to test whether they form a group. It was designed to save time when doing a group theory problem sheet, but ended up taking quite a lot longer even than writing out the largest multiplication table on the problem sheet by hand would have done.
The physics—a quick overview of group theory
A group is a collection of elements (for example, a, b, c, d…) with certain properties:
- Multiplying elements together must give an element which is also in the group. So, for example, a × b = c, or a × a = d, or whatever.
- There is one element which doesn’t change an element it’s multiplied by—just like the number 1, because 1 × anything = the same thing. This is called the identity element.
- Every element has an inverse such that an element multiplied by its inverse is the identity element. For example, the inverse of the number 4 is ¼, because 4 × ¼ = 1.
- Multiplication is associative: this means that (a × b) × c = a × (b × c). This is obviously true with numbers: try it!
Point groups are groups of symmetry elements, like mirror planes and rotation axes. A symmetry element represents doing something to an object which leaves it looking the same after you’ve done it—like turning a brick upside-down: if you looked away, you wouldn’t know if I’d turned it upside-down or not.
A very simple group could contain just the identity element (labelled 1—which means to leave an object alone, so obviously it would look the same afterwards!) and a two-fold rotation axis (labelled 2—this means turning an object around by 180°). If you draw a multiplication table for this group, you find that it obeys all the properties listed above:
- There are only 1s and 2s, so all elements multiply to give other elements.
- The identity element is there: 1.
- In this particularly simple case, every element is its own inverse. For example, if you rotate an object by 180° twice, you take it full circle and are back to the original object.
- It is associative (honest!), but that’s not obvious from the table—try it if you don’t believe me!
Also, for this simple group it doesn’t matter what order you do the operations in: the table is symmetrical about the diagonal from top left to bottom right. A group in which the order doesn’t matter is called abelian.
You can see SymGen’s output for this group here.
There are 32 crystallographic point groups. Here are a few of them, as examples of SymGen’s output:
It is also possible to generate multiplication tables for sets of symmetry elements which do not form a valid group:
- Proof that it all goes wrong if you don't include the identity operator
- Unmitigated disaster
SymGen deals with 3 × 3 matrices as arrays running from
$operation[id]. This is a totally tacky and non-general way of doing things, but it suffices in this limited application. The other elements of the
$operation[id] array are
$operation[id]['type']. The former is the nice HTML code for a given symmetry operation (like
<span class="bar">4</span><sup>3</sup>, giving 43), and the latter just a way of grouping together like operations such that the page in which symmetry elements are entered isn’t a total mess!
SymGen starts by defining a few custom functions:
multiply_matrices($a, $b)does exactly what it says on the tin if you send it two matrices
compare_matrices($c, $d)tells you if two matrices
$dare the same or not, returning a boolean
TRUEif they are and
exactify($x)deals with the annoying problem that PHP only has finite accuracy. For example, under certain circumstances operations involving irrational numbers will result in calculations which should equal 0 being equal to
7.231944E-17and other such ludicrously small values. This function sets anything which is within 10-6 of certain values (0, 1, 2 etc) to the exact value, meaning that comparing two matrix elements where one is 0 and the other 10-17 will result in their being found to be equal, even though they’re not quite.
Having defined these, it generates the various symmetry operations in matrix form. It starts by simply defining 1 and 1. Then, reflection symmetries are generated from by inputting various different normal vectors into a general mirror plane generating matrix. After that, rotation matrices are made with a nested loop, going through the order of rotation (2-, 3-, 4- or 6-fold rotations being permitted in crystalline structures, with n-1 possible rotations for rotation of order n) and a range of different axes.
It then checks for whether or not the user’s web browser has sent it any data. If it hasn’t, it displays a form asking for the symmetry elements it should try to make a group out of. If it has, it draws a symmetry multiplication table.
- SymGen currently only works for rotations parallel to and reflections normal to the Cartesian axes, plus 1 and 1 because they operate about a point.
- Though I wouldn’t really call this a limitation…SymGen only uses international notation because Schönflies notation is rubbish.
- Display which symmetry operation is missing, rather than just a cross. Make it clickable to add that operation into the group.
- Make it work for hexagonal and trigonal crystals.
SymGen is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales license. This means you can copy, adapt or otherwise use it as long as you give credit (a link here would be lovely) and aren't making any money from it.