-
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
Derive the frequency scaling factor in Arkane from the frequency level #1612
Conversation
53686fa
to
bf43243
Compare
Codecov Report
@@ Coverage Diff @@
## master #1612 +/- ##
======================================
Coverage 41.6% 41.6%
======================================
Files 176 176
Lines 29142 29142
Branches 5990 5990
======================================
Hits 12125 12125
Misses 16173 16173
Partials 844 844 Continue to review full report at Codecov.
|
I changed the default behaviour if the freq scale factor isn't found, back to what it was before this PR: of setting it to 1 and warning the user instead of crushing. I think it makes more sense because there are cases where the user doesn't care about the freq scale factor, such as running an RMG network file, or running the Explorer tool. We shouldn't make Arkane crush if the user doesn't artificially set the factor to 1 in the input file. Also, thanks @dranasinghe for spotting this issue to begin with! I think it should be ready for review now. |
Added more unit tests to Arkane's inputTest (force pushed) |
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.
Looking good. I made a comment regarding what I think the default behavior should be. Also, you mean "crash", not "crush" 😄
arkane/input.py
Outdated
else: | ||
# assume only the sp level was given in the model chemistry, assign to sp and return None for freq | ||
sp_level = model_chemistry | ||
freq_level = None |
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 don't think this is the desired default behavior. If only one level of theory is specified, it should be assumed that frequency and energy calculations were done at that level of theory. This would also match typical descriptions in literature. For example, if the user specifies wb97x-d3/def2-tzvp
, then sp_level
and freq_level
should both be set to that.
You can then combine the '/' not in model_chemistry
case and the else
case into just one else
case.
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'll change accordingly, but we still need the /
that differentiates this from a composite method
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.
In both cases we set sp_level
and freq_level
to the same thing, so we don't have to check composite methods separately.
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 agree, added a fixup
arkane/statmech.py
Outdated
logging.warning('No frequency scale factor found for model chemistry {0}; assuming a value of unity.'.format( | ||
model_chemistry)) | ||
else: | ||
if model_chemistry in freq_dict: |
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 far as I can tell, your code changes here don't actually change any of the functionality. Why are your changes necessary? Can we just leave the code as it was?
arkane/inputTest.py
Outdated
|
||
spc0 = species(label0, **kwargs) | ||
self.assertEqual(spc0.label, 'CH2O') | ||
self.assertEqual(spc0.molecule[0].toSMILES(), 'C=O') |
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.
You can use @mliu49's new SMILES
attribute now and just do spc0.SMILES
.
arkane/inputTest.py
Outdated
mc = 'ccsd(t)-f12a/aug-cc-pvtz' | ||
sp, freq = process_model_chemistry(mc) | ||
self.assertEqual(sp, 'ccsd(t)-f12a/aug-cc-pvtz') | ||
self.assertIsNone(freq) |
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.
Change this dependent on your changes to my other comments.
Thanks for the comments! I added fixups, let me know when to squash |
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.
Looks good! I just have a tiny comment about some wording in a comment. Other than that, you can squash and I think you'll also need to rebase.
arkane/input.py
Outdated
@@ -706,7 +706,7 @@ def process_model_chemistry(model_chemistry): | |||
# assume this is an sp//freq format, split | |||
sp_level, freq_level = model_chemistry.split('//') | |||
else: | |||
# assume only the sp level was given in the model chemistry, assign to sp and return None for freq | |||
# assume the sp freq levels are the same, assign to the model chemistry to both |
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 think some words might have gotten lost here. You probably meant something like assume the sp and freq levels are the same, assign the model chemistry to both
Thanks!! Rebased and squashed |
sp_level = freq_level = model_chemistry | ||
if model_chemistry.startswith('cbs-qb3'): | ||
# hard code for CBS-QB3-Paraskevas which has the same frequency scaling factor as CBS-QB3 | ||
freq_level = 'cbs-qb3' |
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.
Sorry about seeing this after merging, but this hard-coding is slightly redundant since there's an entry for cbs-qb3-paraskevas
in assign_frequency_scale_factor
(https://github.com/ReactionMechanismGenerator/RMG-Py/blob/master/arkane/statmech.py#L1224).
I think we could remove one or the other.
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.
Sorry, didn't check the assign_frequency_scale_factor
function in detail.
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.
You're absolutely right, I haven't noticed the redundancy either.
Motivation or Problem
If the user did not specify the frequency scaling factor, Arkane uses the model chemistry to determine it from a dictionary. However, the model chemistry in Arkane currently respesents the sp level, whereas the freq level should have been used instead.
Description of Changes
Arkane can now process a model chemistry in an sp//freq form, e.g.,
CCSD(T)-F12a/aug-cc-pVTZ//B3LYP/6-311++G(3df,3pd)
, and determines the frequency scaling factor from the freq level, if available.Also, if the frequency scaling factor was not specified and could not be determined from the dictionary, we now raise an error instead of setting it to
1
and warn the user. This way, software like ARC could capture the error and attempt to derive the frequency scaling factor by itself.Testing
Added an example which also runs in RMG's tests. Also added a unit test for the new
process_model_chemistry
function.