[MMTK] no subject

dpy99 dpy99 at mails.tsinghua.edu.cn
Fri Jan 20 09:44:25 CET 2006


Hello all:
I find something wrong in universe.view(), which might be general. If first adding
a object by performing Lattice method, say a system of molecules, if you then add
another object with different type, for example an Atom object. Then
universe.view() won¡¯t work.
More detail as follows:
Problem version:
from MMTK import *
from MMTK.Collection import *
from Scientific.Geometry.Objects3D import SCLattice
from MMTK.Visualization import view
from Scientific.Geometry import Vector
# Define parameters of the lattice
edge_length = 0.8*Units.nm
lattice_size = (5, 5, 5)
# Construct the universe
universe = OrthorhombicPeriodicUniverse((edge_length*lattice_size[0],
                                         edge_length*lattice_size[1],
                                         edge_length*lattice_size[2]))
for point in SCLattice(edge_length, lattice_size):
       universe.addObject(Molecule('water',position= point))
      
universe.view()
universe.addObject(Atom('O',position=point))
print universe
universe.view()
Error is shown:
OrthorhombicPeriodicUniverse  containing 126 objects.
Traceback (most recent call last):
  File
"D:\MOLECU~1\PYTHON~1.3\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py
", line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\Molecular dynamics\temp\Anewone.py", line 31, in ?
    
  File "D:\MOLECU~1\PYTHON~1.3\Lib\site-packages\MMTK\Collection.py", line 365, in
view
    configuration)
  File "D:\MOLECU~1\PYTHON~1.3\Lib\site-packages\MMTK\Universe.py", line 753, in
contiguousObjectConfiguration
    offset = self.contiguousObjectOffset(objects, conf)
  File "D:\MOLECU~1\PYTHON~1.3\Lib\site-packages\MMTK\Universe.py", line 1099, in
contiguousObjectOffset
    pairs.append((pairs[-1][1], mpairs[0][0]))
IndexError: list index out of range

But if the script changed as :
from MMTK import *
from MMTK.Collection import *
from Scientific.Geometry.Objects3D import SCLattice
from MMTK.Visualization import view
from Scientific.Geometry import Vector
# Define parameters of the lattice
edge_length = 0.8*Units.nm
lattice_size = (5, 5, 5)

# Construct the universe
universe = OrthorhombicPeriodicUniverse((edge_length*lattice_size[0],
                                         edge_length*lattice_size[1],
                                         edge_length*lattice_size[2]))
maxnumber=5
numberof_molecule=1
for point in SCLattice(edge_length, lattice_size):
       universe.addObject(Molecule('water',position= point))
       numberof_molecule=numberof_molecule+1
       print 'a molecule in the universe'
universe.view()
universe.addObject(Molecule('water',position=point))
print universe
universe.view()

everything is ok ?

could anybody figure out the problem and help me ?
Thank you .
PingYe DENG





More information about the mmtk mailing list