Exemple #1
0
def build_ethane_box(box, n_molecules):
    from mbuild.examples import Ethane
    import mbuild as mb
    ethane = Ethane()
    full_box = mb.fill_box(ethane, n_molecules, box)
    full_box.name = '{}_ethanes'.format(n_molecules)
    return full_box
def test_apply_residues():
    import mbuild as mb
    from mbuild.examples import Ethane
    ethane = Ethane()
    opls = Forcefield(name='oplsaa')
    typed = opls.apply(ethane, residues='CH3')
    assert len([res for res in typed.residues if res.name == 'CH3']) == 2
Exemple #3
0
 def ethane(self):
     from mbuild.examples import Ethane
     return Ethane()
    def test_mbuild_examples(self):
        import mbuild as mb
        from mbuild.examples import (Alkane, Methane, Ethane, PMPCLayer,
                                     AlkaneMonolayer)
        import foyer
        for i in range(4, 20):
            my_alkane = Alkane(n=i)
            ff = foyer.Forcefield(name='oplsaa')
            structure = ff.apply(my_alkane)
            bbox = my_alkane.boundingbox
            bbox.lengths *= 10
            if any(bbox.lengths < 10):
                bbox.lengths = [100, 100, 100]

            structure.box = [
                bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
            ]
            structure.combining_rule = 'lorentz'
            energies = commpare.spawn_engine_simulations(structure,
                                                         hoomd_kwargs={
                                                             'ref_distance':
                                                             10,
                                                             'ref_energy':
                                                             1 / 4.184
                                                         })
            print('Alkane, n={}'.format(i))
            print(energies)
            print('=' * 20)

        eth = Ethane()
        structure = ff.apply(eth)
        bbox = eth.boundingbox
        bbox.lengths *= 10
        if any(bbox.lengths < 10):
            bbox.lengths = [100, 100, 100]

        structure.box = [
            bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
        ]

        structure.combining_rule = 'lorentz'
        energies = commpare.spawn_engine_simulations(structure,
                                                     hoomd_kwargs={
                                                         'ref_distance': 10,
                                                         'ref_energy':
                                                         1 / 4.184
                                                     })
        print("Ethane")
        print(energies)
        print('=' * 20)

        methan = Methane()
        structure = ff.apply(methan)
        bbox = methan.boundingbox
        bbox.lengths *= 10
        if any(bbox.lengths < 10):
            bbox.lengths = [100, 100, 100]

        structure.box = [
            bbox.lengths[0], bbox.lengths[1], bbox.lengths[2], 90, 90, 90
        ]

        structure.combining_rule = 'lorentz'
        energies = commpare.spawn_engine_simulations(structure,
                                                     hoomd_kwargs={
                                                         'ref_distance': 10,
                                                         'ref_energy':
                                                         1 / 4.184
                                                     })
        print("Methane")
        print(energies)
        print('=' * 20)
Exemple #5
0
    if not is_leaf(real_thing):
        # create labels
        for label, part in real_thing.labels.items():
            if isinstance(part, list):
                # TODO support lists with labels
                continue
            if part in memo:
                memo[real_thing].labels[label] = memo[part]

        # recurse
        for part in real_thing.children:
            _create_proxy_labels(part, memo)


if __name__ == '__main__':
    from mbuild.examples import Ethane
    c = Ethane()
    # c = create_proxy(c)
    # p = create_proxy(c, leaf_classes=mbuild.lib.moieties.ch3.CH3)
    p = create_proxy(c)

    print("Top level proxy object: {}".format(p))

    print("Parts of top level proxy object:")
    for part in p.children:
        print(" {}".format(part))

    print("Leaves of top level proxy object:")
    for particle in p.particles():
        print(" {}".format(particle.name))