Skip to content

Conversation

@alongd
Copy link
Member

@alongd alongd commented Mar 7, 2018

This PR allows Chlorine to be reactive in RMG. Only valance 1 is considered, and no hypervalance atomTypes were defined.
A respective atomType test was added, and the documentation was changed accordingly.
I also made a small change to the isomorphismTest which otherwise insists that Cl should be charged.

This PR will soon be accompanied by a sister -db PR with relevant kinetics and thermo data by @zjburas. They should be merged together, but this branch can principally be reviewed.

@codecov
Copy link

codecov bot commented Mar 7, 2018

Codecov Report

Merging #1310 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1310      +/-   ##
==========================================
- Coverage   43.05%   43.03%   -0.02%     
==========================================
  Files         169      169              
  Lines       28342    28365      +23     
  Branches     5535     5538       +3     
==========================================
+ Hits        12203    12208       +5     
- Misses      15302    15321      +19     
+ Partials      837      836       -1
Impacted Files Coverage Δ
rmgpy/cantherm/statmech.py 20.67% <ø> (ø) ⬆️
rmgpy/molecule/atomtype.py 0% <0%> (ø) ⬆️
rmgpy/molecule/group.py 0% <0%> (ø) ⬆️
rmgpy/reaction.py 0% <0%> (ø) ⬆️
rmgpy/molecule/element.py 0% <0%> (ø) ⬆️
rmgpy/molecule/molecule.py 0% <0%> (ø) ⬆️
rmgpy/data/kinetics/family.py 58.19% <0%> (+0.4%) ⬆️

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 f5b7467...f317c69. Read the comment docs.

@mliu49
Copy link
Contributor

mliu49 commented Mar 7, 2018

@rwest mentioned that he was working on chlorine in #717. Are there any updates on the status of that?

and rearranged He/N2/Ar for better readability
@alongd
Copy link
Member Author

alongd commented Mar 13, 2018

@rwest , regarding @mliu49's comment above, are there any chlorine additions you'd like to add to either this PR or ReactionMechanismGenerator/RMG-database#257? Or shall we continue with these as they are?

@rwest
Copy link
Member

rwest commented Mar 13, 2018

Sorry, I've not been keeping on top of this or ReactionMechanismGenerator/RMG-database#257. Here's a brief recap.

Our work was done by @faribas and can be found on her halogens branches. If she still receives github notifications, she can correct what I get wrong...

Because this forked three years ago (March 2015) it's probably hard to merge them directly, but there may be value in copying across what she did.

Thermochemistry:
as well as adding some thermo libraries and Benson's group additivity values for chlorinated hydrocarbons, she found she had to calculate her own hydrogen bond increment (HBI) values in order to estimate radicals containing chlorines. Next-nearest-neighbour effects were required to get decent estimates. She derived these from her own quantum calculations.

Reactions:
She allowed Cl to react as the radical for the two families H abstraction and radical recombination, and created new reaction families for H-Cl or Cl-Cl insertion into a multiple bond and Cl abstraction. Training rates were from the literature.

More details are in chapter 3 of her PhD thesis at http://hdl.handle.net/2047/D20213055

Also worth mentioning is that I have just received a grant to work on adding halogens to RMG (https://www.nsf.gov/awardsearch/showAward?AWD_ID=1751720), so would love to start a conversation about the best way to do this! It will be @skrsna working on that project, starting soon. Perhaps we can all meet.

@alongd
Copy link
Member Author

alongd commented Mar 13, 2018

Congrats on the grant! I love that this includes training undergrads in this kind of problem solving.

Other stakeholders here are @zjburas (currently in CA), and @sarahkha from the GreenGroup implementing iodine.

I'll look at @faribas's -Py repo, @zjburas, could you take a look at the -db repo?

@zjburas
Copy link
Contributor

zjburas commented Mar 13, 2018

Sure @alongd , I can take a look at the -db repo.

Congratulations @rwest on the grant. My immediate interest in halogen chemistry is pretty narrow: I just want to use RMG as a tool to account for chlorine side-chemistry during chlorine initiated oxidation experiments from 300-1000 K. For that purpose, what @faribas already did is probably sufficient. Hopefully we can talk sometime.

Copy link
Member

@amarkpayne amarkpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great PR Alon! I have noted a couple of quick things that need fixing, but this PR should be ready for merging soon after these quick fixes.

The only other thing may be to add cases with chlorine to the unit tests for group.py and molecule.py, but this is probably not necessary.

``S6td`` sulfur atom with no lone pairs (valance 6), one triple bond, one double bond and up to one single bond
``S6tt`` sulfur atom with no lone pairs (valance 6) and two triple bonds
``S6tdc`` charged sulfur atom with no lone pairs (valance 6), one to two triple bonds, up to two double bonds, and up to four single bonds
=============== ==============================================================================================================================================================
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to delete line 118 for the table to format properly. Otherwise, it tries to end the table early

+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|S6tdc |Sulfur |No lone pairs, one to two triple bonds, up to two double bonds, up to four single bonds, charged -1/-1 |
+----------+-------------------+------------------------------------------------------------------------------------------------------------------+
|Cl1s |Chlorine |Three lone pairs, zero to one single bonds |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you add an entry for Cl as well?

'C#C': -0.64, 'C#N': -0.89, 'C-S': 0.43, 'O=S': -0.78, 'S-H': 0.0, 'C-N': -0.13, # Table IX: Petersson GA (1998) J. of Chemical Physics, DOI: 10.1063/1.477794
'N-H': -0.42, 'N=O': 1.11, 'N-N': -1.87, 'N=N': -1.58, 'N-O': 0.35, #Table 2: Ashcraft R (2007) J. Phys. Chem. B; DOI: 10.1021/jp073539t
'N#N': -2.0, 'O=O': -0.2, 'H-H': 1.1, # Unknown source
'C-C': -0.495,'C-H': -0.045,'C=C': -0.825,'C-O': 0.378,'C=O': 0.743,'O-H': -0.423, #Table2: Paraskevas, PD (2013). Chemistry-A European J., DOI: 10.1002/chem.201301381
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like your editor changed some of the spacing here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was actually me, trying to make the lines a bit shorter (now with the 'C-Cl', 'C-F' additions, the second line was too long). It still functions good and it's readable, let me know if you think otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, this is fine by me then, just making sure

self.siliconCount = 0
self.radicalCount = 0
for atom in self.vertices:
if len(atom.atomType) == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outside the scope of your commit, but what should happen if len(atom.atomType) != 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that since it is a Group and not a Molecule, an "atom" can be defined as 1 [C,N,O] ux px cx {2,S}, in which case we can't fingerprint it and we correctly skip this condition. I think this also means we're missing out on cases like 1 [Cs,Cd] ux px cx {2,S} where we could fingerprint, but don't (for that atom in the Group). However, this should be working smoothly for Molecules.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I wonder if there is a way to catch cases like 1 [Cs,Cd] ux px cx {2,S} and if that would be useful. If so this is something for another PR though.

isChlorine = atomType.equivalent(chlorine)
isSilicon = atomType.equivalent(silicon)
sum_is_atom = isCarbon + isNitrogen + isOxygen + isSulfur + isChlorine + isSilicon
if sum_is_atom == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if sum_is_atom != 1? I can't imagine this happening, but maybe I am missing a subtlety here. I would think that this would either always evaluate to True (and thus it is not needed) or we need some sort of error handling if it does occur.

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 think this is related to the previous comment: an "atom" in a Group could be defined as 1 [C,N,O] ux px cx {2,S}. In this case, atomType = [C,N,O], and .equivalent will return True for more than one isAtom. In this case, sum_is_atom will be 3.
I agree that it seems unnecessary (now that I rethink it) since it's already under the if len(atom.atomType) == 1: condition discussed above. We could either keep it to keep the same functionality as before in case I'm also missing a subtlety, or remove. I'll check.


cpdef bint isFluorine(self)

cpdef bint isSilicon(self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a note in the commit that isSilicon was added to cython file as well, good catch!


def isFluorine(self):
"""
Return ``True`` if the atom represents an oxygen atom or ``False`` if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change doc string element name to "fluorine"


def isChlorine(self):
"""
Return ``True`` if the atom represents an sulfur atom or ``False`` if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, but for "chlorine"


def isIodine(self):
"""
Return ``True`` if the atom represents an sulfur atom or ``False`` if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, but for "Iodine"

carbon = atomTypes['C']
nitrogen = atomTypes['N']
oxygen = atomTypes['O']
# flourine = atomTypes['F']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should either go ahead and add fluorine and iodine atom types in this PR, or remove this commented line until we are ready.

@alongd
Copy link
Member Author

alongd commented Mar 14, 2018

Thanks for the timely review, @amarkpayne! I addressed all comments but one in fixup commits. I'll double check the implications of removing the if sum_is_atom == 1: condition.

amarkpayne
amarkpayne previously approved these changes Mar 14, 2018
Copy link
Member

@amarkpayne amarkpayne 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 am looking into the if sum_is_atom == 1: issue as well, though so far it appears that the unit tests do fail without this. Given this I think this PR is good to go. Go ahead and auto-squash the fixup commits, and I'll merge this in

@alongd
Copy link
Member Author

alongd commented Mar 14, 2018

I just saw your comment. I pushed an optional solution, if it won't do the trick I'll squash w/o it

@amarkpayne amarkpayne removed the Status: Ready for Review PR is complete and ready to be reviewed label Mar 14, 2018
@alongd alongd added the Status: Accepted This PR is approved and ready to be merged label Mar 14, 2018
@amarkpayne amarkpayne merged commit 73d4706 into master Mar 14, 2018
@amarkpayne amarkpayne deleted the chlorine branch March 14, 2018 02:52
@amarkpayne amarkpayne removed the Status: Accepted This PR is approved and ready to be merged label Mar 14, 2018
@alongd
Copy link
Member Author

alongd commented Mar 14, 2018

We believe this PR is a comprehensive example for adding new reactive elements into RMG.
See also #1206 for sulfur and #888 for nitrogen
Also, consider elaborating known SMILES, see #1325

@alongd alongd changed the title Added Chlorine Cl1s atomType Added Chlorine as a new reactive element in RMG Mar 14, 2018
@alongd alongd mentioned this pull request Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants