In [ ]:
%matplotlib inline

import kappa

In [ ]:
amber = kappa.Amber()

cnt = kappa.build(amber, "cnt")

kappa.plot.bonds(cnt)

kappa.plot.faces(cnt)

In [ ]:
#pick our indices
indices1 = [73,3]
indices2 = [73,3,76,146]

#generate some chains
polyeth = kappa.build(amber, "polyeth", count=2)
teflon = kappa.build(amber, "teflon", count=2)

#let's look at them
kappa.plot.bonds(polyeth, sites=True)
kappa.plot.bonds(teflon, sites=True)

In [ ]:
#call attach function to make a new molecule
cnt_polyeth1 = kappa.attach(cnt, [polyeth]*2, indices1)

kappa.plot.bonds(cnt_polyeth1)

What we've just done is attach a polyethylene molecule (length unit 2 as specified) to the atomic indices we specified in indices1.

Let us make more molecules then export their gro files.

mol0 is 1 polyethylene connection on each interface

mol1 is 2 polyeth connections

mol2 is 1 teflon connection

mol3 is 2 teflon connections

all connections are length 2


In [ ]:
cnt_polyeth2 = kappa.attach(cnt, [polyeth]*4, indices2)

cnt_teflon1 = kappa.attach(cnt, [teflon]*2, indices1)
cnt_teflon2 = kappa.attach(cnt, [teflon]*4, indices2)

kappa.plot.bonds(cnt_polyeth2)
kappa.plot.bonds(cnt_teflon1)
kappa.plot.bonds(cnt_teflon2)

You may wish to stop plotting matplotlib inline and look at these molecules in 3d.

Now let's export.


In [ ]:
for count, mol in enumerate([cnt_polyeth1, cnt_polyeth2, cnt_teflon1, cnt_teflon2]):
    name = 'mol{}'.format(count)
    mol.hydrogenate()
    pdb = kappa.md.generate.pdb(mol)
    gro = kappa.md.generate.gro(mol, fn=name+'.gro')
    itp = kappa.md.generate.restrains(mol, fn=name+'.itp')
    kappa.md.save_file(pdb,'.', name+'.pdb')

In [ ]: