-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix remaining GeometryEngine issues #51
Conversation
Ok, I have now implemented the reverse torsion logp. |
Oops! stray imports from experimentation last night. Removed. |
I think there are also some unit errors... please stand by... |
Looks like I am calculating an excessive number of jacobians... |
Ok. It runs now without error. However, the final energy is pretty bad. I'm going to head home soon and take a look at a pdb of the output to see what is up with that. |
Do you mean this is slow in profiling, or you are just computing more than
you need?
|
I meant that I had accidentally deleted the |
So, computing more than I needed. It's also slow, though. |
Hm, also it looks like there is an issue with integer division here. 1/17 is unfortunately 0, so I've changed 1 to 1.0 there. |
Reviewing PR now! |
logp_r = self._bond_logp(r_proposed, bond, top_proposal.beta) | ||
r_proposed = self._propose_bond(bond, beta) | ||
bond_k = bond.type.k*units.kilocalorie_per_mole/units.angstrom**2 | ||
sigma_r = units.sqrt(1/beta*bond_k) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 1/(beta*bond_k)
, which is different from what you have which maps to (1/beta)*bond_k
Removing the |
Ok, update:
|
Progress! |
Could you check in your fixes when you get a chance? |
Yeah, sorry--forgot to do that. I still have to clean up the tests, but it looks like the coordinate conversion actually works now. I constructed a minimal OpenMM system of four particles, and added custom bond, angle, and torsion forces to them, where the potential was just the bond, angle, and torsion angle, respectively.
|
Hooray! So things might work now for actual molecules? |
Unfortunately, that doesn't seem to be the case. I'm not sure what the deal is here--the coordinates are clearly converted correctly during the proposal, and the potentials seem to be implemented correctly. Is it possible that we can't capture the geometry of a methyl group by proposing only one atom at a time? |
Have you tried some totally planar molecules? Like toluene to phenol,
where an -H is replaced with an -OH?
|
I did try it, yeah. That is also problematic, though possibly due to ignoring improper torsions in the potential. We should probably, as you said earlier, add these in, but I think maybe a refactor should precede that. |
Ethene to ethene-1,2-diol would be free of the improper issue.
|
We've still got a bug somewhere. I am running It looks like
|
Here's the first proposal, which shows that angle (1,3,2) is proposed as 114 degrees but then measured to be 65 degrees in the subsequent energy calculations. This is our primary problem.
|
@@ -650,10 +646,15 @@ def _calculate_angle(self, atom_position, bond_atom_position, angle_atom_positio | |||
b = angle_atom_position - bond_atom_position | |||
a_u = a / np.linalg.norm(a) | |||
b_u = b / np.linalg.norm(b) | |||
theta = np.arccos(np.dot(a_u, b_u)) | |||
cos_theta = np.dot(a_u, b_u) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the bug. Because of the way you define a
and b
vectors, this should be
cos_theta = np.dot(-a_u, b_u)
Looks like some unit thing is a problem in one of the tests. Working on that. |
bond_position = units.Quantity(np.array([ 0.0765, 0.1 , -0.4005]), unit=units.nanometers) | ||
angle_position = units.Quantity(np.array([ 0.0829 , 0.0952 ,-0.2479]) ,unit=units.nanometers) | ||
torsion_position = units.Quantity(np.array([-0.057 , 0.0951 ,-0.1863] ) ,unit=units.nanometers) | ||
rtp, detJ = geometry_engine._cartesian_to_internal(atom_position, bond_position, angle_position, torsion_position) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your documentation for _cartesian_to_internal
says:
Returns without units!
but then you feed the unitless r
into _internal_to_cartesian
which immediately removes units from r
, assuming it is unit-bearing.
We will need some way to be more consistent with units in a refactoring PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need some way to be more consistent with units in a refactoring PR.
Agreed. The error in the current build is due to a different issue with units, though this is also a problem
Ok, right now it looks like the only problem in the tests is the I should clarify that the problem is an exception caused by an incorrectly written test. |
Also need to restore the Jacobian calculation--leaving this here as a note to myself. |
Passes! Going to merge. |
Fix remaining GeometryEngine issues
As discussed in #49, there are some outstanding issues in the
GeometryEngine
. Currently:logp
have been converted tologq
, so that the exponentiated version of it is the unnormalized probability density.scipy.stats
logq
What remains: