Sending again with the script inline, so that it is easier to find using a google search ;-)
from Sire.Mol import *
from Sire.IO import *
from Sire.Maths import *
from Sire.MM import *
from Sire.Units import *
# create the molecule
benzene = Molecule("benzene")
# create a residue for all of the atoms
res = benzene.edit().add( ResName("BEN") )
res.renumber( ResNum(1) )
# Add a CutGroup - all atoms
# have to be children of a CutGroup (a single entity
# that is used for cutoff or periodic boundary calculations,
# and is essentially the same as a residue) - this requirement
# for cutgroups is very confusing and something I want to remove!
res.molecule().add( CGName("1") )
# Now add the atoms to the residue, ensuring they are
# a child of the cutgroup
res.add( AtomName("H1") ).reparent( CGName("1") )
res.add( AtomName("H2") ).reparent( CGName("1") )
res.add( AtomName("H3") ).reparent( CGName("1") )
res.add( AtomName("H4") ).reparent( CGName("1") )
res.add( AtomName("H5") ).reparent( CGName("1") )
res.add( AtomName("H6") ).reparent( CGName("1") )
res.add( AtomName("C1") ).reparent( CGName("1") )
res.add( AtomName("C2") ).reparent( CGName("1") )
res.add( AtomName("C3") ).reparent( CGName("1") )
res.add( AtomName("C4") ).reparent( CGName("1") )
res.add( AtomName("C5") ).reparent( CGName("1") )
res.add( AtomName("C6") ).reparent( CGName("1") )
# now we have added all of the atoms, commit this
# so that we can add properties to the molecule
# (properties are the connectivity of the atoms,
# coordinates of the atoms, charges, LJ parameters etc.)
benzene = res.molecule().commit()
# here are the charges and LJ parameters for benzene
# (please look these up as I have just guessed them!)
c_chg = -0.0622 * mod_electron
h_chg = 0.0622 * mod_electron
c_lj = LJParameter( 3.5 * angstrom, -0.015 * kcal_per_mol )
h_lj = LJParameter( 1.0 * angstrom, -0.005 * kcal_per_mol )
# let's set the coordinates, element, charges and LJ parameters
benzene = benzene.edit() \
.atom( AtomName("C1") ) \
.setProperty("coordinates", Vector(0.000, 1.396, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("C2") ) \
.setProperty("coordinates", Vector(1.209, 0.698, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("C3") ) \
.setProperty("coordinates", Vector(1.209, -0.698, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("C4") ) \
.setProperty("coordinates", Vector(0.000, -1.396, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("C5") ) \
.setProperty("coordinates", Vector(-1.209, -0.698, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("C6") ) \
.setProperty("coordinates", Vector(-1.209, 0.698, 0.000)) \
.setProperty("element", Element("C")) \
.setProperty("charge", c_chg).setProperty("LJ", c_lj) \
.molecule().atom( AtomName("H1") ) \
.setProperty("coordinates", Vector( 0.000, 2.479, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().atom( AtomName("H2") ) \
.setProperty("coordinates", Vector( 2.147, 1.240, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().atom( AtomName("H3") ) \
.setProperty("coordinates", Vector( 2.147, -1.240, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().atom( AtomName("H4") ) \
.setProperty("coordinates", Vector( 0.000, -2.479, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().atom( AtomName("H5") ) \
.setProperty("coordinates", Vector(-2.147, -1.240, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().atom( AtomName("H6") ) \
.setProperty("coordinates", Vector(-2.147, 1.240, 0.000)) \
.setProperty("element", Element("H")) \
.setProperty("charge", h_chg).setProperty("LJ", h_lj) \
.molecule().commit()
# now set the connectivity of the molecule - this will automatically
# work out the connectivity based on the elements and interatomic distances
connectivity = Connectivity(benzene)
# print it to check it is correct. If not, look at the
# functions of this object to add or remove bonds
print(connectivity)
# set the connectivity property of the molecule
benzene = benzene.edit().setProperty("connectivity", connectivity).commit()
# print out a PDB of the molecule
PDB().write(benzene, "benzene.pdb")
# duplicate the molecule so that we can calculate inter-benzene energies
benzene2 = benzene.edit().renumber().commit()
# translate this second molecule by 5 A along the Z axis
benzene2 = benzene2.move().translate( Vector(0,0,5) ).commit()
# create a forcefield to calculate the coulomb and LJ energy
cljff = InterFF()
cljff.add(benzene)
cljff.add(benzene2)
print("\nCalculating the interaction energy...")
print("Coulomb = %s" % cljff.energy( cljff.components().coulomb() ))
print("LJ = %s" % cljff.energy( cljff.components().lj() ))