def test_lateral_dims_near_x_y_spec(self):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     x = 4
     y = 4
     droplet = Droplet(radius=1, angle=90.0, fluid=water, density=997, x=x, y=y)
     assert (abs(droplet.boundingbox.lengths[0] - x) < 0.5 
                 and abs(droplet.boundingbox.lengths[1] - y) < 0.5)
 def test_save(self, Droplet):
     Droplet.save('droplet.gro', overwrite=True, combine='all')
 def test_init_with_too_large_y(self):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     with pytest.raises(ValueError, match="y .* 100"):
         Droplet(radius=1, angle=90.0, fluid=water, density=997, x=4, y=101)
 def test_init_with_too_small_x(self):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     with pytest.raises(ValueError, match="x .* at least"):
         Droplet(radius=1, angle=90.0, fluid=water, density=997, x=1, y=4)
 def test_init_with_lattice_without_lattice_compound(self, GoldLattice):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     with pytest.raises(ValueError, match="Lattice compounds"):
         Droplet(radius=1, angle=90.0, fluid=water, density=997, x=4, y=4, lattice=GoldLattice)
 def test_init_without_lattice_with_lattice_compound(self):
     lattice_compound = mbuild.Compound(name='Au')
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     with pytest.raises(ValueError, match="do not specify lattice_compound"):
         Droplet(radius=1, angle=90.0, fluid=water, density=997, x=4, y=4, lattice_compound=lattice_compound)
 def test_init_with_missing_density(self):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     with pytest.raises(ValueError, match="Fluid density"):
         Droplet(radius=1, angle=90.0, fluid=water)
 def test_init_with_missing_fluid(self):
     from dropletbuilder.dropletbuilder import Droplet
     with pytest.raises(ValueError, match="Fluid droplet compounds"):
         Droplet(radius=1, angle=90.0, density=997)
 def DropletWithDims(self):
     from dropletbuilder.dropletbuilder import Droplet
     water = mbuild.load(get_fn('tip3p.mol2'))
     return Droplet(radius=1, angle=90.0, fluid=water, density=997, x=4, y=4)
示例#10
0
from dropletbuilder.dropletbuilder import Droplet
import mbuild
from dropletbuilder.utils.io_tools import get_fn
from foyer import Forcefield

# water compound
water = mbuild.load(get_fn('tip3p.mol2'))
water.name = 'H2O'

# build the system
system = Droplet(radius=2, angle=110.0, fluid=water, density=997)

# get and apply forcefields
GPH = Forcefield(get_fn('graphene.xml'))
TIP3P = Forcefield(get_fn('tip3p.xml'))

for child in system.children:
    if child.name == 'LAT':
        lattice_pmd = GPH.apply(child.to_parmed(residues='C'))
    elif child.name == 'FLD':
        water_pmd = TIP3P.apply(child.to_parmed(residues='H2O'))
    else:
        continue

periodicity = system.periodicity
system = lattice_pmd + water_pmd 
system.box[2] = periodicity[2] * 100
system.save('water_graphene_drop.gro', overwrite=True, combine='all')
system.save('water_graphene_drop.top', overwrite=True, combine='all')
示例#11
0
lattice_spacing = [0.40788, 0.40788, 0.40788]
lattice_vector = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
gold_locations = [[0., 0., 0.], [.5, .5, 0.], [.5, 0., .5], [0, .5, .5]]
basis = {lattice_compound.name: gold_locations}
gold_lattice = mbuild.Lattice(lattice_spacing=lattice_spacing,
                              lattice_vectors=lattice_vector,
                              lattice_points=basis)

# hexane compound
hexane = Alkane(n=6)
hexane.name = 'HEX'

# build the system
system = Droplet(radius=3,
                 angle=90,
                 fluid=hexane,
                 density=655,
                 lattice=gold_lattice,
                 lattice_compound=lattice_compound)

# get and apply forcefields
AU = Forcefield(get_fn('heinz2008.xml'))
OPLSAA = Forcefield(name='oplsaa')

for child in system.children:
    if child.name == 'LAT':
        lattice_pmd = AU.apply(child.to_parmed(residues='Au'))
    elif child.name == 'FLD':
        hex_pmd = OPLSAA.apply(child.to_parmed(residues='HEX'))
    else:
        continue