def test_pass_box(self, mb_ethane):
        mb_box = Box(lengths=[3, 3, 3])

        top = from_mbuild(mb_ethane, box=mb_box)
        assert_allclose_units(top.box.lengths, [3, 3, 3] * u.nm,
                              rtol=1e-5,
                              atol=1e-8)
    def test_from_mbuild_single_particle(self):
        compound = mb.Compound()
        top = from_mbuild(compound)

        assert top.n_sites == 1
        assert top.n_subtops == 0
        assert top.n_connections == 0
    def test_full_conversion(self, ethane):
        top = from_mbuild(ethane)

        new = to_mbuild(top)

        assert new.n_particles == 8
        assert new.n_bonds == 7
Exemple #4
0
 def test_pass_box_bounding(self, mb_ethane):
     mb_ethane.periodicity = [0, 0, 0]
     top = from_mbuild(mb_ethane)
     assert_allclose_units(
         top.box.lengths,
         (mb_ethane.boundingbox.lengths + [0.5, 0.5, 0.5]) * u.nm,
         rtol=1e-5,
         atol=1e-8)
 def test_pass_box_bounding(self, mb_ethane):
     mb_ethane.periodicity = [False, False, False]
     top = from_mbuild(mb_ethane)
     assert_allclose_units(
         top.box.lengths,
         (mb_ethane.get_boundingbox().lengths) * u.nm,
         rtol=1e-5,
         atol=1e-8,
     )
Exemple #6
0
    def ar_system(self):
        ar = mb.Compound(name='Ar')

        packed_system = mb.fill_box(
            compound=ar,
            n_compounds=100,
            box=mb.Box([3, 3, 3]),
        )

        return from_mbuild(packed_system)
    def test_from_mbuild_ethane(self, ethane):
        import mbuild as mb
        top = from_mbuild(ethane)

        assert top.n_sites == 8
        assert top.n_subtops == 1
        assert top.subtops[0].n_sites == 8
        assert top.n_connections == 7
        for i in range(top.n_sites):
            assert isinstance(top.sites[i].element, gmso.Element)
            assert top.sites[i].name == top.sites[i].element.symbol
Exemple #8
0
    def water_system(self):
        water = mb.load(get_path('tip3p.mol2'))
        water.name = 'water'
        water[0].name = 'opls_111'
        water[1].name = water[2].name = 'opls_112'

        packed_system = mb.fill_box(compound=water,
                                    n_compounds=2,
                                    box=mb.Box([2, 2, 2]))

        return from_mbuild(packed_system)
    def test_3_layer_compound(self):
        top_cmpnd = mb.Compound()
        mid_cmpnd = mb.Compound()
        bot_cmpnd = mb.Compound()

        top_cmpnd.add(mid_cmpnd)
        mid_cmpnd.add(bot_cmpnd)

        top_cmpnd.periodicity = [1, 1, 1]

        top = from_mbuild(top_cmpnd)

        assert top.n_sites == 1
        assert top.n_subtops == 1
        assert top.subtops[0].n_sites == 1
    def test_4_layer_compound(self):
        l0_cmpnd = mb.Compound()
        l1_cmpnd = mb.Compound()
        l2_cmpnd = mb.Compound()
        particle = mb.Compound()

        l0_cmpnd.add(l1_cmpnd)
        l1_cmpnd.add(l2_cmpnd)
        l2_cmpnd.add(particle)

        l0_cmpnd.periodicity = [1, 1, 1]

        top = from_mbuild(l0_cmpnd)

        assert top.n_sites == 1
        assert top.n_subtops == 1
        assert top.subtops[0].n_sites == 1
        assert top.subtops[0].sites[0] == top.sites[0]
    def test_uneven_hierarchy(self):
        top_cmpnd = mb.Compound()
        mid_cmpnd = mb.Compound()
        particle1 = mb.Compound()
        particle2 = mb.Compound()

        top_cmpnd.add(mid_cmpnd)
        top_cmpnd.add(particle1)
        mid_cmpnd.add(particle2)

        top_cmpnd.periodicity = [1, 1, 1]

        top = from_mbuild(top_cmpnd)

        assert top.n_sites == 2
        assert top.n_subtops == 2
        # Check that all sites belong to a subtop
        site_counter = 0
        for subtop in top.subtops:
            site_counter += subtop.n_sites
        assert site_counter == top.n_sites
 def test_pass_box_periodicity(self, mb_ethane):
     mb_ethane.periodicity = [2,2,2]
     top = from_mbuild(mb_ethane)
     assert_allclose_units(top.box.lengths, [2,2,2]*u.nm, rtol=1e-5, atol=1e-8)
 def test_empty_compound_name(self):
     compound = mb.load("CCOC", smiles=True)
     top = from_mbuild(compound)
     assert top.name is not None
 def test_pass_box_bounding(self, ethane):
     ethane.periodicity = [0, 0, 0]
     top = from_mbuild(ethane)
     assert allclose(top.box.lengths,
                     (ethane.boundingbox.lengths + [0.5, 0.5, 0.5]) * u.nm)
 def test_pass_box_periodicity(self, ethane):
     ethane.periodicity = [2, 2, 2]
     top = from_mbuild(ethane)
     assert allclose(top.box.lengths, [2, 2, 2] * u.nm)
 def test_pass_failed_box(self, ethane):
     with pytest.raises(ValueError):
         top = from_mbuild(ethane, box=[3, 3, 3])
    def test_pass_box(self, ethane):
        mb_box = Box(lengths=[3, 3, 3])

        top = from_mbuild(ethane, box=mb_box)
        assert allclose(top.box.lengths, [3, 3, 3] * u.nm)