problems using Group, ZMatrix

Peter C. McCluskey
Wed, 11 Mar 1998 16:25:22 -0800

I've been playing around with mmtk1.1b1, trying to start a component
library that might be usefull for contructing complex artificial molecules.

 I first tried to read a Group file from a .py file like this:
from mmtk import *
block1 = Group('lego1')

but got the message
"Warning: Some atoms are missing in the output file because their
         positions are undefined."

 I found I could view the component by moving the lego1 file to Molecules
and reading it via "block1 = Molecule('lego1')". Why aren't group files
useable by themselves?

 The next problem I found was the need to put an "import ZMatrix"
statement in my molecule file in order to use the ZMatrix (is there a
better way to do this? I'm just starting to learn Python.):

name = 'Lego1'

C1 = Atom('C')
C2 = Atom('C')
C3 = Atom('C')
C4 = Atom('C')

bonds = [Bond(C1,C2),Bond(C2,C3),Bond(C3,C4),Bond(C4,C1)]

from ConfigIO import ZMatrix

configurations = {
    'default': ZMatrix([[C1],
			[C2,  C1,  1.5*Ang],
			[C3,  C2,  1.5*Ang,  C1,  90*deg],
			[C4,  C3,  1.5*Ang,  C2,  90*deg, C1, 0*deg]])

 When I got the system to understand some of ZMatrix instances, I found that
class ZMatrix was pretty buggy. The final angle in the example above had to
be greater than 90*deg to avoid an exception. The "for p in points:" loop
found no points for angles less than 90*deg, and for exactly 90*deg, it
died because it couldn't iterate through all the points on a circle.
 I've appended a patch which simplifies and fixes the ZMatrix class.

Peter McCluskey  |  | Has anyone used           | to comment on your web pages?

---	Fri Sep 26 08:39:00 1997
+++	Wed Mar 11 15:33:30 1998
@@ -5,7 +5,7 @@
 import ChemicalObjects, Collection, Database, Units, Universe, Utility
-from Geometry import Sphere, Cone, Plane, Line
+from Geometry import Sphere, Cone, Plane, Line, rotateDirection
 from Vector import Vector
 import PDB, VRML
 import copy, os
@@ -168,15 +168,10 @@
 	    distance = entry[2]
 	    angle = entry[4]
 	    dihedral = entry[6]
-	    sphere = Sphere(pos1, distance)
-	    cone = Cone(pos1, pos2-pos1, angle)
 	    plane123 = Plane(pos3, pos2, pos1)
-	    plane234 = plane123.rotate(Line(pos1, pos2), dihedral)
-	    points = sphere.intersectWith(cone).intersectWith(plane234)
-	    for p in points:
-		if (pos3-pos2).cross(p-pos3)*(plane234.normal) > 0:
-		    self.coordinates[entry[0]] = p
-		    break
+	    plane234 = plane123.rotate(Line(pos1, pos2 - pos1), dihedral)
+	    dirOfPoint = rotateDirection(pos1 - pos2, Line(pos1,plane234.normal), angle)
+	    self.coordinates[entry[0]] = pos1 + distance*dirOfPoint.normal()
     def applyTo(self, object):
 	if not len(self.coordinates):