-
Notifications
You must be signed in to change notification settings - Fork 230
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
Several Arkane Torsion (Rotor) related changes #2268
Conversation
#2263 Just realize there is another fix for the linspace error |
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.
Thanks! Please see some minor comments
@@ -540,7 +540,7 @@ cdef class HinderedRotor(Torsion): | |||
A[:-1, m] = np.cos(m * angle) | |||
A[:-1, numterms + m - 1] = np.sin(m * angle) | |||
# This row forces dV/dangle = 0 at angle = 0 | |||
A[N, numterms:] = 1 | |||
A[N, numterms:] = np.arange(1., numterms) |
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.
I saw you related to this in the PR message, but could you please explain what this technically does?
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.
- The Fourier series to be fitted is
V = c0 + c1 cos(t) + c2 cos(2t) + c3 cos(3t) + ...cn cos(nt) + cn+1 sin(t) + cn+2 sin(2t) + ... + c2n sin(nt)
In RMG, it is fitted as a linear equation (Ac = V) to get the values of c
s, where A is a matrix containing the value of
A = [1, cos(t), cost(2t), ..., sin(t), sint(2t)]
# Each item is a column vector
However, RMG appends an extra line to the A matrix, to put an extra constraint in the fitting, which is dV/dangle = 0 at the angle of 0. If you calculate the dV/dangle, it is
dV/dangle = - c1 sin(t) - 2c2 sint(2t) - ... - ncn sin(nt) + cn+1 cos(t) + 2 cn+2 cos(2t) + .... nc2n sin(nt)
# and
dV/dangle (t=0) = cn+1 + 2cn+2 + ... + ncn2
So we need to append [ 0, 0, 0 ...., 1, 2, 3,..., n] to the A matrix instead of 1s.
Note, here n
= numterms-1
, which is due to the definition of numterms
we used. numterms
are the count for sin(0t), sin(1t), sin(2t), ...sin(nt)
(the same for cos's), and notice sin(0t) = 0
which is not included in the A matrix.
@@ -273,6 +276,7 @@ def create_log(log_path, check_for_errors=True): | |||
'True': True, | |||
'False': False, | |||
'HinderedRotor': hinderedRotor, | |||
'HinderedRotor1DArray': hinderedRotor1DArray, |
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.
Should we add this option to Arkane's documentation?
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.
Good suggestion! Let me add it.
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.
Thank you again for pointing me to the documentation. I just realize HinderedRotor
may take a text file with angles and energies stored. It turns out I never find this before...So it actually does something very similar to my addition. Do you know it is still worth adding the class HinderedRotor1DArray
? I can simply remove the last two commits then.
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.
The current option only allows to take in a list of angles and energies. Your option has more arguments. Perhaps keep the current option of passing a file to ScanLog
. We can make this file more machine-friendly by allowing one to pass a yaml file, where you can add all your args and a list of data points.
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.
As suggested, I added the support of reading csv files and yaml files using ScanLog
. For both method, I added unit tests and related descriptions in the documentation.
Thanks for the review @alongd. I made several changes as suggested:
|
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.
Thanks! I added a few minor questions
energies = df[column] | ||
return angle_unit, energy_unit, angles, energies | ||
|
||
def load_yaml(self): |
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.
Do we want to allow users to specify pivots
, top
, and fit
directly in the YAML file?
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 could but, currently, this adds no benefit since we make these arguments required for HinderedRotor
, as other file formats don't support reading the information from them. I decide to not add this into the scope of this PR.
@alongd Thank you for correcting me. I have removed those leftovers. I will squash the |
Perfect, please go ahead and rebase |
We're merging PRs even though rmg-tests fail, right? Is it being looked into? |
Previously, RMG only can load PES profiles from a QM log file. Now, creating a hindered rotor from a PES profile (angles vs energies) is possible when preparing an Arkane input file. This introduces more flexibility.
Not entirely sure about how much it is fixed. #2271 solved some of the issues related to failures in rmg-test, if not any. |
Seems like the tests fail due to an issue with RMS: @mjohnson541 , @hwpang , could you take a look? I think that principally we can merge this PR, let me know if that's acceptable with the current failing rmg-tests |
Yeah, we accidentally merged the RMS part of a PR that should've been a twin RMG-Py-RMS PR. Although, I'm not sure if RMG-tests was working before that either. It should be fine to merge this one without RMG-tests. |
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.
Thanks!
@alongd @mjohnson541 Thanks everyone's help! |
Correct the Fourier fitting Procedure. A function of the following form is to be fitted.
f(x) = 1 + a cosx + b cos2x + ... + a' sinx + b' sin2x + ...
In the fitting procedure, Arkane makes an assumption that f'(0) = 0 (last line in the regression matrix), which correspond to
f'(0) = a' + 2 b' + 3 c' ....=0.
But in the past 10 years, this was set to be
f'(0) = a' + b' + c' .. = 0.
Now, it is corrected. In terms of influence, for most PES profiles, the previous mistake won't cause problems to a curve with good shape (like the PES from -CH3). For a more problematic PES profile (like the ones whose end conformed is significantly different from the initial one), the previous fitting approach may result in a tiny well with negative energies close to the origin. I haven't quantified the influence yet, but conceptually I don't think it is significant.
Enable parse scan log files with something like
L 1 2 3 B
. Currently, Arkane doesn't recognize this internal coordinate definition and will raise errors when parsing the file. So the 'L' defines a linear bend which can be helpful when there are ~180 angles in the molecule. Now, Arkane will simply pass the lines starting with an 'L'.Enable Assign PES (angles vs energies) directly in the Arkane input file. Previously, Arkane can only read the profile from a QM output. The new feature introduces more flexibility when conducting scan jobs, especially when you need to combine some results together. E.g., you may have a job stop in the midway, or you want to run jobs at each scan point separately, or if you want to combine PES profiles from both forward and backward scans, now after your jobs, you can simply prepare a list of angle, and a list of energies, and fit them to the Arkane. A Unit test corresponding to this feature is also added.
Fix a minor np.linspace argument issue. [fixed in another PR, removed the commit in this PR]