• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mbuild.fill_box函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mbuild.fill_box函数的典型用法代码示例。如果您正苦于以下问题:Python fill_box函数的具体用法?Python fill_box怎么用?Python fill_box使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fill_box函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_create_semi_rigid_bodies_hierarchy

    def test_create_semi_rigid_bodies_hierarchy(self, benzene_from_parts):
        n_benzenes = 10
        filled = mb.fill_box(benzene_from_parts,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.name = 'Benzene box'
        filled2 = mb.clone(filled)
        compound = mb.Compound(subcompounds=[filled, filled2])

        compound.label_rigid_bodies(discrete_bodies='Benzene box')
        assert compound.max_rigid_id == 1
        assert filled.max_rigid_id == 0
        assert filled2.max_rigid_id == 1
        assert len(list(compound.rigid_particles())) == n_benzenes * 2 * 12

        compound.unlabel_rigid_bodies()
        compound.label_rigid_bodies(discrete_bodies='Benzene', rigid_particles='C')
        assert compound.max_rigid_id == (n_benzenes*2) - 1
        assert filled.max_rigid_id == n_benzenes - 1
        assert filled2.max_rigid_id == (n_benzenes*2) - 1
        assert len(list(compound.rigid_particles())) == n_benzenes * 2 * 6
        assert len(list(filled.rigid_particles())) == n_benzenes * 6
        assert len(list(filled2.rigid_particles())) == n_benzenes * 6

        compound.unlabel_rigid_bodies()
        compound.label_rigid_bodies(discrete_bodies='CH')
        assert compound.max_rigid_id == (n_benzenes*2*6) - 1
        assert filled.max_rigid_id == (n_benzenes*6) - 1
        assert filled2.max_rigid_id == (n_benzenes*2*6) - 1
        assert len(list(compound.rigid_particles())) == n_benzenes * 2 * 12
        assert len(list(filled.rigid_particles())) == n_benzenes * 12
        assert len(list(filled2.rigid_particles())) == n_benzenes * 12
开发者ID:iModels,项目名称:mbuild,代码行数:32,代码来源:test_rigid.py


示例2: test_label_rigid_bodies_duplicate_warn

 def test_label_rigid_bodies_duplicate_warn(self, rigid_benzene):
     with pytest.warns(UserWarning):
         n_benzenes = 10
         filled = mb.fill_box(rigid_benzene,
                              n_compounds=n_benzenes,
                              box=[0, 0, 0, 4, 4, 4])
         filled.label_rigid_bodies(discrete_bodies='Benzene')
开发者ID:iModels,项目名称:mbuild,代码行数:7,代码来源:test_rigid.py


示例3: build_ethane_box

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
开发者ID:iModels,项目名称:simgen,代码行数:7,代码来源:mbuild_example.py


示例4: test_no_rotate

 def test_no_rotate(self, h2o):
     filled = mb.fill_box([h2o, h2o], [1, 1], box=[1, 1, 1], fix_orientation=[False, True])
     w0 = filled.xyz[:3]
     w1 = filled.xyz[3:]
     # Translate w0 and w1 to COM
     w0 -= w0.sum(0) / len(w0)
     w1 -= w1.sum(0) / len(w1)
     assert np.isclose(w0, w1).all() is not True
开发者ID:iModels,项目名称:mbuild,代码行数:8,代码来源:test_packing.py


示例5: test_write_temp_file

 def test_write_temp_file(self, h2o):
     cwd = os.getcwd() # Must keep track of the temp dir that pytest creates
     filled = mb.fill_box(h2o, n_compounds=10, box=[4, 4, 4], temp_file='temp_file1.pdb')
     region = mb.fill_region(h2o, 10, [2, 2, 2, 4, 4, 4], temp_file='temp_file2.pdb')
     solvated = mb.solvate(filled, h2o, 10, box=[4, 4, 4], temp_file='temp_file3.pdb')
     assert os.path.isfile(os.path.join(cwd, 'temp_file1.pdb'))
     assert os.path.isfile(os.path.join(cwd, 'temp_file2.pdb'))
     assert os.path.isfile(os.path.join(cwd, 'temp_file3.pdb'))
开发者ID:iModels,项目名称:mbuild,代码行数:8,代码来源:test_packing.py


示例6: test_rotate

 def test_rotate(self, h2o):
     filled = mb.fill_box(h2o, 2, box=[1, 1, 1], fix_orientation=True)
     w0 = filled.xyz[:3]
     w1 = filled.xyz[3:]
     # Translate w0 and w1 to COM
     w0 -= w0.sum(0) / len(w0)
     w1 -= w1.sum(0) / len(w1)
     assert np.isclose(w0, w1).all()
开发者ID:iModels,项目名称:mbuild,代码行数:8,代码来源:test_packing.py


示例7: box_of_benzenes

 def box_of_benzenes(self, benzene):
     n_benzenes = 10
     benzene.name = 'Benzene'
     filled = mb.fill_box(benzene,
                          n_compounds=n_benzenes,
                          box=[0, 0, 0, 4, 4, 4]) 
     filled.label_rigid_bodies(discrete_bodies='Benzene', rigid_particles='C')
     return filled
开发者ID:ctk3b,项目名称:mbuild,代码行数:8,代码来源:base_test.py


示例8: test_delete_body_multiple

    def test_delete_body_multiple(self, rigid_benzene):
        n_benzenes = 10
        filled = mb.fill_box(rigid_benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.remove([filled.children[0], filled.children[1]])

        assert filled.max_rigid_id == n_benzenes - 3
        assert len(list(filled.rigid_particles())) == (n_benzenes - 2) * rigid_benzene.n_particles
开发者ID:iModels,项目名称:mbuild,代码行数:9,代码来源:test_rigid.py


示例9: test_box_dimensions

 def test_box_dimensions(self, benzene):
     n_benzenes = 10
     filled = mb.fill_box(benzene,
                          n_compounds=n_benzenes,
                          box=[0, 0, 0, 4, 4, 4])
     filled.save(filename='benzene.hoomdxml')
     for atom in mb.load('benzene.hoomdxml'):
         assert atom.pos.max() < 20
         assert atom.pos.min() > -20
开发者ID:iModels,项目名称:mbuild,代码行数:9,代码来源:test_hoomdxml.py


示例10: test_label_semi_rigid_bodies_after_fill

    def test_label_semi_rigid_bodies_after_fill(self, benzene):
        n_benzenes = 10
        filled = mb.fill_box(benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.label_rigid_bodies(discrete_bodies='Benzene', rigid_particles='C')

        assert filled.max_rigid_id == n_benzenes - 1
        assert len(list(filled.rigid_particles())) == n_benzenes * 6
开发者ID:iModels,项目名称:mbuild,代码行数:9,代码来源:test_rigid.py


示例11: test_save_non_sequential_rigid_ids

 def test_save_non_sequential_rigid_ids(self, benzene):
     n_benzenes = 10
     filled = mb.fill_box(benzene,
                          n_compounds=n_benzenes,
                          box=[0, 0, 0, 4, 4, 4])
     filled.label_rigid_bodies(discrete_bodies='Benzene')
     filled.children[0]._increment_rigid_ids(increment=3)
     with pytest.warns(UserWarning):
         filled.save('benzene-box.hoomdxml')
开发者ID:iModels,项目名称:mbuild,代码行数:9,代码来源:test_rigid.py


示例12: test_delete_body_semi_rigid

    def test_delete_body_semi_rigid(self, benzene):
        n_benzenes = 10
        filled = mb.fill_box(benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.label_rigid_bodies(discrete_bodies='Benzene', rigid_particles='C')
        filled.remove(filled.children[0])

        assert filled.max_rigid_id == n_benzenes - 2
        assert len(list(filled.rigid_particles())) == (n_benzenes - 1) * 6
开发者ID:iModels,项目名称:mbuild,代码行数:10,代码来源:test_rigid.py


示例13: test_fill_box_rigid

    def test_fill_box_rigid(self, rigid_benzene):
        n_benzenes = 10
        filled = mb.fill_box(rigid_benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])

        assert filled.contains_rigid is True
        assert filled.rigid_id is None
        assert filled.max_rigid_id == n_benzenes - 1
        assert len(list(filled.rigid_particles())) == n_benzenes * rigid_benzene.n_particles
开发者ID:iModels,项目名称:mbuild,代码行数:10,代码来源:test_rigid.py


示例14: test_delete_body_particle_by_particle

    def test_delete_body_particle_by_particle(self, rigid_benzene):
        n_benzenes = 10
        filled = mb.fill_box(rigid_benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        for particle in filled.children[0].particles():
            filled.remove(particle)

        assert filled.max_rigid_id == n_benzenes - 2
        assert len(list(filled.rigid_particles())) == (n_benzenes - 1) * rigid_benzene.n_particles
开发者ID:iModels,项目名称:mbuild,代码行数:10,代码来源:test_rigid.py


示例15: test_fill_box_semi_rigid

    def test_fill_box_semi_rigid(self, benzene):
        n_benzenes = 10
        benzene.label_rigid_bodies(rigid_particles='C')
        filled = mb.fill_box(benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])

        assert filled.contains_rigid is True
        assert filled.rigid_id is None
        assert filled.max_rigid_id == n_benzenes - 1
        assert len(list(filled.rigid_particles())) == n_benzenes * 6
开发者ID:iModels,项目名称:mbuild,代码行数:11,代码来源:test_rigid.py


示例16: test_remove_from_box

    def test_remove_from_box(self, ethane):
        n_ethanes = 5
        box = mb.fill_box(ethane, n_ethanes, [3, 3, 3])
        box.remove(box.children[3])

        n_ethanes -= 1
        assert box.n_particles == n_ethanes * ethane.n_particles
        assert len(box.children) == n_ethanes
        assert box.n_bonds == n_ethanes * ethane.n_bonds
        assert len([meth.referenced_ports()
                    for eth in box.children
                    for meth in eth.children]) == 2 * n_ethanes
开发者ID:tcmoore3,项目名称:mbuild,代码行数:12,代码来源:test_compound.py


示例17: solvate_bilayer

    def solvate_bilayer(self):
        """Solvate the constructed bilayer. """
        solvent_number_density = self.solvent.n_particles / np.prod(self.solvent.periodicity)

        lengths = self.lipid_box.lengths
        water_box_z = self.solvent_per_layer / (lengths[0] * lengths[1] * solvent_number_density)

        mins = self.lipid_box.mins
        maxs = self.lipid_box.maxs
        bilayer_solvent_box = mb.Box(mins=[mins[0], mins[1], maxs[2]],
                                     maxs=[maxs[0], maxs[1], maxs[2] + 2 * water_box_z])

        self.solvent_components.add(mb.fill_box(self.solvent, bilayer_solvent_box))
开发者ID:TengyuMaVandy,项目名称:mbuild,代码行数:13,代码来源:bilayer.py


示例18: test_label_rigid_bodies_list

    def test_label_rigid_bodies_list(self, benzene):
        n_benzenes = 10
        filled = mb.fill_box(benzene,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.children[0].name = 'Benzene0'
        filled.children[1].name = 'Benzene1'
        filled.label_rigid_bodies(discrete_bodies=['Benzene0', 'Benzene1'])

        assert filled.contains_rigid is True
        assert filled.rigid_id is None
        assert filled.max_rigid_id == 1
        assert len(list(filled.rigid_particles())) == 2 * benzene.n_particles
开发者ID:iModels,项目名称:mbuild,代码行数:13,代码来源:test_rigid.py


示例19: test_create_semi_rigid_bodies_filled_no_increment

    def test_create_semi_rigid_bodies_filled_no_increment(self, benzene_from_parts):
        n_benzenes = 10
        filled = mb.fill_box(benzene_from_parts,
                             n_compounds=n_benzenes,
                             box=[0, 0, 0, 4, 4, 4])
        filled.label_rigid_bodies(discrete_bodies='Benzene', rigid_particles='C')
        filled2 = mb.clone(filled)
        filled.add(filled2, reset_rigid_ids=False)

        assert filled.max_rigid_id == n_benzenes - 1
        assert len(list(filled.rigid_particles())) == n_benzenes * 2 * 6
        for rigid_id in range(n_benzenes):
            assert len(list(filled.rigid_particles(rigid_id=rigid_id))) == 12
开发者ID:iModels,项目名称:mbuild,代码行数:13,代码来源:test_rigid.py


示例20: test_box_dimensions

 def test_box_dimensions(self, benzene):
     import gsd
     n_benzenes = 10
     filled = mb.fill_box(benzene,
                          n_compounds=n_benzenes,
                          box=[0, 0, 0, 4, 4, 4])
     filled.save(filename='benzene.gsd')
     gsd_file = gsd.pygsd.GSDFile(open('benzene.gsd', 'rb'))
     frame = gsd.hoomd.HOOMDTrajectory(gsd_file).read_frame(0)
     positions = frame.particles.position.astype(float)
     for coords in positions:
         assert coords.max() < 20
         assert coords.min() > -20
开发者ID:iModels,项目名称:mbuild,代码行数:13,代码来源:test_gsd.py



注:本文中的mbuild.fill_box函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mbuild.load函数代码示例发布时间:2022-05-27
下一篇:
Python mbuild.clone函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap