void gui_siesta_mode_show(GtkWidget *w, gpointer dialog) { gint i, atom, state; gdouble scale, x1[3], x2[3], colour[3]; gpointer button, spin; GSList *list; struct core_pak *core; struct spatial_pak *spatial; struct model_pak *model; g_assert(dialog != NULL); model = dialog_model(dialog); g_assert(model != NULL); button = dialog_child_get(dialog, "phonon_toggle"); g_assert(button != NULL); spatial_destroy_by_label("siesta_phonons", model); state = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); if (!state) { redraw_canvas(SINGLE); return; } spin = dialog_child_get(dialog, "phonon_scaling"); scale = SPIN_FVAL(spin); /* create & init the spatial object */ spatial = spatial_new("siesta_phonons", SPATIAL_VECTOR, 2, TRUE, model); atom = 0; /* get eigenvectors from all atoms */ for (list=model->cores ; list; list=g_slist_next(list)) { core = list->data; ARR3SET(x1, core->x); /* get current eigenvector */ i = model->siesta.sorted_eig_values[model->siesta.current_animation]; x2[0] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom, i); x2[1] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+1, i); x2[2] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+2, i); atom++; /* compute coords */ VEC3MUL(x2, scale); vecmat(model->ilatmat, x2); ARR3ADD(x2, x1); /* add to spatial */ spatial_vertex_add(x2, colour, spatial); spatial_vertex_add(x1, colour, spatial); } /* drawing update */ coords_compute(model); redraw_canvas(SINGLE); }
void xml_parse_spatial(const gchar **names, const gchar **values) { gint i, periodic=-1; g_assert(xml_model != NULL); i=0; while (*(names+i)) { if (g_ascii_strncasecmp(*(names+i), "periodic", 8) == 0) periodic = str_to_float(*(values+i)); /* TODO - more details */ i++; } xml_spatial = spatial_new(NULL, SPATIAL_GENERIC, 0, periodic, xml_model); }
// not really an animate function as such... void gui_animate_phonon_vectors(struct model_pak *model) { gdouble *v, x1[3], x2[3], colour[3]; gpointer spatial, ptr; GSList *list, *xlist, *ylist, *zlist; struct core_pak *core, *prim; if (!model) return; /* create & init the spatial object */ spatial_destroy_by_label("phonons", model); spatial = spatial_new("phonons", SPATIAL_VECTOR, 2, TRUE, model); /* get eigenvectors from all atoms */ for (list=model->cores ; list; list=g_slist_next(list)) { core = list->data; ARR3SET(x1, core->x); /* get eigenvector list */ if (core->primary) { xlist = core->vibx_list; ylist = core->viby_list; zlist = core->vibz_list; } else { prim = core->primary_core; xlist = prim->vibx_list; ylist = prim->viby_list; zlist = prim->vibz_list; } if (!xlist || !ylist || !zlist) { printf("Missing phonon eigenvectors.\n"); return; } /* vibrational eigenvector */ /* NB: current_phonon starts from 1 */ ptr = g_slist_nth_data(xlist, model->current_phonon-1); if (ptr) x2[0] = *((gdouble *) ptr); ptr = g_slist_nth_data(ylist, model->current_phonon-1); if (ptr) x2[1] = *((gdouble *) ptr); v = g_slist_nth_data(zlist, model->current_phonon-1); if (ptr) x2[2] = *v; /* pulse offset scaling */ VEC3MUL(x2, sysenv.render.phonon_scaling); vecmat(model->ilatmat, x2); /* TODO - unify with siesta */ /* i = model->siesta.sorted_eig_values[model->siesta.current_animation]; x2[0] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom, i); x2[1] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+1, i); x2[2] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+2, i); atom++; */ /* compute coords */ ARR3ADD(x2, x1); /* add to spatial */ spatial_vertex_add(x2, colour, spatial); spatial_vertex_add(x1, colour, spatial); } coords_compute(model); gui_refresh(GUI_CANVAS); }