customHbondForce cannot take tabulated functions with defined indexes.
Posted: Thu Dec 20, 2018 8:28 pm
Hi Peter,
I met with this problem when I tried to implement a position dependent Hydrogen Bonding term in openmm. However, I met with the problem of "unknown particle res_i". I don't have this problem when I access tabulated functions in other custom forces before. Is hydrogen bonding term different from other custom forces?
Many thanks in advance.
Sincerely,
Here is the code:
def beta_term_1(self, k_beta = 0.25*4.184):
print("new beta_1 term ON");
r_ON = .298
sigma_NO = .068
r_OH = .206
sigma_HO = .076
lambda_1 = np.zeros((self.nres, self.nres))
for i in range(self.nres):
for j in range(self.nres):
lambda_1[j] = self.get_lambda_by_index(i, j, 0);
theta_ij = f"exp(-(r_Oi_Nj-{r_ON})^2/(2*{sigma_NO}^2)-(r_Oi_Hj-{r_OH})^2/(2*{sigma_HO}^2))"
beta_string_1 = f"-k_beta*lambda_1(res_i,res_j)*theta_ij;theta_ij={theta_ij};r_Oi_Nj=distance(d1,a1);r_Oi_Hj=distance(d1,a2);"
beta_1 = CustomHbondForce(beta_string_1);
beta_1.addGlobalParameter("k_beta", k_beta)
beta_1.addPerDonorParameter("res_i");
beta_1.addPerAcceptorParameter("res_j");
beta_1.addTabulatedFunction("lambda_1", Discrete2DFunction(self.nres, self.nres, lambda_1.T.flatten()))
print(lambda_1)
for i in range(2):
if self.o!= -1:
beta_1.addDonor(self.o, -1, -1, );
if self.n!=-1 and self.h!=-1:
beta_1.addAcceptor(self.n, self.h, -1, )
beta_1.setCutoffDistance(1.0);
beta_1.setForceGroup(23)
return beta_1
I met with this problem when I tried to implement a position dependent Hydrogen Bonding term in openmm. However, I met with the problem of "unknown particle res_i". I don't have this problem when I access tabulated functions in other custom forces before. Is hydrogen bonding term different from other custom forces?
Many thanks in advance.
Sincerely,
Here is the code:
def beta_term_1(self, k_beta = 0.25*4.184):
print("new beta_1 term ON");
r_ON = .298
sigma_NO = .068
r_OH = .206
sigma_HO = .076
lambda_1 = np.zeros((self.nres, self.nres))
for i in range(self.nres):
for j in range(self.nres):
lambda_1[j] = self.get_lambda_by_index(i, j, 0);
theta_ij = f"exp(-(r_Oi_Nj-{r_ON})^2/(2*{sigma_NO}^2)-(r_Oi_Hj-{r_OH})^2/(2*{sigma_HO}^2))"
beta_string_1 = f"-k_beta*lambda_1(res_i,res_j)*theta_ij;theta_ij={theta_ij};r_Oi_Nj=distance(d1,a1);r_Oi_Hj=distance(d1,a2);"
beta_1 = CustomHbondForce(beta_string_1);
beta_1.addGlobalParameter("k_beta", k_beta)
beta_1.addPerDonorParameter("res_i");
beta_1.addPerAcceptorParameter("res_j");
beta_1.addTabulatedFunction("lambda_1", Discrete2DFunction(self.nres, self.nres, lambda_1.T.flatten()))
print(lambda_1)
for i in range(2):
if self.o!= -1:
beta_1.addDonor(self.o, -1, -1, );
if self.n!=-1 and self.h!=-1:
beta_1.addAcceptor(self.n, self.h, -1, )
beta_1.setCutoffDistance(1.0);
beta_1.setForceGroup(23)
return beta_1