本文整理匯總了Python中MMTK.Utility.normalizePair方法的典型用法代碼示例。如果您正苦於以下問題:Python Utility.normalizePair方法的具體用法?Python Utility.normalizePair怎麽用?Python Utility.normalizePair使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MMTK.Utility
的用法示例。
在下文中一共展示了Utility.normalizePair方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: addBondTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addBondTerm(self, data, bond, object, global_data):
a1 = bond.a1
a2 = bond.a2
i1 = a1.index
i2 = a2.index
global_data.add('excluded_pairs', Utility.normalizePair((i1, i2)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
try:
p = self.dataset.bondParameters(t1, t2)
except KeyError:
raise KeyError(('No parameters for bond %s (atom type %s)' +
' - %s (atom type %s)') % (str(a1), t1,
str(a2), t2))
if p is not None and p[1] != 0.:
data.add('bonds', (i1, i2, p[0], p[1]*self.scale_factor))
示例2: addBondTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addBondTerm(self, data, bond, object, global_data):
if not self.arguments[0]:
return
a1 = bond.a1
a2 = bond.a2
i1 = a1.index
i2 = a2.index
global_data.add('excluded_pairs', Utility.normalizePair((i1, i2)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
try:
p = self.dataset.bondParameters(t1, t2)
except KeyError:
raise KeyError('No parameters for bond ' + `a1` + '--' + `a2`)
if p is not None:
d = data.get('universe').distance(a1, a2)
data.add('bonds', (i1, i2, d, p[1]))
示例3: evaluatorParameters
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def evaluatorParameters(self, universe, subset1, subset2, global_data):
if universe.is_periodic and \
(len(self.atom_indices_1) > 1 or len(self.atom_indices_1) > 1):
raise ValueError("Center-of-mass restraints not implemented"
" for periodic universes")
ok = False
for s1, s2 in [(subset1, subset2), (subset2, subset1)]:
if s1 is None and s1 is None:
ok = True
break
s1 = set(a.index for a in s1.atomIterator())
diff1 = set(self.atom_indices_1).difference(s1)
s2 = set(a.index for a in s2.atomIterator())
diff2 = set(self.atom_indices_2).difference(s2)
if not diff1 and not diff2:
# Each object is in one of the subsets
ok = True
break
if (diff1 and len(diff1) != len(self.atom_indices_1)) \
or (diff2 and len(diff2) != len(self.atom_indices_2)):
# The subset contains some but not all of the
# restrained atoms.
raise ValueError("Restrained atoms partially "
"in a subset")
global_data.add('initialized', self.__class__)
if not ok:
# The objects are not in the subsets, so there is no
# contribution to the total energy.
return {'harmonic_distance_cm': []}
if self.nb_exclusion:
assert len(self.atom_indices_1) == 1
assert len(self.atom_indices_2) == 1
i1 = self.atom_indices_1[0]
i2 = self.atom_indices_2[0]
global_data.add('excluded_pairs', Utility.normalizePair((i1, i2)))
if len(self.atom_indices_1) == 1 and len(self.atom_indices_2) == 1:
# Keep the old format for the single-atom case for best
# compatibility with older MMTK versions.
return {'harmonic_distance_term':
[(self.atom_indices_1[0], self.atom_indices_2[0],
self.distance, self.force_constant)]}
else:
return {'harmonic_distance_cm':
[(self.atom_indices_1, self.atom_indices_2,
self.distance, self.force_constant)]}
示例4: addBondAngleTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addBondAngleTerm(self, data, angle, object, global_data):
a1 = angle.a1
a2 = angle.a2
ca = angle.ca
i1 = a1.index
i2 = a2.index
ic = ca.index
global_data.add('excluded_pairs', Utility.normalizePair((i1, i2)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
tc = global_data.atom_type[ca]
try:
p = self.dataset.bondAngleParameters(t1, tc, t2)
except KeyError:
raise KeyError(('No parameters for angle %s (atom type %s)' +
' - %s (atom type %s) - %s (atom type %s)')
% (str(a1), t1, str(ca), tc, str(a2), t2))
if p is not None and p[1] != 0.:
data.add('angles', (i1, ic, i2, p[0], p[1]*self.scale_factor))
示例5: addDihedralTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addDihedralTerm(self, data, dihedral, object, global_data):
a1 = dihedral.a1
a2 = dihedral.a2
a3 = dihedral.a3
a4 = dihedral.a4
i1 = a1.index
i2 = a2.index
i3 = a3.index
i4 = a4.index
global_data.add('1_4_pairs', Utility.normalizePair((i1, i4)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
t3 = global_data.atom_type[a3]
t4 = global_data.atom_type[a4]
terms = self.dataset.dihedralParameters(t1, t2, t3, t4)
if terms is not None:
for p in terms:
if p[2] != 0.:
data.add('dihedrals', (i1, i2, i3, i4,
p[0], p[1], p[2]*self.scale_factor))
示例6: addBondAngleTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addBondAngleTerm(self, data, angle, object, global_data):
if not self.arguments[1]:
return
a1 = angle.a1
a2 = angle.a2
ca = angle.ca
i1 = a1.index
i2 = a2.index
ic = ca.index
global_data.add('excluded_pairs', Utility.normalizePair((i1, i2)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
tc = global_data.atom_type[ca]
try:
p = self.dataset.bondAngleParameters(t1, tc, t2)
except KeyError:
raise KeyError('No parameters for angle ' + `a1` +
'--' + `ca` + '--' + `a2`)
if p is not None:
v1 = a1.position()-ca.position()
v2 = a2.position()-ca.position()
angle = v1.angle(v2)
data.add('angles', (i1, ic, i2, angle) + p[1:])
示例7: addDihedralTerm
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import normalizePair [as 別名]
def addDihedralTerm(self, data, dihedral, object, global_data):
if not self.arguments[2]:
return
a1 = dihedral.a1
a2 = dihedral.a2
a3 = dihedral.a3
a4 = dihedral.a4
i1 = a1.index
i2 = a2.index
i3 = a3.index
i4 = a4.index
global_data.add('1_4_pairs', Utility.normalizePair((i1, i4)))
t1 = global_data.atom_type[a1]
t2 = global_data.atom_type[a2]
t3 = global_data.atom_type[a3]
t4 = global_data.atom_type[a4]
terms = self.dataset.dihedralParameters(t1, t2, t3, t4)
if terms is not None:
v1 = a1.position()-a2.position()
v2 = a2.position()-a3.position()
v3 = a4.position()-a3.position()
a = v1.cross(v2).normal()
b = v3.cross(v2).normal()
cos = a*b
sin = b.cross(a)*v2/v2.length()
dihedral = Transformation.angleFromSineAndCosine(sin, cos)
if dihedral > N.pi:
dihedral -= 2.*N.pi
for p in terms:
if p[2] != 0.:
mult = p[0]
phase = N.fmod(N.pi-mult*dihedral, 2.*N.pi)
if phase < 0.:
phase += 2.*N.pi
data.add('dihedrals', (i1, i2, i3, i4,
p[0], phase) + p[2:])