本文整理汇总了Python中chemlab.core.System.empty方法的典型用法代码示例。如果您正苦于以下问题:Python System.empty方法的具体用法?Python System.empty怎么用?Python System.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chemlab.core.System
的用法示例。
在下文中一共展示了System.empty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bond_orders
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_bond_orders():
# Get a molecule with some bonds
wat = _make_water()
wat_o = wat.copy()
# 0,1 0,2
assert_npequal(wat.bond_orders, np.array([1, 1]))
# Remove a bond
wat.bonds = np.array([[0, 1]])
assert_npequal(wat.bond_orders, np.array([1]))
wat.bond_orders = np.array([2])
# Try with a system
s = System.empty(2, 6)
s.add(wat_o)
s.add(wat)
assert_npequal(s.bond_orders , np.array([1, 1, 2]))
s.reorder_molecules([1, 0]) # We don't actually sort bonds again
assert_npequal(s.bond_orders , np.array([1, 1, 2]))
s.bonds = np.array([[0, 1], [0, 2], [3, 4], [3, 5]])
assert_npequal(s.bond_orders, np.array([1, 1, 2, 1]))
示例2: test_merge_system
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_merge_system():
# take a protein
from chemlab.io import datafile
from chemlab.graphics import display_system
from chemlab.db import ChemlabDB
water = ChemlabDB().get("molecule", "example.water")
prot = datafile("tests/data/3ZJE.pdb").read("system")
# Take a box of water
NWAT = 50000
bsize = 20.0
pos = np.random.random((NWAT, 3)) * bsize
wat = water.copy()
s = System.empty(NWAT, NWAT*3, box_vectors=np.eye(3)*bsize)
for i in range(NWAT):
wat.move_to(pos[i])
s.add(wat)
prot.r_array += 10
s = merge_systems(s, prot, 0.5)
display_system(s, 'ball-and-stick')
示例3: test_write_gromacs
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_gromacs():
water = Molecule(
[
Atom("O", [0.0, 0.0, 0.0], export={"grotype": "OW"}),
Atom("H", [0.1, 0.0, 0.0], export={"grotype": "HW1"}),
Atom("H", [-0.03333, 0.09428, 0.0], export={"grotype": "HW2"}),
],
export={"groname": "SOL"},
)
sys = System.empty(200, 3 * 200, box_vectors=np.eye(3) * 2.0)
for i in range(200):
sys.add(water.copy())
df = datafile("/tmp/dummy.gro", mode="w")
df.write("system", sys)
with assert_raises(Exception):
df = datafile("/tmp/dummy.gro")
df.write("system", sys)
df = datafile("/tmp/dummy.gro")
sread = df.read("system")
assert all(sread.type_array == sys.type_array)
示例4: test_write_pdb
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_pdb():
water = Molecule([Atom('O', [0.0, 0.0, 0.0], export={'grotype': 'OW'}),
Atom('H', [0.1, 0.0, 0.0], export={'grotype': 'HW1'}),
Atom('H', [-0.03333, 0.09428, 0.0], export={'grotype': 'HW2'})],
export={'groname': 'SOL'})
sys = System.empty(200, 3*200, box_vectors = np.eye(3) * 2.0)
for i in range(200):
sys.add(water.copy())
df = datafile('/tmp/dummy.gro', mode="w")
df.write("system", sys)
示例5: _make_molecules
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def _make_molecules(self):
wat = _make_water()
wat.r_array *= 0.1
# Initialization from empty
s = System.empty(4, 4*3)
mols = []
# Array to be compared
for _ in range(s.n_mol):
wat.r_array += 0.1
mols.append(wat.copy())
return mols
示例6: test_write_pdb
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_pdb():
water = Molecule([Atom('O', [0.0, 0.0, 0.0], export={'pdb.type': 'O'}),
Atom('H', [0.1, 0.0, 0.0], export={'pdb.type': 'H'}),
Atom('H', [-0.03333, 0.09428, 0.0], export={'pdb.type': 'H'})],
export={'groname': 'SOL'})
sys = System.empty()
with sys.batch() as b:
for i in range(200):
water.r_array += 0.1
b.append(water.copy())
df = datafile('/tmp/dummy.pdb', mode="w")
df.write("system", sys)
示例7: test_write_gromacs
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_gromacs():
water = Molecule([Atom('O', [0.0, 0.0, 0.0], export={'grotype': 'OW'}),
Atom('H', [0.1, 0.0, 0.0], export={'grotype': 'HW1'}),
Atom('H', [-0.03333, 0.09428, 0.0], export={'grotype': 'HW2'})],
export={'groname': 'SOL'})
sys = System.empty(200, 3*200, box_vectors = np.eye(3)*2.0)
for i in range(200):
sys.add(water.copy())
df = datafile('/tmp/dummy.gro', mode="w")
df.write('system', sys)
df = datafile('/tmp/dummy.gro')
sread = df.read('system')
assert all(sread.type_array == sys.type_array)
示例8: test_write_pdb
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_pdb():
water = Molecule(
[
Atom("O", [0.0, 0.0, 0.0], export={"pdb.type": "O"}),
Atom("H", [0.1, 0.0, 0.0], export={"pdb.type": "H"}),
Atom("H", [-0.03333, 0.09428, 0.0], export={"pdb.type": "H"}),
],
export={"groname": "SOL"},
)
sys = System.empty(200, 3 * 200, box_vectors=np.eye(3) * 2.0)
for i in range(200):
water.r_array += 0.1
sys.add(water.copy())
df = datafile("/tmp/dummy.pdb", mode="w")
df.write("system", sys)
示例9: test_bonds
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_bonds():
from chemlab.io import datafile
bz = datafile("tests/data/benzene.mol").read('molecule')
na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
# Adding bonds
s = System.empty(2, 2*bz.n_atoms)
s.add(bz)
assert_npequal(s.bonds, bz.bonds)
assert_npequal(bz.bond_orders, [1, 2, 2, 1, 1, 2])
assert_npequal(s.bond_orders, bz.bond_orders)
s.add(bz)
assert_npequal(s.bonds, np.concatenate((bz.bonds, bz.bonds + 6)))
#assert_npequal(s.bond_orders)
# Reordering
orig = np.array([[0, 1], [6, 8]])
s.bonds = orig
s.reorder_molecules([1, 0])
assert_npequal(s.bonds, np.array([[6, 7], [0, 2]]))
# This doesn't change the bond_ordering
# Selection
ss = subsystem_from_molecules(s, [1])
assert_npequal(ss.bonds, np.array([[0, 1]]))
import inspect
ss2 = System.from_arrays(**dict(inspect.getmembers(ss)))
ss2.r_array += 10.0
ms = merge_systems(ss, ss2)
assert_npequal(ms.bonds, np.array([[0, 1], [6, 7]]))
assert_npequal(ms.bond_orders, np.array([1, 1]))
# From_arrays
s = System.from_arrays(mol_indices=[0], bonds=bz.bonds, **bz.__dict__)
assert_npequal(s.bonds, bz.bonds)
assert_npequal(s.bond_orders, bz.bond_orders)
# Get molecule entry
# Test the bonds when they're 0
s.bonds = np.array([])
assert_equals(s.get_derived_molecule_array('formula'), 'C6')
示例10: test_write_gromacs
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_write_gromacs():
water = Molecule([Atom('O', [0.0, 0.0, 0.0], name="OW"),
Atom('H', [0.1, 0.0, 0.0], name='HW1'),
Atom('H', [-0.03333, 0.09428, 0.0], name='HW2')],
name='SOL')
sys = System.empty()
with sys.batch() as b:
for i in range(200):
b.append(water.copy())
sys.box_vectors = [[2, 0, 0], [0, 2, 0], [0, 0, 2]]
df = datafile('/tmp/dummy.gro', mode="w")
df.write('system', sys)
with assert_raises(Exception):
df = datafile('/tmp/dummy.gro')
df.write('system', sys)
df = datafile('/tmp/dummy.gro')
sread = df.read('system')
assert all(sread.type_array == sys.type_array)
示例11: Molecule
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
import numpy as np
from chemlab.core import Atom, Molecule, System
from chemlab.graphics import display_system
# Spacing between two grid points
spacing = 0.3
# an 8x8x8 grid, for a total of 512 points
grid_size = (8, 8, 8)
# Preallocate the system
# 512 molecules, and 512*3 atoms
s = System.empty(512, 512*3)
# Water template, it contains export informations for gromacs
# more about export later...
water_tmp = Molecule([Atom('O', [0.0, 0.0, 0.0], export={'grotype': 'OW'}),
Atom('H', [0.1, 0.0, 0.0], export={'grotype': 'HW1'}),
Atom('H', [-0.03333, 0.09428, 0.0], export={'grotype':'HW2'})],
export={'groname': 'SOL'})
for a in range(grid_size[0]):
for b in range(grid_size[1]):
for c in range(grid_size[2]):
grid_point = np.array([a,b,c]) * spacing # array operation
water_tmp.move_to(grid_point)
s.add(water_tmp)
# Adjust boxsize for periodic conditions
s.box_vectors = np.eye(3) * 8 * spacing
示例12: test_from_empty
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_from_empty(self):
s = System.empty(molecule=3, atom=9, bonds=6)
assert_npequal(s.type_array, [''] * 9)
assert_npequal(s.molecule_name, [''] * 3)
示例13: test_from_empty
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import empty [as 别名]
def test_from_empty(self):
mols = self._make_molecules()
system = System.empty(4, 4*3)
[system.add(mol) for mol in mols]
self._assert_init(system)