示例#1
0
文件: phonon.c 项目: Bhattiasif/gdis
void show_phonon_components(struct model_pak *model)
{
gdouble f, lc, lf, xc[3], xf[3];
gpointer ptr;
GSList *list;
struct core_pak *core;

/* checks */
if (!model)
  return;

/* get required mode to analyse */
ptr = g_slist_nth_data(model->phonons, model->current_phonon-1);
if (!ptr)
  return;
f = str_to_float(ptr);

printf("--------------------------------------------------------------------------\n");
printf("Mode: %d, Frequency = %f\n", model->current_phonon, f);
printf("--------------------------------------------------------------------------\n");
printf("  atom  |   len   |     x        y        z    |      a        b        c\n");
printf("--------------------------------------------------------------------------\n");

for (list=model->selection ; list; list=g_slist_next(list))
  {
  core = (struct core_pak *) list->data;

/* get eigen-vector components */
  xc[0] = *((gdouble *) g_slist_nth_data(core->vibx_list, model->current_phonon-1));
  xc[1] = *((gdouble *) g_slist_nth_data(core->viby_list, model->current_phonon-1));
  xc[2] = *((gdouble *) g_slist_nth_data(core->vibz_list, model->current_phonon-1));
  ARR3SET(xf, xc);
  vecmat(model->ilatmat, xf);

  lc = VEC3MAG(xc);
  lf = VEC3MAG(xf);

  VEC3MUL(xc, 1.0/lc);
  VEC3MUL(xf, 1.0/lf);

  printf("%6s  | %7.4f | %7.2f  %7.2f  %7.2f  |  %7.2f  %7.2f  %7.2f\n",
          core->atom_label, lc, xc[0], xc[1], xc[2], xf[0], xf[1], xf[2]);

  }
}
示例#2
0
GSList *get_facet_equiv(struct model_pak *data, gint *f1)
{
gint i, flag, *f2, index[3];
gdouble d1, d2, vec[3];
GSList *flist=NULL, *list=NULL;

g_return_val_if_fail(data != NULL, NULL);
g_return_val_if_fail(f1 != NULL, NULL);

/* NEW */
ARR3SET(vec, f1);
vecmat(data->rlatmat, vec);
d1 = 1.0/VEC3MAG(vec);

#if DEBUG_GET_FACET_EQUIV
printf("search for equiv faces to (%d %d %d) (Dhkl = %f)\n",
        f1[0], f1[1], f1[2], d1);
#endif

/* add the supplied face to the list (needed to eliminate repetitions) */
f2 = g_malloc(3*sizeof(gint));
ARR3SET(f2, f1);
flist = g_slist_prepend(flist, (gpointer) f2);

if (data->sginfo.spacenum)
  {
/* skip 1st (trivial) op */
  for (i=1 ; i<data->sginfo.order ; i++)
    {
/* generate new symmetry related hkl */
    ARR3SET(vec, f1);
    vecmat(*(data->sginfo.matrix+i), vec);
    ARR3SET(index, vec);

/* NEW - weed out symop generated faces with different Dhkl values */
/* FIXME - why does this happen??? */
vecmat(data->rlatmat, vec);
d2 = 1.0/VEC3MAG(vec);

#if DEBUG_GET_FACET_EQUIV
printf("candidate: (%3d %3d %3d) : (Dhkl=%7.4f)", index[0], index[1], index[2], d2);
#endif

if (fabs(d2-d1) > FRACTION_TOLERANCE)
  {
#if DEBUG_GET_FACET_EQUIV
printf("[NO : dhkl mis-match]\n");
#endif
  continue;
  }

/* add new hkl if not found in the list */
    flag = 0;
    list = flist;
    while (list != NULL)
      {
      f2 = (gint *) list->data;
      if (index[0] == f2[0] && index[1] == f2[1] && index[2] == f2[2])
        {
        flag++;
        break;
        }
      list = g_slist_next(list);
      }
    if (!flag)
      {
      f2 = g_malloc(3*sizeof(gint));
      ARR3SET(f2, index);
      flist = g_slist_prepend(flist, f2);

#if DEBUG_GET_FACET_EQUIV
printf("[YES : symop %d]\n", i);
#endif
      }
#if DEBUG_GET_FACET_EQUIV
    else
      {
printf("[NO : already exists]\n");
      }
#endif
    }
  }
else
  printf("No space group information.\n");

flist = g_slist_reverse(flist);
return(flist);
}