CCL Home Page
Up Directory CCL matfract
/* matfract is a conversion program that takes a matrix file concatenated with a
   fractional coordinates file as input from stdin and converts it to a standard
   fractional file on stdout.
   format of the matrix file : unformatted input (only sequence important)
   number of symmetry operations : nsymm
   for every symmetry operation  : M11 M12 M13 T1 M21 M22 M23 T2 M31 M32 M33 T3
   The symmetry operations performed are :
   / M11 M12 M13 \ / x \   / T1 \
   | M21 M22 M23 | | y | + | T2 |
   \ M31 M32 M33 / \ z /   \ T3 /
   with (x,y,z) as the fractional coordinates listed in the appended fractional
   coordinates file.
   The symmetry operations are only performed on the input coordinates (not on the
   generated ones from previous symmetry operations).
   Atoms that end up with fractional coordinates within 0.00001 of existing one
   (input and previously generated ones) are deleted in the output file.
   format of the fractional coordinates file:
   first line : natoms alpha beta gamma a-axis b-axis c-axis (rest of line ignored)
   second line : title or comment line
   rest : atomname fract(x)  fract(y)  fract(z)              (rest of line ignored)

   atomname = elementname that may have a number concatenated to it
   i.g. C3 or H34b are valid : become C and H respectively
   fract(x) fract(y) fract(z) : floating point fractional coordinates

   to compile on SUN : cc matfract.c -o matfract -O -lm

   typical use :
     cat matrix.txt infile.fract | matfract >outfile.fract
   if you want to make it straight into an xyz file for xmol you can issue:
     cat matrix.txt infile.fract | matfract | fract2xyz >

   bugs : report to KANTERS@URVAX.URICH.EDU

   Rene Kanters


#define MINDIST 0.00001

typedef double vector[3];
typedef vector matrix[3];

typedef struct symmetry_operation {
  matrix m;
  vector t;
} SymmOp;

typedef struct atom {
  char name[4];
  vector xyz;
} Atom;

double vecxvec(v1,v2) vector v1,v2; { return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2];}

void symmatom(o,s,d) SymmOp *o;Atom *s,*d;
{ /* note that the atom pointers should NOT be the same !!!! */

void scanvec(v) vector v;  {scanf("%lf%lf%lf",&v[0],&v[1],&v[2]);}

int argc;
char *argv[];
{ long natoms,nsymm,i,j,k;
  Atom *atoms,*a;
  SymmOp *symmops,*s;
  char buf[256],line1[256],line2[256],*ch;

  /* read the symmetry operations */
  if(!(symmops=(SymmOp *)malloc(nsymm*sizeof(struct symmetry_operation)))) {
    fprintf(stderr,"Not enough space to allocate memory for symmetry operations/n");
  for (i=0,s=symmops;im[0]);scanf("%lf",&s->t[0]);
  scanf("%ld",&natoms); gets(line1);
  if(!(atoms=(Atom *)malloc((nsymm+1)*natoms*sizeof(struct atom)))) {
    fprintf(stderr,"Not enough space to allocate memory for the atoms/n");
  /* read the atoms themselves */  
      printf("%3s %15.6lg %15.6lg %15.6lg\n",a->name,a->xyz[0],a->xyz[1],a->xyz[2]);

Modified: Sun Apr 26 16:00:00 1992 GMT
Page accessed 6644 times since Sat Apr 17 18:24:43 1999 GMT