Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
void exec_analysis_task(GtkWidget *w, gpointer dialog)
{
const gchar *type;
gpointer gui_menu_calc;
struct analysis_pak *analysis;
struct model_pak *model;

/* duplicate the analysis structure at time of request */
g_assert(dialog != NULL);
model = dialog_model(dialog);
g_assert(model != NULL);
analysis = analysis_dup(model->analysis);

/* get the task type requested from the dialog */
gui_menu_calc = dialog_child_get(dialog, "gui_menu_calc");
type = gui_pulldown_text(gui_menu_calc);

if (g_ascii_strncasecmp(type, "RDF", 3) == 0)
  {
  analysis->rdf_normalize = TRUE;
  task_new("RDF", &analysis_plot_rdf, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "Pair", 4) == 0)
  {
  analysis->rdf_normalize = FALSE;
  task_new("Pair", &analysis_plot_rdf, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "VACF", 4) == 0)
  {
  task_new("VACF", &analysis_plot_vacf, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "Temp", 4) == 0)
  {
  task_new("Temp", &analysis_plot_temp, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "Pot", 3) == 0)
  {
  task_new("Energy", &analysis_plot_pe, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "Kin", 3) == 0)
  {
  task_new("Energy", &analysis_plot_ke, analysis, &analysis_show, model, model);
  return;
  }
if (g_ascii_strncasecmp(type, "Meas", 4) == 0)
  {
  task_new("Measure", &analysis_plot_meas, analysis, &analysis_show, model, model);
  return;
  }
}
Exemplo n.º 3
0
void gui_host_connect(GtkWidget *w, gpointer dialog)
{
gchar *text;
gpointer host;
GtkEntry *user_entry, *host_entry;

user_entry = dialog_child_get(dialog, "user");
host_entry = dialog_child_get(dialog, "host");

text = g_strdup_printf("%s@%s", gtk_entry_get_text(user_entry), gtk_entry_get_text(host_entry));
host = host_new(text);
g_free(text);

if (host_connect(host))
  printf("host_connect(): success!\n");
else
  printf("host_connect(): failed!\n");

gui_host_update(host, dialog);
}
Exemplo n.º 4
0
void gui_siesta_mode_prev(GtkWidget *w, gpointer dialog)
{
    gdouble m;
    gpointer slider;

    slider = dialog_child_get(dialog, "phonon_slider");

    m = gtk_range_get_value(GTK_RANGE(slider));
    m--;
    gtk_range_set_value(GTK_RANGE(slider), m);
}
Exemplo n.º 5
0
void siesta_phonon_movie(GtkWidget *w, gpointer dialog)
{
    gpointer entry;
    struct model_pak *model;

    model = dialog_model(dialog);
    g_assert(model != NULL);

    entry = dialog_child_get(dialog, "phonon_movie_name");
    g_assert(entry != NULL);
    /* FIXME - GULP phonon movie uses the same variable */
    g_free(model->phonon_movie_name);
    model->phonon_movie_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));

    entry = dialog_child_get(dialog, "phonon_movie_type");
    g_assert(entry != NULL);
    g_free(model->phonon_movie_type);
    model->phonon_movie_type = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));

    model->phonon_movie = TRUE;
    siesta_phonon_start(NULL, dialog);
}
Exemplo n.º 6
0
void gui_siesta_frequency_set(gpointer dialog)
{
    gint m;
    gchar *text;
    gdouble f;
    gpointer entry;
    struct model_pak *model;

    model = dialog_model(dialog);
    g_assert(model != NULL);
    entry = dialog_child_get(dialog, "phonon_entry");
    g_assert(entry != NULL);

    m = model->siesta.current_animation;

    g_assert(m >= 0);
    g_assert(m < model->siesta.num_animations);

    f = make_eigvec_freq(mesch_ve_get(model->siesta.eigen_values, model->siesta.sorted_eig_values[m]));

    text = g_strdup_printf("%f", f);
    gtk_entry_set_text(GTK_ENTRY(entry), text);
    g_free(text);
}
Exemplo n.º 7
0
gint siesta_phonon_timer(gpointer dialog)
{
    static gint count=0;
    gint atom, mode;
    gchar *text, *name;
    gdouble f, x1[3];
    gpointer spin;
    GSList *list;
    struct core_pak *core;
    struct model_pak *model;

    /* checks */
    if (!dialog_valid(dialog))
        return(FALSE);

    model = dialog_model(dialog);
    g_assert(model != NULL);

    /* stop animation? */
    if (!model->pulse_direction)
    {
        siesta_phonon_cleanup(model);
        coords_compute(model);
        redraw_canvas(SINGLE);
        return(FALSE);
    }

    /* setup animation resolution */
    spin = dialog_child_get(dialog, "phonon_resolution");
    model->pulse_max = SPIN_FVAL(spin);

    /* setup scaling for this step */
    model->pulse_count += model->pulse_direction;
    if (model->pulse_count <= -model->pulse_max)
    {
        model->pulse_count = -model->pulse_max;
        model->pulse_direction = 1;
    }
    if (model->pulse_count >= model->pulse_max)
    {
        model->pulse_count = model->pulse_max;
        model->pulse_direction = -1;
    }

    spin = dialog_child_get(dialog, "phonon_scaling");
    f = SPIN_FVAL(spin);
    f *= (gdouble) model->pulse_count;
    f /= model->pulse_max;

    atom = 0;

    mode = model->siesta.sorted_eig_values[model->siesta.current_animation];

    /* get eigenvectors from all atoms */
    for (list=model->cores ; list; list=g_slist_next(list))
    {
        core = list->data;
        ARR3SET(x1, core->x);

//get x,y,z for given freq.
        core->offset[0] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom, mode);
        core->offset[1] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+1, mode);
        core->offset[2] = mesch_me_get(model->siesta.eigen_xyz_atom_mat, 3*atom+2, mode);
        atom++;

        /* pulse offset scaling */
        VEC3MUL(core->offset, f);
        vecmat(model->ilatmat, core->offset);
    }

    /* recalc coords */
    coords_compute(model);

    /* CURRENT - output to povray for movie rendering */
    if (model->phonon_movie)
    {
        if (!model->pulse_count && model->pulse_direction==1)
        {
            model->phonon_movie = FALSE;
            count=0;

            text = g_strdup_printf("%s -delay 20 %s_*.tga %s.%s",
                                   sysenv.convert_path, model->phonon_movie_name,
                                   model->phonon_movie_name, model->phonon_movie_type);

            system(text);
            g_free(text);

            return(FALSE);
        }
        else
        {
            text = g_strdup_printf("%s_%06d.pov", model->phonon_movie_name, count++);
            name = g_build_filename(sysenv.cwd, text, NULL);
            write_povray(name, model);

            povray_exec(sysenv.cwd, name);

            g_free(text);
            g_free(name);
        }

    }
    else
        redraw_canvas(SINGLE);

    return(TRUE);
}