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

Network Explorer Part 2 #1545

Merged
merged 14 commits into from
Apr 23, 2019
Merged

Network Explorer Part 2 #1545

merged 14 commits into from
Apr 23, 2019

Conversation

mjohnson541
Copy link
Contributor

This PR improves the network explorer tool. It enables use of bimolecular reactant channels and changes the definition of explore_tol. Before explore_tol was an explicit rate coefficient the leak flux of the network was compared to. This PR uses the sum of the coefficients for the net reactions from the source to all other channels to scale the leak rate coefficient. This means that the network will be expanded if the leak rate of the network is larger than explore_tol times the characteristic rate coefficient. Where the charactersitic rate coefficient is the sum of the rate coefficients for all (net) reactions taking the source channel to any other channel in the network.

Check that the unittests pass, run the methoxy network example and take a look at how the new explore_tol affects network generation.

@mjohnson541 mjohnson541 added Arkane Status: Ready for Review PR is complete and ready to be reviewed Complexity: Low labels Feb 2, 2019
@mjohnson541 mjohnson541 self-assigned this Feb 2, 2019
@mjohnson541 mjohnson541 changed the title Network Exploration Part 2 Network Explorer Part 2 Feb 2, 2019
@codecov
Copy link

codecov bot commented Feb 6, 2019

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1545   +/-   ##
=======================================
  Coverage   41.65%   41.65%           
=======================================
  Files         166      166           
  Lines       28452    28452           
  Branches     5855     5855           
=======================================
  Hits        11853    11853           
  Misses      15777    15777           
  Partials      822      822

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 0db89ac...e09ad75. Read the comment docs.

@mjohnson541 mjohnson541 force-pushed the explorer2 branch 3 times, most recently from ea62530 to 9153c83 Compare February 6, 2019 20:52
@mjohnson541
Copy link
Contributor Author

This should be ready for review now.

Copy link
Member

@alongd alongd 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! See some comments

flags = np.array([s.molecule[0].getFormula()==form for s in reaction_model.core.species])
biflags = np.zeros((len(reaction_model.core.species),len(reaction_model.core.species)))
elif len(self.source) == 2:
flags = np.array([s.molecule[0].getFormula()==form for s in reaction_model.core.species])
Copy link
Member

Choose a reason for hiding this comment

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

If flags is being set the same regardless of the condition, perhaps set it before the if statement? Or should it be set to zeroes if len(self.source)==2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

if network.getLeakCoefficient(T=T,P=P) > self.explore_tol:
kchar = 0.0 #compute the characteristic rate coefficient by summing all rate coefficients from the reactant channel
for rxn in self.network.netReactions:#reaction_model.core.reactions+reaction_model.edge.reactions:
if set(rxn.reactants) == set(self.source) and len(rxn.products) == 1 and rxn.products[0].molecule[0].getFormula() == form:
Copy link
Member

Choose a reason for hiding this comment

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

Can we have len(rxn.products) == 1 but not rxn.products[0].molecule[0].getFormula() == form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check rxn.products[0].molecule[0].getFormula() == form as well in this condition? Shouldn't checking for len(rxn.products) == 1 be enough? If there's only one product, can it have a different formula than the PES?

if set(rxn.reactants) == set(self.source) and len(rxn.products) == 1 and rxn.products[0].molecule[0].getFormula() == form:
kchar += rxn.kinetics.getRateCoefficient(T=T,P=P)
elif set(rxn.products) == set(self.source) and len(rxn.reactants) == 1 and rxn.reactants[0].molecule[0].getFormula() == form:
kchar += rxn.generateReverseRateCoefficient(network_kinetics=True).getRateCoefficient(T=T,P=P)
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 this chunk was added in a commit which is part of this PR:
use the sum of the rate coefficients for all net rates from the, f236722

Can you merge these instead of deleting the code?

Copy link
Contributor 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 fixed too.


def test_arkane_examples(self):
for example_type in self.example_types:
example_type_path = os.path.join(self.base_path, example_type)
for example in os.listdir(example_type_path):
for example in sorted(os.listdir(example_type_path)):
Copy link
Member

Choose a reason for hiding this comment

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

Can you check whether #1565 solved this problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't solve the issue

@mjohnson541
Copy link
Contributor Author

I think this should be ready.

…e channel to every other channel times the explore_tol for the threshold

before explore_tol was simply an unscaled threshold for the leak rate
this results in multiple output files
So it appears that the order of the explorer/network examples matters significantly enough that some orders give you database loading related errors
The logic of the errors and the ordering aren't obvious
for this reason the explorer examples are run before the network examples and the the os.listdir() output is sorted to maintain consistency
Copy link
Member

@alongd alongd 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. See one minor comment. I'd like to test it out before we merge

if network.getLeakCoefficient(T=T,P=P) > self.explore_tol:
kchar = 0.0 #compute the characteristic rate coefficient by summing all rate coefficients from the reactant channel
for rxn in self.network.netReactions:#reaction_model.core.reactions+reaction_model.edge.reactions:
if set(rxn.reactants) == set(self.source) and len(rxn.products) == 1 and rxn.products[0].molecule[0].getFormula() == form:
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to check rxn.products[0].molecule[0].getFormula() == form as well in this condition? Shouldn't checking for len(rxn.products) == 1 be enough? If there's only one product, can it have a different formula than the PES?

@alongd
Copy link
Member

alongd commented Apr 14, 2019

@mjohnson541, I reviewed by commits, I see that the final code doesn't include the line I commented on. Please ignore my comment above. Maybe you'd like to polish the commits so there won't be additions and deletions of the same code blocks in a single PR?

@mjohnson541
Copy link
Contributor Author

mjohnson541 commented Apr 14, 2019

I could do that, but the order in which the commits were applied wouldn't make sense any longer. It would mean applying two major changes at once in one commit, which is a lot harder to read than the current way (even if its a bit more difficult to review).

@mjohnson541
Copy link
Contributor Author

@alongd pdf overwritting issue is fixed can you merge?

Copy link
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Perfect! Sorry for being too slow.

@alongd alongd merged commit 88e62a8 into master Apr 23, 2019
@alongd alongd deleted the explorer2 branch April 23, 2019 00:04
@alongd alongd removed the Status: Ready for Review PR is complete and ready to be reviewed label Apr 23, 2019
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants