File: lattice.py

package info (click to toggle)
mmtk 2.7.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,788 kB
  • ctags: 6,600
  • sloc: python: 18,050; ansic: 12,400; makefile: 129; csh: 3
file content (27 lines) | stat: -rw-r--r-- 896 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Example: water molecules on a lattice
#
# This example creates a system of water molecules whose centers
# of mass are positioned simple cubic lattice consisting of
# 3x4x5 cells, i.e. there are 60 water molecules in total.
# The molecules are put into a suitably sized periodic universe.
#

from MMTK import *
from Scientific.Geometry.Objects3D import SCLattice
from MMTK.Visualization import view

# Define parameters of the lattice
edge_length = 0.5*Units.nm
lattice_size = (3, 4, 5)

# Construct the universe
universe = OrthorhombicPeriodicUniverse((edge_length*lattice_size[0],
                                         edge_length*lattice_size[1],
                                         edge_length*lattice_size[2]))

# Add the water molecules
for point in SCLattice(edge_length, lattice_size):
    universe.addObject(Molecule('water', position = point))

# Visualization
view(universe)