-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
52 lines (36 loc) · 1.52 KB
/
test.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import topologyer
from topologyer import Vector3, Quaternion
import math
# create an empty system
s = lammpser.System('asd')
# set the size of the simulation box
s.box = Vector3(2,2,2)
# declare atomic types
s.AddAtomType(name='C',mass=12, charge=0, epsilon=1, sigma=1)
s.AddAtomType(name='Cr',mass=12, charge=0, epsilon=1, sigma=1)
# declare bond types - C-Cr is just a name
s.bondTypes['C-Cr'] = [330, 1.2] # list of parameter needed by LAMMPS, in the same order
# declare angle/dihedral/improper types
# ...
# declare a molecular type
cmol = s.AddMoleculeType('myDimer')
# put atoms in the molecule - give unique ID, atom type ID, and position in the molecule
cmol.AddAtom('C1', 'C', Vector3(0,0,0))
s.moleculeTypes['myDimer'].AddAtom('C2', 'Cr', Vector3(1,0,0))
# create a bond - specify bond type name, atom1 ID and atom2 ID
cmol.bonds.append( ['C-Cr','C1','C2'] )
# create a molecule in the system, using a declared type - give unique ID and a type ID
s.MakeMolecule('molecule1', 'myDimer')
# a copy of myDimer named molecule1 is now added to the topology of the system
# get a reference to the molecule by ID
mol1 = s.topology['molecule1']
# create another molecule
mol2 = s.MakeMolecule('molecule2', 'myDimer')
# set the position of the molecule
mol2.position = Vector3(3,0,0)
# set the orientation of the molecule, using angle-axis notation
mol2.rotation = Quaternion.FromAngleAxis(math.pi/2, Vector3(0,1,0))
# make a random rotation
mol2.rotation = Quaternion.Random()
# write the lammps topology
s.ExportLAMMPS('test.topo')