def test_altint(self, molfrag): R = molfrag.R rMP = ref.rMP diff = [(1, 2), (3, 4), (5, 6)] bonds = (1, 3, 4) ablab = ("O", "H1O", "H1", "H2O", "H2H1", "H2") ijlab = ("xx", "yx", "yy", "zx", "zy", "zz") pol = np.zeros((6, molfrag.noa * (molfrag.noa + 1) // 2)) for ab, a, b in pairs(molfrag.noa): for ij, i, j in pairs(3): i1, i2 = diff[i] j1, j2 = diff[j] pol[ij, ab] += ( rMP[i + 1, j1, ab] - rMP[i + 1, j2, ab] + rMP[j + 1, i1, ab] - rMP[j + 1, i2, ab] ) / (4 * ref.ff) if ab in bonds: pol[ij, ab] -= ( (R[a][i] - R[b][i]) * (rMP[0, j1, ab] - rMP[0, j2, ab]) / (2 * ref.ff) ) self.assert_allclose( ref.Aab[ij, ab], pol[ij, ab], text="%s%s" % (ablab[ab], ijlab[ij]) )
def test_quadrupole_allbonds(self): QU = full.matrix(ref.QU.shape) QUab = self.m.QUab for ab, a, b in pairs(self.m.noa): QU[:, ab] += QUab[:, a, b ] if a != b: QU[:, ab] += QUab[:, b, a] self.assert_allclose(QU, ref.QU)
def test_dipole_allbonds(self): D = full.matrix(ref.D.shape) Dab = self.m.Dab for ab, a, b in pairs(self.m.noa): D[:, ab] += Dab[:, a, b ] if a != b: D[:, ab] += Dab[:, b, a] self.assert_allclose(D, ref.D)
def test_dipole_allbonds(self, molfrag): D = full.matrix(ref.D.shape) Dab = molfrag.Dab for ab, a, b in pairs(molfrag.noa): D[:, ab] += Dab[:, a, b] if a != b: D[:, ab] += Dab[:, b, a] self.assert_allclose(D, ref.D)
def test_quadrupole_allbonds(self, molfrag): QU = full.matrix(ref.QU.shape) QUab = molfrag.QUab for ab, a, b in pairs(molfrag.noa): QU[:, ab] += QUab[:, a, b] if a != b: QU[:, ab] += QUab[:, b, a] self.assert_allclose(QU, ref.QU)
def test_altint(self): R = self.m.R rMP = ref.rMP diff = [(1, 2), (3, 4), (5, 6)] atoms = (0, 2, 5) bonds = (1, 3, 4) ablab = ("O", "H1O", "H1", "H2O", "H2H1", "H2") ijlab = ("xx", "yx", "yy", "zx", "zy", "zz") pol = np.zeros((6, self.m.noa*(self.m.noa+1)//2)) for ab, a, b in pairs(self.m.noa): for ij, i, j in pairs(3): #from pdb import set_trace; set_trace(self) i1, i2 = diff[i] j1, j2 = diff[j] pol[ij, ab] += (rMP[i+1, j1, ab] - rMP[i+1, j2, ab] + rMP[j+1, i1, ab] - rMP[j+1, i2, ab])/(4*ref.ff) if ab in bonds: pol[ij, ab] -= (R[a][i]-R[b][i])*(rMP[0, j1, ab] - rMP[0, j2, ab])/(2*ref.ff) self.assert_allclose(ref.Aab[ij, ab], pol[ij, ab], text="%s%s"%(ablab[ab], ijlab[ij]))