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

Non-cat changes to master from cat branch, 2 #1542

Merged
merged 9 commits into from
Feb 6, 2019
Merged

Non-cat changes to master from cat branch, 2 #1542

merged 9 commits into from
Feb 6, 2019

Conversation

rwest
Copy link
Member

@rwest rwest commented Jan 25, 2019

Motivation or Problem

This is a follow-on from #1538.
This is the second of two pull requests that don't actually introduce surface sites or heterogeneous reactions, but contains a series of commits that prepare the groundwork for merging RMG-Cat (heterogeneous catalysis) features into RMG.

Description of Changes

  • change Hydrogen bonds to have a bond order of 0.1 (instead of 0)
  • introduce Van der Waals bonds with a bond order of 0
  • introduce Quadruple bonds (with a bond order of 4)
  • Snapshots (PNGs and CSVs) now track moles not mole fractions.

Testing

The last change (tracking moles not mole fractions) may mess up some regression tests, depending how they're configured, and should come with warnings (that the meaning of RMG's output has changed), but I think it's an improvement. I am open to discussion though, if people feel it should be an configurable option or something. Mole amounts make so much more sense when you have surfaces etc. And if you want to get a mole fraction, it's trivial to go in that direction.

Reviewer tips.

Now that #1538 has been merged, and all the unit tests and regression tests seem to be passing, I guess it's ready for review.

@rwest rwest force-pushed the catemp2 branch 3 times, most recently from fac8d84 to 7bead49 Compare January 27, 2019 01:42
@codecov
Copy link

codecov bot commented Jan 27, 2019

Codecov Report

Merging #1542 into master will decrease coverage by 0.13%.
The diff coverage is 7.4%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1542      +/-   ##
==========================================
- Coverage   41.99%   41.86%   -0.14%     
==========================================
  Files         165      165              
  Lines       27896    28010     +114     
  Branches     5680     5714      +34     
==========================================
+ Hits        11715    11726      +11     
- Misses      15395    15496     +101     
- Partials      786      788       +2
Impacted Files Coverage Δ
rmgpy/molecule/group.py 0% <0%> (ø) ⬆️
rmgpy/molecule/converter.py 0% <0%> (ø) ⬆️
rmgpy/molecule/molecule.py 0% <0%> (ø) ⬆️
rmgpy/molecule/atomtype.py 0% <0%> (ø) ⬆️
rmgpy/molecule/adjlist.py 75.28% <100%> (+0.04%) ⬆️
rmgpy/rmg/listener.py 100% <100%> (ø) ⬆️
rmgpy/molecule/atomtypedatabase.py 38.57% <23.07%> (-0.5%) ⬇️
rmgpy/data/kinetics/database.py 46.65% <40%> (-0.22%) ⬇️
rmgpy/data/kinetics/family.py 58.56% <60%> (+0.27%) ⬆️
rmgpy/molecule/draw.py 42.16% <7.69%> (-0.51%) ⬇️
... and 1 more

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 f4d8a0b...7ff2527. Read the comment docs.

@rwest rwest force-pushed the catemp2 branch 3 times, most recently from 602b7b9 to 610f693 Compare February 1, 2019 03:59
@rwest rwest added the Status: Ready for Review PR is complete and ready to be reviewed label Feb 1, 2019
@mjohnson541 mjohnson541 self-requested a review February 1, 2019 17:02
@@ -785,7 +785,7 @@ cdef class ReactionSystem(DASx):


snapshot = [self.t, self.V]
snapshot.extend(y_coreSpecies / numpy.sum(y_coreSpecies))
snapshot.extend(y_coreSpecies)
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree analyzing moles work better for the general case and it's not difficult to convert them into whatever you need later during analysis. This won't have an impact on sensitivity analysis, since the sensitivity coefficients are converted from molar to concentration during simulation. It also doesn't look like it will impact flux diagram generation since it just pulls the concentrations off the object each time step rather than reading an output file.

@@ -154,6 +154,7 @@ cdef class SimpleReactor(ReactionSystem):
initialMoleFractions[speciesDict[label]] = moleFrac
self.initialMoleFractions = initialMoleFractions


Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this change was already made on master?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. If there had been no change the rebase would have dropped the commit. Will fix.


#count up number of bonds
single = 0; rDouble = 0; oDouble = 0; sDouble = 0; triple = 0; benzene = 0
single = 0; rDouble = 0; oDouble = 0; sDouble = 0; triple = 0; quadruple = 0; benzene = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Since benzene doesn't have quadruple bonds, this commit message is a bit confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will reword

@@ -1581,7 +1589,7 @@ def find_H_bonds(self):
atm_cov = atm_covs[0]
if (atm_cov.isOxygen() or atm_cov.isNitrogen()): #this H can be H-bonded
for k,atm2 in enumerate(ONatoms):
if all([q.order != 0 for q in atm2.bonds.values()]): #atm2 not already H bonded
if all([q.order != 0.1 for q in atm2.bonds.values()]): #atm2 not already H bonded
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be numpy.isclose(0.1,q.order) as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK

@@ -89,7 +90,9 @@ def check_partial_charge(atom):

theoretical = valence - order - atom.radicalElectrons - 2*atom.lonePairs

if atom.charge != theoretical:
if np.isclose(-0.1, theoretical):
Copy link
Contributor

Choose a reason for hiding this comment

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

This will break if the molecule has more than one H bond? I don't expect having more than 2-
H bonds on a realistic molecule. Perhaps we should just check that abs(theoretical) > 0.301 before raising the error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't it require an atom to have more than one H bond to break this?

But anyway, it's easy to do your suggestion.

rwest and others added 9 commits February 5, 2019 22:19
Unsure if this has consequences on flux diagrams or
sensitivity analyses, etc. but I think it's a helpful 
start towards making more sense of simulation outputs,
especially for two-phase heterogeneous systems.
A combination of commits with these messages:

replaced part of the adjlist in the test that I accidentally deleted

added in a quadruple bond to orders

Added in quadruple bond type in converter
added in more instances of quadruple bonds

Adding Cq to R and R!H atom types

added in todos to add unit tests for quadruple bonded elements
It's unfortunate how fragile this code is, using integer
indexing.
Had to change getFeatures to include Benzene in its corrcect spot,
A combination of several commits, with these messages:

changed the remove H bonds to remove anything close to 0.1

Hydrogen-bonds now have order 0.1

This way of doing things is a bit fragile, and not very satisfying.
But I think this fixes at least a couple of places where this change
needs to be made.

Detect 0.1 bond orders (for H bonds) more robustly.

Now passes last unit test.
(It was something like 0.1000000000000149)
Reaction recipes can make Van der Waals bonds (with order 0)

Remove 'vdW' from bond types accepted (should be 0).

This is a hold-over from when bond types were strings
not floating point numbers.
Might not make a difference if you could see the logging.info call two lines earlier,
but when running unit tests (databaseTest) that is not necessarily the case.
@rwest
Copy link
Member Author

rwest commented Feb 6, 2019

I believe I addressed all @mjohnson541's comments, and the tests seem to be passing (I think the coverage check doesn't detect cythonized stuff properly?).

@mjohnson541 mjohnson541 merged commit 87ed3a5 into master Feb 6, 2019
@mjohnson541 mjohnson541 deleted the catemp2 branch February 6, 2019 17:35
@mliu49 mliu49 mentioned this pull request May 15, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Ready for Review PR is complete and ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants