bio-phys / pydhamed Goto Github PK
View Code? Open in Web Editor NEWDynamic Histogram Analysis To Determine Free Energies and Rates from Biased Simulations
License: BSD 3-Clause "New" or "Revised" License
Dynamic Histogram Analysis To Determine Free Energies and Rates from Biased Simulations
License: BSD 3-Clause "New" or "Revised" License
Use Travis CI to run tests automatically :-)
Add GLIC ion-permeation channel example Jupyter.
ZeroDivisionError Traceback (most recent call last)
<ipython-input-36-882a6db4a90e> in <module>()
----> 1 og = run_dhamed(c_l, -np.log(v_ar), g_init=og, numerical_gradients=False, last_g_zero=True)
/Users/lukas/Projects/DHAMed/public-dhamed/PyDHAMed/pydhamed/optimize_dhamed.pyc in grad_dhamed_likelihood_ref_0(g_prime, g, ip, jp, ti, tj, vi, vj, nk, nijp)
88 grad = np.zeros(g.shape[0] )
89 grad[:-1] += nk[:-1]
---> 90 grad = loop_grad_dhamed_likelihood_0(grad,g, ip, jp, ti, tj, vi, vj, nijp)
91 return grad[:-1]
92
ZeroDivisionError: division by zero
Hi,
I wanted to make sure that I understand the definition of the bias potential matrix correctly.
Assuming an umbrella sampling experiment with 4 windows A, B, C, D and 3 states 0, 1, 2. The restraining potential defined as k*(x-x0)^2. Should the cell A0 contain the following?
x=median value of bin 0,
x0=target value of window A
Dear Lukas,
thanks a lot for providing the software to DHAMed.
I am trying to use the program with the following test data:
traj=np.array([0., 0., 1., 2., 1., 0., 2., 2.])
c_l = [count_matrix(traj,n_states=3)]
v_ar=np.array([1, 1.5, 2]).reshape(3,1)
I get the following error:
File "dhamed.py", line 17, in
bl_g = run_dhamed(c_l, -np.log(v_ar))
....
....
InternalError: unsupported array index type float64 in [float64]
[1] During: typing of intrinsic-call at /home/andt88/miniconda2/lib/python2.7/site-packages/pydhamed/optimize_dhamed.py (21)
--%<-----------------------------------------------------------------
File "../../../../miniconda2/lib/python2.7/site-packages/pydhamed/optimize_dhamed.py", line 21
Dear Lukas
I am trying to use PyDHAMed to compute a PMF for a small molecule crossing a membrane bilayer. I performed umbrella sampling in 1.5ร windows, spanning approx. 7nm (57 umbrellas in total).
Following your code, I first created the list of transition matrices for each of the umbrellas:
def create_transition_matrix(traj: npt.NDArray, microstates: npt.NDArray)->npt.NDArray:
"""
Parameters
--------------
traj: np.array of size n
microstates: np.array of size m
First, the trajectory is binned into the provided
microstates. Next, a transition matrix is calculated
giving the number of transitions between each of the
microstates.
Returns: m x m matrix with the transitions between
all possible pairs of bins in subsequent trajectory frames.
"""
traj_binned = np.digitize(traj, microstates)
n_states = microstates.shape[0]+1 # digitize is 1 indexed.
mat = np.zeros((n_states, n_states))
for (x, y), c in six.iteritems(Counter(zip(traj_binned[:-1], traj_binned[1:]))):
mat[int(y), int(x)] = c
return mat
colvar_files = glob.glob("../gromacs/plumed_us_*-colvar.dat")
transition_matrices = list()
for i, f in enumerate(colvar_files):
print("Processing trajectory: ", f)
traj = np.loadtxt(f)[500:, 1]
transition_matrices.append(create_transition_matrix(traj, microstates)[1:, 1:])
with open("NFP_membrane_transition_counts.pickle", "wb") as outfile:
pickle.dump(transition_matrices, outfile)
Next, I calculated the bias grid (in kBT units) as follows:
def create_biasses(q0, kappa, microstates)->npt.NDArray:
bias = (0.5 * force_constants[:, np.newaxis] * (centers[:, np.newaxis] - microstates)**2).T
# convert to kBT
return (bias*1000)/(R*T)
#col0 = bias number
#col1 = bias center position
#col2 = bias force constant
umbrellas = np.loadtxt("../gromacs/wham_input.txt", skiprows=1)
centers = umbrellas[:, 1]
force_constants = umbrellas[:, 2]
biasses = create_biasses(centers, force_constants, microstates)
np.save("NFP_membrane_biasses.npy", biasses)
, where the input file simply contains the centers and force constants of the harmonic potentials. But when I try to use run_dhamed
I cannot seem to get sensible results. When I use jit_gradient=False
, the calculation finished but I do not get a sensible result (see figure).
When I use jit_gradient=True
, I get a division by zero error at '_loop_grad_dhamed_likelihood_0'. Would you have an idea of what is going wrong?
Best,
Warre
*Enable users to run binless WHAM in the same framework as DHAMed.
To do:
I have performed an Umbrella Sampling analysis on a membrane system in gromacs. My collective variable is the distance of a small molecule from the center of a membrane. Using the pullf file generated from gromacs how would I go about generating the bias force matrix for each of my 80 US windows?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.