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

« back to all changes in this revision

Viewing changes to measure.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:
320
320
  core2 = mp->core[n];
321
321
  ARR3SET(dx, core1->x);
322
322
  ARR3SUB(dx, core2->x);
323
 
  fractional_minsq(dx, model->periodic);
 
323
  fractional_min(dx, model->periodic);
324
324
  vecmat(model->latmat, dx);
325
325
  ARR3SUB(x, dx);
326
326
  }
507
507
return(R2D*via(a,b,3)); 
508
508
}
509
509
 
 
510
/**********************************/
 
511
/* dihedral calculation primitive */
 
512
/**********************************/
 
513
gdouble measure_dihedral(gdouble *x1, gdouble *x2, gdouble *x3, gdouble *x4)
 
514
{
 
515
gdouble len, sign;
 
516
gdouble a[3], b[3], c[3], n[3];
 
517
 
 
518
/* compute end atom vectors (from 1-2 axis) */
 
519
ARR3SET(a, x1);
 
520
ARR3SUB(a, x2);
 
521
ARR3SET(b, x4);
 
522
ARR3SUB(b, x3);
 
523
 
 
524
/* compute normal to the plane in which the dihedral is to be calc'd */
 
525
ARR3SET(n, x2);
 
526
ARR3SUB(n, x3);
 
527
normalize(n, 3);
 
528
 
 
529
/* CURRENT - compute the direction sense (sign) */
 
530
crossprod(c, a, b);
 
531
if (via(c,n,3) < 0.5*PI)
 
532
  sign = -1.0;
 
533
else
 
534
  sign = 1.0;
 
535
 
 
536
/* n[0..2] is the normal of the plane */
 
537
/* project 1-0 onto the normal (ie dist to plane) */
 
538
len = a[0]*n[0] + a[1]*n[1] + a[2]*n[2];
 
539
/* subtract vector to plane from 1-0 to get projection on plane */
 
540
a[0] -= len*n[0];
 
541
a[1] -= len*n[1];
 
542
a[2] -= len*n[2];
 
543
/* project 2-3 onto the normal */
 
544
len = b[0]*n[0] + b[1]*n[1] + b[2]*n[2];
 
545
/* subtract vector to plane from 2-3 to get projection on plane */
 
546
b[0] -= len*n[0];
 
547
b[1] -= len*n[1];
 
548
b[2] -= len*n[2];
 
549
/* compute angle between projected vectors */
 
550
return(sign * R2D*via(a,b,3)); 
 
551
}
 
552
 
510
553
/*********************************************/
511
554
/* recompute a measurement value for a model */
512
555
/*********************************************/
727
770
 
728
771
/* test if distance satisfies the cutoffs */
729
772
ARR3SUB(x1, x2);
730
 
fractional_minsq(x1, model->periodic);
 
773
fractional_min(x1, model->periodic);
731
774
vecmat(model->latmat, x1);
732
775
rsq = VEC3MAGSQ(x1);
733
776
 
1280
1323
  }
1281
1324
return(m);
1282
1325
}
 
1326
 
 
1327
/************************/
 
1328
/* match pairs of atoms */
 
1329
/************************/
 
1330
#define DEBUG_PAIR_MATCH 0
 
1331
gint pair_match(const gchar *label1, const gchar *label2,
 
1332
                struct core_pak *core1, struct core_pak *core2)
 
1333
{
 
1334
gint a, b, i, j, mask;
 
1335
 
 
1336
#if DEBUG_PAIR_MATCH
 
1337
printf("[%s,%s] : [%s,%s]\n", label1, label2, core1->label, core2->label);
 
1338
#endif
 
1339
 
 
1340
/* if a or b = 0 => any i or j is accepted */
 
1341
/* otherwise it must match either i or j */
 
1342
/* if a and b are non zero, both i & j must match both a & b */
 
1343
a = elem_symbol_test(label1);
 
1344
b = elem_symbol_test(label2);
 
1345
i = core1->atom_code;
 
1346
j = core2->atom_code;
 
1347
 
 
1348
/* fill out the mask */
 
1349
mask = 0;
 
1350
if (i == a)
 
1351
  {
 
1352
/* if input label doesn't match the element symbol length - it means the */
 
1353
/* user has put in something like H1 - compare this with the atom label */
 
1354
  if (g_ascii_strcasecmp(label1, elements[i].symbol) != 0)
 
1355
    {
 
1356
    if (g_ascii_strcasecmp(core1->atom_label, label1) == 0)
 
1357
      mask |= 1;
 
1358
    }
 
1359
  else
 
1360
    mask |= 1; 
 
1361
  }
 
1362
 
 
1363
if (j == a)
 
1364
  {
 
1365
  if (g_ascii_strcasecmp(label1, elements[j].symbol) != 0)
 
1366
    {
 
1367
    if (g_ascii_strcasecmp(core2->atom_label, label1) == 0)
 
1368
      mask |= 2;
 
1369
    }
 
1370
  else
 
1371
    mask |= 2; 
 
1372
  }
 
1373
 
 
1374
if (i == b)
 
1375
  {
 
1376
  if (g_ascii_strcasecmp(label2, elements[i].symbol) != 0)
 
1377
    {
 
1378
    if (g_ascii_strcasecmp(core1->atom_label, label2) == 0)
 
1379
      mask |= 4;
 
1380
    }
 
1381
  else
 
1382
    mask |= 4; 
 
1383
  }
 
1384
 
 
1385
if (j == b)
 
1386
  {
 
1387
  if (g_ascii_strcasecmp(label2, elements[j].symbol) != 0)
 
1388
    {
 
1389
    if (g_ascii_strcasecmp(core2->atom_label, label2) == 0)
 
1390
      mask |= 8;
 
1391
    }
 
1392
  else
 
1393
    mask |= 8; 
 
1394
  }
 
1395
 
 
1396
#if DEBUG_PAIR_MATCH
 
1397
printf("mask = %d\n", mask);
 
1398
#endif
 
1399
 
 
1400
/* if both types must match - only two possibilities (a,b) or (b,a) */
 
1401
/* but we can get further matches (than the required 2) when labels are compared */
 
1402
if (a && b)
 
1403
  {
 
1404
  switch(mask)
 
1405
    {
 
1406
/* single valid pair match */
 
1407
    case 6:
 
1408
    case 9:
 
1409
/* valid pair match plus one extra */
 
1410
    case 7:
 
1411
    case 11:
 
1412
    case 13:
 
1413
    case 14:
 
1414
/* pair match in all possible combinations */
 
1415
    case 15:
 
1416
      break;
 
1417
/* bad match - exit */
 
1418
    default:
 
1419
      return(0);
 
1420
    }
 
1421
  }
 
1422
 
 
1423
/* if only one type to match - any match at all will do */
 
1424
if (a || b)
 
1425
  if (!mask)
 
1426
    return(0);
 
1427
 
 
1428
#if DEBUG_PAIR_MATCH
 
1429
printf("accepted [%d][%d] as a match.\n",i,j);
 
1430
#endif
 
1431
 
 
1432
return(1);
 
1433
}