Skip to content

Instantly share code, notes, and snippets.

@uppittu11
Last active February 5, 2020 19:01
Show Gist options
  • Save uppittu11/02396be93269675a6b72794ecf628e52 to your computer and use it in GitHub Desktop.
Save uppittu11/02396be93269675a6b72794ecf628e52 to your computer and use it in GitHub Desktop.
;
; File top.top was generated
; By user: parashara (501)
; On host: Parasharas-MacBook-Pro.local
; At date: Wed. February 3 12:57:49 2020
;
; This is a standalone topology file
;
; Created by:
; ParmEd: test.py, VERSION 3.2.0
; Executable: test.py
; Library dir: /Users/parashara/Documents/devel/src/gromacs/install/share/gromacs/top
; Command line:
; test.py
;
[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 3 yes 1 1
[ atomtypes ]
; name at.num mass charge ptype sigma epsilon
CH4 0 16.043000 0.00000000 A 0.373 1.23054
CH3 0 15.035000 0.00000000 A 0.375 0.814817
OH 0 15.999400 0.00000000 A 0.302 0.773245
[ moleculetype ]
; Name nrexcl
RES 3
[ atoms ]
; nr type resnr residue atom cgnr charge mass typeB chargeB massB
; residue 1 RES rtp RES q 0.0
1 CH4 1 RES _CH4 1 0.00000000 16.043000 ; qtot 0.000000
[ system ]
; Name
Generic title
[ molecules ]
; Compound #mols
RES 16
import mbuild as mb
from foyer import Forcefield
import topology
from topology.external.convert_parmed import from_parmed
from topology.formats.top import write_top
from topology.formats.gro import write_gro
methane_cmpd = mb.Compound()
methane_particle = mb.Particle(name="_CH4")
methane_cmpd.add(methane_particle)
methanol = mb.Compound()
ch3 = mb.Particle(name="_CH3")
oh = mb.Particle(name="_OH")
methanol.add([ch3, oh])
ch3_port = mb.Port(anchor=ch3, orientation=[1,0,0], separation=0.07)
methanol.add(ch3_port, label='right')
oh_port = mb.Port(anchor=oh, orientation=[-1,0,0], separation=0.07)
methanol.add(oh_port, label='left')
mb.force_overlap(move_this=oh,
from_positions=methanol['left'],
to_positions=methanol['right'])
methane_grid = mb.Grid3DPattern(2,2,2)
methane_grid.scale(0.4)
list_of_methanes = methane_grid.apply(methane_cmpd)
methane_box = mb.Compound(list_of_methanes)
methanol_grid = mb.Grid3DPattern(2,2,2)
methanol_grid.scale(0.4)
list_of_methanols = methane_grid.apply(methanol)
methanol_box = mb.Compound(list_of_methanols)
methanol_box.translate([0,0, 1.1*max(methane_box.xyz[:,2])])
mixture_box = mb.Compound([methane_box, methanol_box])
ff = Forcefield(forcefield_files='ff.xml')
struc = ff.apply(mixture_box)
top = from_parmed(struc)
write_top(top, "test.top")
write_gro(top, "test.gro")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment