~ubuntu-branches/ubuntu/trusty/gdis/trusty

« back to all changes in this revision

Viewing changes to gui_surface.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2009-04-06 17:12:18 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090406171218-uizoe126jrq09ytt
Tags: 0.90-1
* New upstream release 0.90.
* Acknowledge NMU (closes: #492994). Thanks to Neil Williams.

* makefile.debian: Upstream doesn't provide a Makefile to edit - so created
  our own.
* debian/compat: Added and set to be 5.
* debian/control: Added Homepage, Vcs* and DM-Upload-Allowed fields.
  (Maintainer): Set to the debichem team with approval by Noèl.
  (Uploaders): Added myself.
  (Build-Depends): Increased debhelper version to 5. Removed glutg3-dev.
  Added dpatch.
  (Standards-Version): Bumped to 3.8.1.
  (Description): Removed homepage. Fixed a typo.
* debian/copyright: Updated, completed and adjusted.
* debian/dirs: Dropped useless file.
* debian/docs: Renamed to debian/gdis.docs.
* debian/menu: Renamed to debian/gdis.menu.
  (section): Fixed accordingly to policy.
* debian/gdis.1: Just some formatting changes.
* debian/gdis.desktop: Added file (with small fixes) provided by Phill Bull
  (LP: #111353).
* debian/gdis.install: Added.
* debian/rules: Cleaned. Installation is now done by dh_install. Make sure,
  the CVS directory is not copied. Added dh_desktop call.
* debian/source.lintian-overrides: makefile.debian is created for Debian but
  lives outside debian/.
* debian/watch: Added.
* debian/README.build: Dropped.
* debian/README.source: Added to be compliant to the policy v3.8.
* debian/patches/Debian_make.dpatch: Added.
  - gdis.h (ELEM_FILE): Moved fix for gdis.elemts path (#399132) to this
    patch.
* debian/patches/00list: Added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "matrix.h"
41
41
#include "space.h"
42
42
#include "surface.h"
43
 
#include "shortcuts.h"
 
43
#include "gui_shorts.h"
44
44
#include "interface.h"
45
45
#include "dialog.h"
46
46
#include "opengl.h"
439
439
plane = plane_find(surfdata.surface.miller, model);
440
440
if (plane)
441
441
  {
442
 
ARR3SET(surf.surface.miller, plane->index);
443
 
generate_surface(model, &surf);
 
442
  ARR3SET(surf.surface.miller, plane->index);
 
443
  generate_surface(model, &surf);
444
444
 
445
 
shift->dipole = surf.gulp.sdipole;
446
 
shift->dipole_computed = TRUE;
 
445
  shift->dipole = surf.gulp.sdipole;
 
446
  shift->dipole_computed = TRUE;
447
447
 
448
448
  plane->shifts = g_slist_append(plane->shifts, shift);
449
449
 
452
452
    fn_graft_shift(&iter, shift, plane, model);
453
453
  else
454
454
    printf("FIXME NOW - need to create plane iter here.\n");
455
 
 
456
455
  }
457
456
else
458
457
  {
530
529
return(FALSE);
531
530
}
532
531
 
533
 
/********************************************************/
534
 
/* scan a plane's shift list for the best energy values */
535
 
/********************************************************/
536
 
#define DEBUG_UPDATE_PLANE_ENERGY 0
537
 
void update_plane_energy(struct plane_pak *plane, struct model_pak *model)
538
 
{
539
 
gint i;
540
 
GSList *list;
541
 
struct plane_pak *plane2;
542
 
struct shift_pak *sdata;
543
 
 
544
 
/* checks */
545
 
g_assert(model != NULL);
546
 
g_assert(plane != NULL);
547
 
 
548
 
#if DEBUG_UPDATE_PLANE_ENERGY
549
 
printf("(%d %d %d)\n", plane->index[0], plane->index[1], plane->index[2]);
550
 
#endif
551
 
 
552
 
/* set best values to those of the 1st shift */
553
 
list = plane->shifts;
554
 
if (list)
555
 
  {
556
 
  sdata = list->data;
557
 
 
558
 
/* init the plane's best values */
559
 
  for (i=0 ; i<2 ; i++)
560
 
    {
561
 
    plane->esurf[i] = sdata->esurf[i];
562
 
    plane->esurf_shift = sdata->shift;
563
 
    plane->eatt[i] = sdata->eatt[i];
564
 
    plane->eatt_shift = sdata->shift;
565
 
    plane->bbpa = sdata->bbpa;
566
 
    plane->bbpa_shift = sdata->shift;
567
 
    }
568
 
  }
569
 
else
570
 
  return;
571
 
 
572
 
/* search the shift list for better values */
573
 
while (list != NULL)
574
 
  {
575
 
  sdata = list->data;
576
 
  for (i=0 ; i<2 ; i++)
577
 
    {
578
 
/* surface energy */
579
 
    if (sdata->esurf[i] < plane->esurf[i])
580
 
      {
581
 
      plane->esurf[i] = sdata->esurf[i];
582
 
      plane->esurf_shift = sdata->shift;
583
 
      }
584
 
/* attachment energy */
585
 
    if (sdata->eatt[i] > plane->eatt[i])
586
 
      {
587
 
      plane->eatt[i] = sdata->eatt[i];
588
 
      plane->eatt_shift = sdata->shift;
589
 
      }
590
 
    }
591
 
/* broken bonds */
592
 
  if (sdata->bbpa < plane->bbpa)
593
 
    {
594
 
    plane->bbpa = sdata->bbpa;
595
 
    plane->bbpa_shift = sdata->shift;
596
 
    }
597
 
  list = g_slist_next(list);
598
 
  }
599
 
 
600
 
#if DEBUG_UPDATE_PLANE_ENERGY
601
 
printf(" %f\n", plane->bbpa);
602
 
#endif
603
 
 
604
 
/* update symmetry related planes */
605
 
if (plane->primary)
606
 
  {
607
 
  for (list=model->planes ; list ; list=g_slist_next(list))
608
 
    {
609
 
    plane2 = list->data;
610
 
 
611
 
    if (plane2->parent == plane)
612
 
      {
613
 
      plane2->esurf[0] = plane->esurf[0];
614
 
      plane2->esurf[1] = plane->esurf[1];
615
 
      plane2->eatt[0] = plane->eatt[0];
616
 
      plane2->eatt[1] = plane->eatt[1];
617
 
      }
618
 
    }
619
 
  }
620
 
}
621
 
 
622
 
/*************************/
623
 
/* construct the surface */
624
 
/*************************/
625
 
#define MAKE_SURFACE_DEBUG 0
626
 
gpointer make_surface(struct model_pak *data,
627
 
                      struct plane_pak *pdata,
628
 
                      struct shift_pak *sdata)
629
 
{
630
 
gint bmode, r1size;
631
 
gdouble sbe;
632
 
GSList *list;
633
 
struct model_pak *surf;
634
 
struct core_pak *core;
635
 
 
636
 
/* checks */
637
 
g_assert(data != NULL);
638
 
if (data->periodic != 3)
639
 
  {
640
 
  gui_text_show(ERROR, "base model is not 3D periodic.\n");
641
 
  return(NULL);
642
 
  }
643
 
if (!pdata->index[0] && !pdata->index[1] && !pdata->index[2])
644
 
  {
645
 
  gui_text_show(ERROR, "Don't be silly.\n");
646
 
  return(NULL);
647
 
  }
648
 
 
649
 
#if MAKE_SURFACE_DEBUG
650
 
printf("Generating surface for model: %d\n", source);
651
 
#endif
652
 
 
653
 
/* ignore mols when building surface? */
654
 
bmode = data->build_molecules;
655
 
if (data->surface.ignore_bonding)
656
 
  {
657
 
  data->build_molecules = FALSE;
658
 
  connect_bonds(data);
659
 
  connect_molecules(data);
660
 
  }
661
 
 
662
 
/* allocate & init for surface data */
663
 
surf = model_new();
664
 
 
665
 
/* NEW - label it as MARVIN, so it's build mode follows the */
666
 
/* source model, rather than the GULP setup data - see model_prep() */
667
 
surf->id = MARVIN;
668
 
 
669
 
/* transfer appropriate GULP setup data to new model */
670
 
gulp_data_copy(data, surf);
671
 
 
672
 
surf->gulp.run = E_SINGLE;
673
 
surf->gulp.method = CONV;
674
 
 
675
 
/* transfer surface data to new model */
676
 
/* NB: memcpy would produce undesired effects if pointers were */
677
 
/* later added to the surface struct */
678
 
ARR3SET(surf->surface.miller, pdata->index);
679
 
surf->surface.shift = sdata->shift;
680
 
surf->surface.region[0] = sdata->region[0];
681
 
surf->surface.region[1] = sdata->region[1];
682
 
/* setup for region display */
683
 
if (surf->surface.region[0])
684
 
  surf->region_empty[REGION1A] = FALSE;
685
 
if (surf->surface.region[1])
686
 
  surf->region_empty[REGION2A] = FALSE;
687
 
 
688
 
surf->build_molecules = bmode;
689
 
 
690
 
#if MAKE_SURFACE_DEBUG
691
 
printf("Miller (%d,%d,%d)\n",surf->surface.miller[0]
692
 
                            ,surf->surface.miller[1]
693
 
                            ,surf->surface.miller[2]);
694
 
printf("Shift %f\n",surf->surface.shift);
695
 
printf("Region sizes (%d,%d)\n",surf->surface.region[0]
696
 
                               ,surf->surface.region[1]);
697
 
#endif
698
 
 
699
 
/* TODO - valid shift/region size loop??? */
700
 
generate_surface(data, surf);
701
 
gulp_files_init(surf);
702
 
 
703
 
/*
704
 
coords_init(INIT_COORDS, surf);
705
 
*/
706
 
 
707
 
/* restore connectivity in source model */
708
 
if (data->surface.ignore_bonding)
709
 
  {
710
 
  data->build_molecules = bmode;
711
 
  connect_bonds(data);
712
 
  connect_molecules(data);
713
 
  }
714
 
 
715
 
/* calculate the bulk energy needed for GULP surface calcs */
716
 
sbe = data->gulp.energy;
717
 
if (fabs(sbe) < FRACTION_TOLERANCE)
718
 
  {
719
 
  gui_text_show(WARNING, "Suspicious total energy. Has it been properly calculated?\n");
720
 
  }
721
 
 
722
 
/* calc the number of region 1 atoms */
723
 
r1size=0;
724
 
for (list=surf->cores ; list ; list=g_slist_next(list))
725
 
  {
726
 
  core = list->data;
727
 
  if (core->region == REGION1A)
728
 
    r1size++;
729
 
  }
730
 
 
731
 
sbe /= data->num_atoms;    /* E per atom in unit cell */
732
 
sbe *= r1size;             /* E scaled to region 1 size */
733
 
surf->gulp.sbulkenergy = sbe;
734
 
 
735
 
/* employ src file? */
736
 
tree_model_add(surf);
737
 
tree_select_model(surf);
738
 
 
739
 
return(surf);
740
 
}
741
 
 
742
532
/*************/
743
533
/* rank cuts */
744
534
/*************/
834
624
if (!status)
835
625
  {
836
626
  tree_model_add(data);
837
 
/*
838
 
  tree_select(data->number);
839
 
*/
840
627
  }
841
628
 
842
629
g_free(filename);
2104
1891
  return;
2105
1892
 
2106
1893
/* process filename to force .gmf extension */
2107
 
a = strdup_basename(name); 
 
1894
a = parse_strip(name); 
2108
1895
b = g_strconcat(a, ".gmf", NULL);
2109
1896
 
2110
1897
filename = g_build_filename(sysenv.cwd, b, NULL);