Skip to content
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

Merged
merged 4 commits into from
Jun 3, 2019

Conversation

alongd
Copy link
Member

@alongd alongd commented Jun 2, 2019

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.

@alongd alongd requested a review from cgrambow June 2, 2019 00:57
@alongd alongd self-assigned this Jun 2, 2019
@alongd alongd added the Arkane label Jun 2, 2019
@alongd alongd force-pushed the model_chemistry branch 2 times, most recently from 53686fa to bf43243 Compare June 3, 2019 00:17
@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #1612 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f90526f...b7967ba. Read the comment docs.

@alongd
Copy link
Member Author

alongd commented Jun 3, 2019

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.

@alongd
Copy link
Member Author

alongd commented Jun 3, 2019

Added more unit tests to Arkane's inputTest (force pushed)

Copy link

@cgrambow cgrambow left a 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
Copy link

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.

Copy link
Member Author

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

Copy link

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.

Copy link
Member Author

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

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:
Copy link

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?


spc0 = species(label0, **kwargs)
self.assertEqual(spc0.label, 'CH2O')
self.assertEqual(spc0.molecule[0].toSMILES(), 'C=O')
Copy link

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.

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)
Copy link

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.

@alongd
Copy link
Member Author

alongd commented Jun 3, 2019

Thanks for the comments! I added fixups, let me know when to squash

Copy link

@cgrambow cgrambow left a 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
Copy link

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

@alongd
Copy link
Member Author

alongd commented Jun 3, 2019

Thanks!! Rebased and squashed

@cgrambow cgrambow merged commit 67dab34 into master Jun 3, 2019
@cgrambow cgrambow deleted the model_chemistry branch June 3, 2019 21:18
@mliu49 mliu49 mentioned this pull request Jun 3, 2019
5 tasks
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'
Copy link
Contributor

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.

Copy link

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants