-
Notifications
You must be signed in to change notification settings - Fork 8
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
cartesian_to_irc produces 180 degree dihedrals with random sign #52
Comments
Okay, my trick does have a knock on. My own plaster outside libirc still works though, Something more is required. Your input would be appreciated. As an example from my code when validating the back transform. Observe the values flipped sign for coordinate 22 and 27 , so the error is 2pi when it should have been 0 or close.
It would easy enough to add the ethane test case to your tests. I haven't done that to see what happens. Cheers. |
I think you should be determining all differences (including "error" column) in dihedral angles in the |
The reproducibility of the values is a little more concerning, one should be able to write a test just in the IRC library that confirms there is a problem. |
Agreed. I added a test with ethane where @AlexB67 could you please provide a bit more information on the system and the functions you are calling so that I can try to reproduce the issue? If I use the following cartesian coordinates (in angstrom)
I consistently get the following internal coordinates for the dihedral angles (in radians):
Are you talking about successive back and forth transformations? |
Hi, Thanks for replying. Leave it with me. I would hate to discover it;s something on my end I am doing. I understanding the code base bit by bit. When I have a bit of time, it'll require a strong coffee, and make sure I understand it better. Yes, I am talking about successive back and forth. Please don't spend any time on my behalf on it until I have a better understanding. Best ... |
Yes, I had considered that It was a kind of temporary thing to experiment if it worked around the near 180 case in my geometry optimization, so for now I changed nothing in libirc I thought i had a bug in my BFGS step, but I don't, that's how I came to discover the whole thing. All the updates for RFO, ,BFGS Hessian matched the output of Psi4 once i just kept track of the sign flips in my own code, but it's probably not 100% full proof. Best ... |
I'll also do this. i'll keep you posted. Thx. |
@AlexB67 I added a small test for consecutive forward and backward transformations (this is where the error appears if I understand correctly?) as follows: const vec irc_0 = cartesian_to_irc<vec3, vec>(x_c, B, A, D, LA, OOPB);
vec irc = irc_0;
size_t n_irc = irc.size();
// Small test on reproducibility, related to issue #52
for(std::size_t n{0}; n < 100; n++){
auto result = irc_to_cartesian<vec3, vec, mat>(
irc, linalg::zeros<vec>(n_irc), x_c, B, A, D, LA, OOPB);
REQUIRE(result.converged);
const vec x_c_new = result.x_c;
irc = cartesian_to_irc<vec3, vec>(x_c_new, B, A, D, LA, OOPB);
// Check IRC are the same as the first one
REQUIRE(irc.size() == irc_0.size());
for(size_t i{0}; i < n_irc; i++){
CHECK(irc(i) == Approx(irc_0(i)));
}
} Unfortunately, it does not seem to reproduce the problem (internal coordinates always match the first conversion). Please correct me if I am misunderstanding the problem, but without more details on how to reproduce it in the library it will be tricky to pinpoint the issue. |
You are understanding it perfectly. I'll dig deeper. thx for that. |
Hello, Not had much time, but what I found thus far. The inconsistent signs happen as the structure changes during a geometry optimization which is not captured in the above test. This has led me to the following test. I have taken two structures, one has been optimized previously, not the other, They are both D3d. Taking either as just an input structure the following happens. (Note: No geometry optimization happening here in the current run). Generate internal coordinates using optimized structure 2 as input. Dihedrals are reported like so
Using the original unoptimized structure 1 as input
The sign flips are happening in cartesian_to_irc. Where In some cases it generates a -180 angle for structure X, but +180 for structure Y. My gut says that since the dihedral angles are not changing it this structure, apart from some numerical noise during optimization. The signs should stay consistent, but they are not. my fault ? libirc ? Don't know yet. In any case, the above test is independent of any geometry optimization, I am just reporting the libirc internal coordinates given a Cartesian input structure. Any thoughts on the different reported dihedrals for both structures. It's only the 180 degree case. Other angles are reported consistently. I've not made an isolated test case in libirc to double check. Cheers |
Okay. I added 2 structures to the test suite to isolate it from my code. I get the same results. I've experimented with the internals of irc a bit, but no cigar as yet. I suppose, one question that arises, should dihedrals need to have a negative sign at all. The WDC convention is for dihedrals to be always positive. |
@AlexB67 Thanks for the additional details, are the test available somewhere? If you could open a PR against the (I don't have a lot of spare time this week, so it might take a while.) |
Hi, |
FWIW The closest I have come as a code smell fix. Adding this one line to the connectivity function for dihedrals, though it can induce very small rounding errors transforming to and from irc to cartesian, in practice quite negligible I think. All your test still pass with this change, including my new one, and my own code behaves without requiring my current plaster outside libirc, I admit I don't feel comfortable about doing it this way. Making dihedral angles other than 180 all positive as per WDC convention makes everything go bust, more serious intervention would be required. The reason the sign flips is the atan2(y/x) call sometimes has a value of -0 or +0 for y in the numerator for the different structures. That's all I can offer this week. // Code smell addition
// end code smell Cheers :) |
Hello, I hope I can explain this right, but I observed the issue as described in the title. Take ethane as an example. it produces the following coordinates:
If you run cartesian_to_iirc successive times the outcome of the 180 dihedral angles flip sign. it may give
or sometimes
but only for the 180 degree case.
As you can imagine this can pay havoc with geometry optimization because dihedrals that have flipped 360 degrees during a geometry optimization step can give rogue values for dq,
one can get dq = 2 pi when it should have been dq = 0, or something very small.
Yesterday, I put a plaster in my own code to detect this flip, so I could work around the issue. Of course, it would be nice to see what the issue in libirc is.
Thus far, I've made the following change; It works in all my tests so far, but not knowing your code base very well I don't if there could be unwanted consequences
In constsnts.h I added
and in connectivity.h I changed the following lines, around 440 thereabouts
What do you think ?
Best regards.
oh ad thanks for the library, great stuff.
The text was updated successfully, but these errors were encountered: