本文整理汇总了Python中molecule.Molecule.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.copy方法的具体用法?Python Molecule.copy怎么用?Python Molecule.copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unit_conversion_symmetry
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import copy [as 别名]
def test_unit_conversion_symmetry(self):
"""
Does converting back and forth between bohrs and angstroms introduce and compound rounding errors? Each
operation should exactly reverse its counterpart.
"""
with open('../../extra-files/molecule.xyz', 'r') as file1:
mol1 = Molecule(file1.read())
mol2 = mol1.copy()
for count in range(10000) :
mol2.to_bohr()
mol2.to_angstrom()
self.assertEqual(mol1.geom, mol2.geom)
示例2: test_unit_conversion_accuracy
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import copy [as 别名]
def test_unit_conversion_accuracy(self):
"""
1.0 Angstrom is approximately 1.889725989 Bohr. Is this conversion (and its reverse) carried out correctly?
"""
with open('../../extra-files/molecule.xyz', 'r') as file1:
mol1 = Molecule(file1.read())
mol2 = mol1.copy()
mol2.to_bohr()
for i in range(mol1.natom) :
self.assertAlmostEqual(mol1.geom[i][0] * 1.889725989, mol2.geom[i][0])
self.assertAlmostEqual(mol1.geom[i][1] * 1.889725989, mol2.geom[i][1])
self.assertAlmostEqual(mol1.geom[i][2] * 1.889725989, mol2.geom[i][2])
示例3: test_copy_function
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import copy [as 别名]
def test_copy_function(self):
"""
Does the copy function correctly initialize all variables of a new molecule? Also, is the new molecule
truly a different object? (ie: changing properties of the original does not affect the copy and vice versa)?
"""
with open('../../extra-files/molecule.xyz', 'r') as file1:
mol1 = Molecule(file1.read())
mol2 = mol1.copy()
self.assertEqual(mol1.units, mol2.units, 'checking units')
self.assertEqual(mol1.natom, mol2.natom, 'checking natom')
self.assertEqual(mol1.labels, mol2.labels, 'checking labels')
self.assertEqual(mol1.masses, mol2.masses, 'checking masses')
self.assertEqual(mol1.charges, mol2.charges, 'checking charges')
self.assertEqual(mol1.geom, mol2.geom, 'checking geometry')
mol2.to_bohr()
self.assertNotEqual(mol1.units, mol2.units)
self.assertNotEqual(mol1.geom, mol2.geom)
示例4: float
# 需要导入模块: from molecule import Molecule [as 别名]
# 或者: from molecule.Molecule import copy [as 别名]
out = float(match[0].split()[-1])
return out
#### Run reference configuration ####
make_input("X0X0_00",mol.atoms,mol.geom)
run_input("X0X0_00")
#### Run single displacements ####
for i in range(3*N):
forward = "X%dX0_10" % i
reverse = "X%dX0_-10" % i
geom_copy = mol.copy().geom
geom_copy[i/3,i%3] +=h
make_input(forward,mol.atoms,geom_copy)
geom_copy[i/3,i%3] -= 2*h
make_input(reverse,mol.atoms,geom_copy)
run_input(forward)
run_input(reverse)
#### Run double displacements ######
for i in range(3*N):
for j in range(i):