Hi David, Albert,

> The current reduceToPrimitive function is here:
>
> http://github.com/dlonie/avogadro/blob/master/libavogadro/src/extensions/crystallography/avospglib.cpp#L226
>
> What it does is:
>
> (1) Determine the spacegroup of the cell with spg_get_international
> (2) Clean up the structure with spg_refine_cell
> (3) Reduce the cell to it's primitive representation with spg_find_primitive
> (4) Update the molecule with the new cell matrix and coordinates
>
> The coordinates, lattice matrix, etc are kept in the same arrays
> throughout the process, so if refine_cell is changing the orientation,
> it should not matter since the reoriented matrix and refined
> coordinates are passed to the find_primitive function. I cannot see
> how calling the refine_cell function before the reduction would break
> the behavior, but I may be missing something.

I had a look at reduceToPrimitive and I also couldn't find something wrong.
So now I doubt spglib. There may be bug in spg_refine_cell in the
previous versions. I wrote the followng test code in C and confirmed
that the latest spglib works correctly. I've not tested but if this C
code also works for the spglib in the Avogadro, the problem might be
somewhere out of reduceToPrimitive.

#include "spglib.h"
#include <stdio.h>

int main()
{
  double lattice[3][3] = { {3, 0, 0}, {0, 3, 0}, {0, 0, 3} };
  double positions[32][3];
  double pos_orig[][3] = {
    {0, 0, 0},
    {0.0, 0.5, 0.5},
    {0.5, 0.5, 0.0},
    {0.5, 0.0, 0.5},
    {0.75, 0.25, 0.75},
    {0.25, 0.25, 0.25},
    {0.25, 0.75, 0.75},
    {0.75, 0.75, 0.25}
  };
  int types[32];
  int i, num_atom = 8, num_atom_prim, num_atom_bravais;
  double symprec = 1e-5;

  for (i = 0; i < num_atom; i++) {
    positions[i][0] = pos_orig[i][0];
    positions[i][1] = pos_orig[i][1];
    positions[i][2] = pos_orig[i][2];
    types[i] = 1;
  }

  num_atom_bravais = spg_refine_cell(lattice,
                                     positions,
                                     types,
                                     num_atom,
                                     symprec);

  for (i = 0; i < 3; i++) {
    printf("%f %f %f\n", lattice[i][0], lattice[i][1], lattice[i][2]);
  }
  for (i = 0; i < num_atom_bravais; i++) {
    printf("%d: %f %f %f\n", i, positions[i][0], positions[i][1],
positions[i][2]);
  }

  num_atom_prim = spg_find_primitive(lattice, positions, types,
num_atom_bravais, symprec);

  for (i = 0; i < 3; i++) {
    printf("%f %f %f\n", lattice[i][0], lattice[i][1], lattice[i][2]);
  }
  for (i = 0; i < num_atom_prim; i++) {
    printf("%d: %f %f %f\n", i, positions[i][0], positions[i][1],
positions[i][2]);
  }
}

Togo

>
> As a side note, I've recently started using your phonopy software
> after giving up a fight with PHON (it wouldn't recognize the symmetry,
> and doesn't seem to have an adjustable tolerance...). Phonopy is a
> wonderful tool, and I'm especially impressed by the matplotlib
> integration. I've been recommending it to my coworkers -- keep up the
> good work! :-)
>
> Dave



-- 
Atsushi Togo
http://atztogo.users.sourceforge.net/
[email protected]

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Avogadro-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

Reply via email to