[MMTK] MMTK nc trajectory file and simulation box

Matti Ropo matti.ropo at tut.fi
Tue Mar 10 12:22:58 UTC 2015


On 09.03.2015 10:14, Konrad Hinsen wrote:
> The easiest way to answer such questions is by asking MMTK itself:

Thank you. I should have in fact thought the last solution by myself.

Cheers,
Matti

> ----------------------------------------------------------------------
> 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


-- 
---------------------------------------------------------
         Department of Physics
   Tampere University of Technology, Finland 
               and
Centre of Excellence in Computational Nanoscience
       Aalto University, Finland
---------------------------------------------------------




More information about the mmtk mailing list