You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am playing with the hydrogen bond lifetime function. I have molecules of sugar in the simulation box and around 600 molecules of water. I tried to calculate the hydrogen bond lifetime of only the bonds between the sugar oxygens and water, for example:
ids = [238, 239, 240, 243, 244, 245]
for id_val in ids:
hbonds_oxygen_water = HBA(universe=u,
between=['resname SOL', f'resname B00 and id {id_val}'],
d_a_cutoff=3.0,
d_h_a_angle_cutoff=120
)
sorbitol_hydrogen_donors_sel = f"resname B00 and id {id_val}"
sorbitol_hydrogens_sel = hbonds_oxygen_water.guess_hydrogens("resname B00")
sorbitol_acceptors_sel = hbonds_oxygen_water.guess_acceptors("resname B00")
water_hydrogens_sel = "resname SOL and name HW1 HW2"
water_acceptors_sel = "resname SOL and name OW"
water_hydrogen_donors_sel = "resname SOL and name OW"
hbonds_oxygen_water.hydrogens_sel = f"({sorbitol_hydrogens_sel}) or ({water_hydrogens_sel})"
hbonds_oxygen_water.acceptors_sel = f"({sorbitol_acceptors_sel}) or ({water_acceptors_sel})"
hbonds_oxygen_water.donors_sel = f"({sorbitol_hydrogen_donors_sel}) or ({water_hydrogen_donors_sel})"
hbonds_oxygen_water.run(verbose=True)
hbonds_sorbitol_water_per_frame = hbonds_oxygen_water.count_by_time()
average_hb_count_sorbitol_water = np.mean(hbonds_sorbitol_water_per_frame)
print(f"Average number of hydrogen bonds with water (ID {id_val}): {average_hb_count_sorbitol_water}")
print(f"Total number of hydrogen bonds with water (ID {id_val}): {np.sum(hbonds_sorbitol_water_per_frame)}")
tau_max = 40
window_step = 1
tau_frames, hbond_lifetime_sorbitol_water = hbonds_oxygen_water.lifetime(
tau_max=tau_max,
window_step=window_step
)
params_water, fit_t_water, fit_ac_water = fit_biexponential(tau_frames, hbond_lifetime_sorbitol_water)
tau_times = tau_frames * u.trajectory.dt
A, tau1, B, tau2 = params_water
time_constant = A * tau1 + B * tau2
print(f"Relevant lifetime for ID {id_val}: {time_constant:.2f} ps")
I do something similar for the intramolecular hydrogen bonds related to these oxygens. However, sometimes I get too high values in this case; for example, 179458,59 ps, which is bigger than the simulation time (5 ns). I wanted to know if I'm doing something wrong? What is the physical meaning of such a value?
The function I'm using is:
def fit_biexponential(tau_timeseries, ac_timeseries):
"""Fit a biexponential function to a hydrogen bond time autocorrelation function
Return the two time constants
"""
from scipy.optimize import curve_fit
def model(t, A, tau1, B, tau2):
"""Fit data to a biexponential function.
"""
return A * np.exp(-t / tau1) + B * np.exp(-t / tau2)
params, params_covariance = curve_fit(model, tau_timeseries, ac_timeseries, [1, 0.5, 1, 2], maxfev=100000)
fit_t = np.linspace(tau_timeseries[0], tau_timeseries[-1], 1000)
fit_ac = model(fit_t, *params)
return params, fit_t, fit_ac
And the code for intramolecular hydrogen bonds is pretty much the same, only changing:
for id_val in ids:
hbonds_oxygen_intra = HBA(universe=u,
between=['resname B00', f'resname B00'],
d_a_cutoff=3.0,
d_h_a_angle_cutoff=120
)
sorbitol_hydrogen_donors_sel = f"resname B00 and id {id_val}"
sorbitol_hydrogens_sel = hbonds_oxygen_intra.guess_hydrogens("resname B00")
sorbitol_acceptors_sel = hbonds_oxygen_intra.guess_acceptors("resname B00")
hbonds_oxygen_intra.hydrogens_sel = f"({sorbitol_hydrogens_sel})"
hbonds_oxygen_intra.acceptors_sel = f"({sorbitol_acceptors_sel})"
hbonds_oxygen_intra.donors_sel = f"({sorbitol_hydrogen_donors_sel})"
hbonds_oxygen_intra.run(verbose=True)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
I am playing with the hydrogen bond lifetime function. I have molecules of sugar in the simulation box and around 600 molecules of water. I tried to calculate the hydrogen bond lifetime of only the bonds between the sugar oxygens and water, for example:
I do something similar for the intramolecular hydrogen bonds related to these oxygens. However, sometimes I get too high values in this case; for example, 179458,59 ps, which is bigger than the simulation time (5 ns). I wanted to know if I'm doing something wrong? What is the physical meaning of such a value?
The function I'm using is:
And the code for intramolecular hydrogen bonds is pretty much the same, only changing:
Thank you very much: :-)
Beta Was this translation helpful? Give feedback.
All reactions