[MMTK] MMTK nc trajectory file and simulation box

Konrad Hinsen research at khinsen.fastmail.net
Mon Mar 9 08:14:20 UTC 2015


Hi Matti,

 > I have ParallelepipedicPeriodicUniverse boundary conditions and when I
 > use ncdump I get
 > "3.0639, 1.53195, 0, 0, 2.653415, 0, 0, 0, 2.261158," (repeated 10 times
 > as there is 10 frames)
 > 
 > Is the first 3 numbers the component of the first lattice vector and
 > second 3 numbers component of second lattice vector and last 3 component
 > of last lattice vector?
 > 
 > As I my lattice vectors should be
 > A = [3.0639,0,0]
 > B = [1.53195,2.653415,0]
 > C = [0,0,2.261158]

The easiest way to answer such questions is by asking MMTK itself:

----------------------------------------------------------------------
from MMTK import *
from MMTK.Trajectory import Trajectory, SnapshotGenerator, TrajectoryOutput

A = Vector(3.0639,0,0)
B = Vector(1.53195,2.653415,0)
C = Vector(0,0,2.261158)

universe = ParallelepipedicPeriodicUniverse((A, B, C))

universe.addObject(Molecule('water'))

trajectory = Trajectory(universe, "test.nc", "w")
snapshot = SnapshotGenerator(universe,
                             actions = [TrajectoryOutput(trajectory,
                                                         ["all"], 0, None, 1)])
snapshot()
trajectory.close()
----------------------------------------------------------------------

Then in a shell:

----------------------------------------------------------------------
$ ncdump -v box_size test.nc
netcdf test {
dimensions:
	step_number = UNLIMITED ; // (1 currently)
	atom_number = 3 ;
	xyz = 3 ;
	box_size_length = 9 ;
	description_length = 144 ;
variables:
	char description(description_length) ;
	int step(step_number) ;
	float configuration(step_number, atom_number, xyz) ;
		configuration:units = "nanometer" ;
	float box_size(step_number, box_size_length) ;
		box_size:units = "nanometer" ;

// global attributes:
		:Conventions = "MMTK/Trajectory" ;
		:trajectory_type = 0 ;
		:history = "Created Mon Mar  9 09:06:21 2015" ;
data:

 box_size =
  3.0639, 1.53195, 0, 0, 2.653415, 0, 0, 0, 2.261158 ;
}
----------------------------------------------------------------------

The good news for you: your conversion went right!

The other way to figure that out is to go through the code and
verify that box_size is an array storing the lattice vectors
in its columns, but that is much more difficult to do.

If you want another level of verification, try this (in Python):

----------------------------------------------------------------------
print Trajectory(None, 'test.nc').universe.basisVectors()

[Vector(3.063900,0.000000,0.000000), Vector(1.531950,2.653415,0.000000), Vector(0.000000,0.000000,2.261158)]
----------------------------------------------------------------------

Konrad
-- 
---------------------------------------------------------------------
Konrad Hinsen
Centre de Biophysique Moléculaire, CNRS Orléans
Synchrotron Soleil - Division Expériences
Saint Aubin - BP 48
91192 Gif sur Yvette Cedex, France
Tel. +33-1 69 35 97 15
E-Mail: research AT khinsen DOT fastmail DOT net
http://dirac.cnrs-orleans.fr/~hinsen/
ORCID: http://orcid.org/0000-0003-0330-9428
Twitter: @khinsen
---------------------------------------------------------------------



More information about the mmtk mailing list