def calc_energy(self, coords): energy = self.shift for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) energy += qi*qj/bond.value(coords)*scale return energy
def calc_gradient(self, coords): grad = np.zeros(3*len(self.charges), float) for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) r = bond.value(coords) grad += -qi*qj/(r**2)*bond.grad(coords)*scale return grad
def calc_energy(self, coords): energy = self.shift for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) r = bond.value(coords) sigma = np.sqrt(self.sigmas[i]**2+self.sigmas[j]**2) energy += scale*qi*qj/r*math.erf(r/sigma) return energy
def calc_hessian(self, coords): hess = np.zeros([3*len(self.charges), 3*len(self.charges)], float) for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) r = bond.value(coords) qgrad = bond.grad(coords) hess += qi*qj/(r**2)*(2.0/r*np.outer(qgrad, qgrad) - bond.hess(coords))*scale return hess
def calc_gradient(self, coords): grad = np.zeros(3*len(coords), float) for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (bond.value(coords)/sigma) grad += scale*epsilon/sigma*(-2.208e6*np.exp(-12.0*x) + 13.5/x**7)*bond.grad(coords) return grad
def calc_energy(self, coords): energy = self.shift for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (bond.value(coords)/sigma) energy += scale*epsilon*(1.84e5*np.exp(-12.0*x) - 2.25/x**6) return energy
def calc_gradient(self, coords): grad = np.zeros(3*len(coords), float) for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (sigma/bond.value(coords)) grad -= 24.0*epsilon/sigma*(2.0*x**13-x**7)*bond.grad(coords)*scale return grad
def calc_energy(self, coords): energy = self.shift for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (sigma/bond.value(coords)) energy += 4.0*epsilon*(x**12-x**6)*scale return energy
def calc_hessian(self, coords): hess = np.zeros([3*len(coords), 3*len(coords)], float) for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (sigma/bond.value(coords)) qgrad = bond.grad(coords) hess += 24.0*epsilon/sigma**2*(26*x**14-7*x**8)*np.outer(qgrad, qgrad)*scale hess -= 24.0*epsilon/sigma*(2*x**13-x**7)*bond.hess(coords)*scale return hess
def calc_hessian(self, coords): hess = np.zeros([3*len(coords), 3*len(coords)], float) for i, (si, ei) in enumerate(zip(self.sigmas, self.epsilons)): for j, (sj, ej) in enumerate(zip(self.sigmas, self.epsilons)): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue sigma = 0.5*(si+sj) epsilon = np.sqrt(ei*ej) bond = IC('_internal_vdw_bond', [i, j], bond_length) x = (bond.value(coords)/sigma) qgrad = bond.grad(coords) dVdr = -2.208e6*np.exp(-12.0*x) + 13.5/x**7 d2Vdr2 = 2.6496e7*np.exp(-12.0*x)-94.5/x**8 hess += scale*epsilon/sigma*(d2Vdr2/sigma*np.outer(qgrad, qgrad) + dVdr*bond.hess(coords)) return hess
def calc_gradient(self, coords): grad = np.zeros(3*len(self.charges), float) for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) r = bond.value(coords) sigma = np.sqrt(self.sigmas[i]**2+self.sigmas[j]**2) #intermediate results erf = math.erf(r/sigma) exp = np.exp(-(r/sigma)**2)/np.sqrt(np.pi) #update grad grad += scale*qi*qj/r*(-erf/r + 2.0*exp/sigma)*bond.grad(coords) return grad
def calc_hessian(self, coords): hess = np.zeros([3*len(self.charges), 3*len(self.charges)], float) for i, qi in enumerate(self.charges): for j, qj in enumerate(self.charges): if j >= i: break scale = self._get_scale(i, j) if scale==0.0: continue bond = IC('_internal_ei_bond', [i, j], bond_length) r = bond.value(coords) qgrad = bond.grad(coords) sigma = np.sqrt(self.sigmas[i]**2+self.sigmas[j]**2) #intermediate results erf = math.erf(r/sigma) exp = np.exp(-(r/sigma)**2)/np.sqrt(np.pi) dVdr = (-erf/r + 2.0/sigma*exp)/r d2Vdr2 = (erf/r - 2*exp/sigma)/r**2 - 2*exp/sigma**3 #update hessian hess += scale*qi*qj*(2*d2Vdr2*np.outer(qgrad, qgrad) + dVdr*bond.hess(coords)) return hess