# Looking for crystal generator library

I am looking for a C or a C++ library that can do crystal generation, that is, multiply unit cells in one or more directions with symmetry information. (in other words, generate supercells). I have been using OpenBabel (also C++) but it doesn't have this function (it is more oriented to molecules).

If the library can read or write CIF or other similar formats that would be even better.

Can you recommend one?

I know that libraries like this exist in Python, e.g. ASE, but I need to generate them on the fly (e.g from CIF files.)

I am not looking in particular to generate random periodic structures, but it is fine as long as the simpler case I mention above can be performed as well.

• Try SYMLIB and see if that works.
– PBH
Oct 15 at 5:33
• +1! What a great first question, already 10 upvotes and 3 bookmarks. Thank you for contributing your question here and we hope to see much more of you in the future !!! Oct 16 at 4:43
• @NikeDattani, I think there is a great need for a library like this. Anecdotally, I couldn't find one yet. I think my best option will be to contribute this functionality to OpenBabel, although that code base is quite messy/outdated.
– alfC
Oct 16 at 4:50
• @alfC let's hope our fellow MatterModeling.SE user Geoff Hutchison either agrees with your last comment, or doesn't see it! Oct 16 at 4:53
• @NikeDattani, let's see. I mean, it is amazing that can read and write so many formats. I mean "outdated" in the sense of the coding practices. And I mean "messy" in the sense of... well, messy.
– alfC
Oct 16 at 8:44

Please feel free to contribute to Open Babel. I'm sure people would use it! Probably the easiest C++ code to adapt would be from Avogadro 1, which directly used the Open Babel API.

For example the "supercell extension"

      // For each atom, we loop through:
// * convert the coords back to inverse space
// * apply the transformations
// * create new atoms
// * check for atoms in the same spot due to symmetry
…


There are methods to put all the atoms into the unit cell (not strictly required), and duplicate the unit cell -- which is just a big triple loop over a, b, and c repeats.

If you want more specific pointers, ping me on the Open Babel GitHub or mailing list.