Skip to content

11_Example_Input_Scripts

Ambuild-code edited this page Oct 27, 2020 · 10 revisions

11 Example Input Scripts

This section contains a variety of example Ambuild input scripts, each of which involves the growth of a polymer from methane building blocks. There is one example of each of the growBlocks, joinBlocks, and zipBlocks scripts, in which the polymer is built solely from methane fragments, with no solvent, catalyst, or influence from other reagents (Sections 11.1-11.3, respectively).

11.1 Example growBlocks Input Script

#!/usr/bin/env python3

#Our imports
from ambuild import ab_cell

#Cell Dimensions
boxDim=[30,30,30]

#Create the Cell
paramsDir='./params'
mycell = ab_cell.Cell(boxDim, atomMargin=0.1, bondMargin=0.5, bondAngleMargin=5,  paramsDir=paramsDir )

#Add Fragments to the Library
mycell.libraryAddFragment( filename='./blocks/ch4.car', fragmentType='Me' )

#Specify Bonding Rules
mycell.addBondType( 'Me:a-Me:a' )

#Seed the Cell with the Building Blocks in the Library
mycell.seed( 1, fragmentType='Me' )

for i in range(100):
    mycell.growBlocks(4, cellEndGroups='Me:a', libraryEndGroups='Me:a', maxTries=500)
    mycell.optimiseGeometry(quiet=True)
    mycell.dump()
    mycell.runMD(doDihedral=True, rCut=10, mdCycles=1000000, T=55.0)

11.2 Example joinBlocks Input Script

#!/usr/bin/env python3

#Our imports
from ambuild import ab_cell

#Cell Dimensions
boxDim=[30,30,30]

#Create the Cell
paramsDir='./params'
mycell = ab_cell.Cell(boxDim, atomMargin=0.1, bondMargin=0.5, bondAngleMargin=5,  paramsDir=paramsDir )

#Add Fragments to the Library
mycell.libraryAddFragment( filename='./blocks/ch4.car', fragmentType='Me' )

#Specify Bonding Rules
mycell.addBondType( 'Me:a-Me:a' )

#Seed the Cell with the Building Blocks in the Library
mycell.seed( 100, fragmentType='Me' )
mycell.optimiseGeometry(quiet=False)

for i in range(100):
    mycell.joinBlocks(1, cellEndGroups=None, maxTries=500)
    mycell.optimiseGeometry(quiet=False)
    mycell.dump()
    mycell.runMD(doDihedral=True, rCut=10, mdCycles=1000000, T=55.0)

11.3 Example zipBlocks Input Script

#!/usr/bin/env python3

#Our imports
from ambuild import ab_cell

#Cell Dimensions
boxDim=[30,30,30]

#Create the Cell
paramsDir='./params'
mycell = ab_cell.Cell(boxDim, atomMargin=0.1, bondMargin=0.5, bondAngleMargin=5,  paramsDir=paramsDir )

#Add Fragments to the Library
mycell.libraryAddFragment( filename='./blocks/ch4.car', fragmentType='Me' )

#Specify Bonding Rules
mycell.addBondType( 'Me:a-Me:a' )

#Seed the Cell with the Building Blocks in the Library
mycell.seed( 100, fragmentType='Me' )
mycell.runMD(doDihedral=True, rCut=10, mdCycles=1000000, T=55.0)
mycell.optimiseGeometry(quiet=True)

for i in range(100):
    mycell.zipBlocks(bondMargin=2.0, bondAngleMargin=30, clashCheck=False)
    mycell.optimiseGeometry(quiet=True)
    mycell.dump()
    mycell.runMD(doDihedral=True, rCut=10, mdCycles=1000000, T=55.0)

Clone this wiki locally