[ase-users] Find space group
Jens Jørgen Mortensen
jensj at fysik.dtu.dk
Wed Jan 28 15:48:21 CET 2009
On Sat, 2009-01-24 at 19:21 +0900, Atz Togo wrote:
> Dear ASE users,
>
> I made the small code to find space group for ASE Atoms class. I send
> this e-mail because I wonder if some developer may be interested in
> space group or crysta symmetry search.
Thanks for the tip! It would be good to put this information somewhere
in the ASE web-pages. If you put the C-wrapper and the information on
how compile the Python extension on sourceforge, then we can make a link
to that and put an ASE example in the ASE documentation.
In the example below, you give the positions in scaled coordinates
(relative to the unit cell), so you must use:
bulk = Atoms(symbols='Si8',
cell=[(4,0,0),
(0,4,0),
(0,0,4)],
scaled_positions=[(0, 0, 0),
(0, 0.5, 0.5),
(0.5, 0, 0.5),
...
If your get_spacegroup() function needs scaled coordinates, then you
should not use atoms.positions - use atoms.get_scaled_positions()
instead.
Jens Jørgen
> The following example code requires the spglib library
> (http://spglib.sourceforge.net/) that I made. The usage of an example
> code is like this.
>
> % python example_ase.py
> Fd -3 m (227)
>
> The codes and makefile are written below, and are found in svn
> repository of spglib, too.
>
> ---------python example (example_ase.py)--------------
> #!/usr/bin/evn python
>
> from ase import *
> import _spglib as spg
>
> bulk = Atoms(symbols='Si8',
> cell=[(4,0,0),
> (0,4,0),
> (0,0,4)],
> positions=[(0, 0, 0),
> (0, 0.5, 0.5),
> (0.5, 0, 0.5),
> (0.5, 0.5, 0),
> (0.25, 0.25, 0.25),
> (0.25, 0.75, 0.75),
> (0.75, 0.25, 0.75),
> (0.75, 0.75, 0.25)],
> pbc=True)
>
> spg.get_spacegroup(bulk.numbers.size, bulk.cell, bulk.positions,
> array(bulk.numbers, dtype=int32), 1e-5)
> ------------------------------
>
> --------c-wrapper-----------
> #include <Python.h>
> #include <stdio.h>
> #include <numpy/arrayobject.h>
> #include <spglib.h>
>
> static PyObject * get_spacegroup(PyObject *self, PyObject *args);
>
> static PyMethodDef functions[] = {
> {"get_spacegroup", get_spacegroup, METH_VARARGS, "Space group finder"},
> {NULL, NULL, 0, NULL}
> };
>
> PyMODINIT_FUNC init_spglib(void)
> {
> PyObject* m = Py_InitModule3("_spglib", functions,
> "C-extension for spglib\n\n...\n");
> }
>
> static PyObject *get_spacegroup(PyObject *self, PyObject *args)
> {
> int i, j;
> int size;
> double symprec;
> char symbol[21];
> PyArrayObject* lattice;
> PyArrayObject* position;
> PyArrayObject* atom_type;
> if (!PyArg_ParseTuple(args, "iOOOd", &size, &lattice, &position,
> &atom_type, &symprec))
> return NULL;
>
> double* lat = (double*)lattice->data;
> double* pos = (double*)position->data;
> int* typat = (int*)atom_type->data;
>
> i = spg_get_international(symbol, lat, pos, typat, size, symprec);
> printf("%s (%d)\n", symbol, i);
>
> Py_RETURN_NONE;
> }
> --------------------------
>
> -------makefile-----------
> CC = gcc
> PYINC = /usr/include/python2.5
> NUMPYINC = /usr/lib/python2.5/site-packages/numpy/core/include
>
> _spglib.so: example.c
> $(CC) example.c -g -I$(PYINC) -I$(NUMPYINC) -I$(SPGLIBINC)
> -L$(SPGLIB) -lsymspg -fpic -shared -o _spglib.so
>
> clean:
> rm -f _spglib.so core
> -------------------------------
>
> Best regards,
>
> --
> Atsushi Togo
> Department of Materials Science and Engineering
> Kyoto University
> Yoshida-Honmachi, Sakyo-ku, Kyoto 606-8501, Japan
> E-mail: atz.togo at gmail.com
> E-mail: atz.togo at gmail.com
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
More information about the ase-users
mailing list