本文整理汇总了Python中chemlab.core.System.from_arrays方法的典型用法代码示例。如果您正苦于以下问题:Python System.from_arrays方法的具体用法?Python System.from_arrays怎么用?Python System.from_arrays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chemlab.core.System
的用法示例。
在下文中一共展示了System.from_arrays方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_attributes
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_attributes():
coords = [np.random.rand(10, 3) for i in range(10)]
t = np.arange(0, 10, 0.1)
traj = Trajectory(coords, t)
system = System.from_arrays(r_array=coords[0])
system.update(traj.at(1))
npeq_(system.r_array, coords[1])
示例2: test_bonds
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [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')
示例3: test_display
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_display():
d = Display('povray')
s = System.from_arrays(type_array=['O', 'H', 'H'],
r_array=[[0.0, 0.0, 0.0], [0.15, 0.0, 0.0], [0.0, 0.15, 0.0]])
d.system(s)
s.r_array = s.r_array + 0.3
d.system(s, alpha=0.5)
d.render()
示例4: test_from_arrays
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_from_arrays(self):
mols = self._make_molecules()
system = System.from_arrays(
r_array=np.concatenate([m.r_array for m in mols]),
type_array=np.concatenate([m.type_array for m in mols]),
bonds=np.concatenate([m.bonds + 3 * i for i, m in enumerate(mols)
]),
maps={
('atom', 'molecule'): [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3],
('bond', 'molecule'): [0, 0, 1, 1, 2, 2, 3, 3]
})
self._assert_init(system)
示例5: test_atom_type
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_atom_type(self):
self.s = System.from_arrays(
type_array=["Cl", "Cl", "O", "H", "H", "O", "H", "H", "O", "H", "H", "Na", "Na"],
maps={("atom", "molecule"): [0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6]},
)
idx = self.s.where(atom_type="O")
assert_npequal(
idx["atom"], [False, False, True, False, False, True, False, False, True, False, False, False, False]
)
assert_npequal(idx["molecule"], [False, False, True, True, True, False, False])
self.s = System.from_arrays(
type_array=["Cl", "Cl", "O", "H", "H", "O", "H", "H", "O", "H", "H", "Na", "Na"],
maps={("atom", "molecule"): [0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6]},
)
idx = self.s.where(atom_type=["Na", "Cl"])
assert_npequal(
idx["atom"], [True, True, False, False, False, False, False, False, False, False, False, True, True]
)
示例6: test_from_arrays
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_from_arrays(self):
mols = self._make_molecules()
r_array = np.concatenate([m.r_array for m in mols])
type_array = np.concatenate([m.type_array for m in mols])
mol_indices = [0, 3, 6, 9]
bonds = np.concatenate([m.bonds + 3*i for i, m in enumerate(mols)])
system = System.from_arrays(r_array=r_array,
type_array=type_array,
mol_indices=mol_indices,
bonds=bonds)
self._assert_init(system)
示例7: test_atom_type
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_atom_type(self):
self.s = System.from_arrays(
type_array=['Cl', 'Cl', 'O', 'H', 'H', 'O', 'H', 'H', 'O', 'H',
'H', 'Na', 'Na'],
maps=
{('atom', 'molecule'): [0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6]})
idx = self.s.where(type_array='O')
assert_npequal(idx['atom'],
[False, False, True, False, False, True, False, False,
True, False, False, False, False])
assert_npequal(idx['molecule'], [False, False, True, True, True, False,
False])
self.s = System.from_arrays(
type_array=['Cl', 'Cl', 'O', 'H', 'H', 'O', 'H', 'H', 'O', 'H',
'H', 'Na', 'Na'],
maps=
{('atom', 'molecule'): [0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 6]})
idx = self.s.where(type_array=['Na', 'Cl'])
assert_npequal(idx['atom'],
[True, True, False, False, False, False, False, False,
False, False, False, True, True])
示例8: test_query
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_query():
type_array = ['Cl', 'Cl', 'O', 'H', 'H', 'O', 'H', 'H', 'Na', 'Na']
mol_indices = [0, 1, 2, 5, 8, 9]
s = System.from_arrays(type_array = type_array, mol_indices=mol_indices)
array_eq_(s.where(type_in=['Na', 'Cl']),
[True, True, False, False, False, False, False, False, True, True])
array_eq_(s.where(type='Cl'),
[True, True, False, False, False, False, False, False, False, False])
# We move the Cl away
cl = s.where(type='Cl')
s.r_array[cl.nonzero()[0]] = [1, 0, 0]
s.box_vectors = np.diag([3, 3, 3])
array_eq_(s.where(type_in=['H', 'O'], within_of=(0.2, [8, 9])),
[False, False, True, True, True, True, True, True, False, False])
array_eq_(s.where(type_in=['H', 'O'], within_of=(0.2, 8)),
[False, False, True, True, True, True, True, True, False, False])
array_eq_(s.where(type_in=['H', 'O'], within_of=(0.2, [8])),
[False, False, True, True, True, True, True, True, False, False])
示例9: test_query
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def test_query():
type_array = ['Cl', 'Cl', 'O', 'H', 'H', 'O', 'H', 'H', 'Na', 'Na']
maps = {('atom', 'molecule'): [0, 1, 2, 2, 2, 3, 3, 3, 4, 5]}
s = System.from_arrays(type_array = type_array, maps=maps)
assert_npequal(s.where(type_array=['Na', 'Cl'])['atom'],
[True, True, False, False, False, False, False, False, True, True])
assert_npequal(s.where(type_array='Cl')['atom'],
[True, True, False, False, False, False, False, False, False, False])
# We move the Cl away
cl = s.where(type_array='Cl')['atom']
s.r_array[cl.nonzero()[0]] = [1, 0, 0]
s.box_vectors = np.diag([3, 3, 3])
assert_npequal(s.where(type_array=['H', 'O'], within_of=(0.2, [8, 9]))['atom'],
[False, False, True, True, True, True, True, True, False, False])
assert_npequal(s.where(type_array=['H', 'O'], within_of=(0.2, 8))['atom'],
[False, False, True, True, True, True, True, True, False, False])
assert_npequal(s.where(type_array=['H', 'O'], within_of=(0.2, [8]))['atom'],
[False, False, True, True, True, True, True, True, False, False])
示例10: setup
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def setup(self):
self.s = System.from_arrays(
type_array=['O', 'H', 'H', 'O', 'H', 'H', 'O', 'H', 'H'],
maps={('atom', 'molecule'): [0, 0, 0, 1, 1, 1, 2, 2, 2]})
示例11: setup
# 需要导入模块: from chemlab.core import System [as 别名]
# 或者: from chemlab.core.System import from_arrays [as 别名]
def setup(self):
self.s = System.from_arrays(
type_array=["O", "H", "H", "O", "H", "H", "O", "H", "H"],
maps={("atom", "molecule"): [0, 0, 0, 1, 1, 1, 2, 2, 2]},
)