-
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
Automatic Network Generation 3 #1647
Conversation
ff67fdf
to
505333f
Compare
Codecov Report
@@ Coverage Diff @@
## master #1647 +/- ##
=========================================
- Coverage 41.87% 41.77% -0.1%
=========================================
Files 176 176
Lines 29369 29423 +54
Branches 6059 6075 +16
=========================================
- Hits 12297 12291 -6
- Misses 16192 16257 +65
+ Partials 880 875 -5
Continue to review full report at Codecov.
|
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 for the delay in reviewing, please see some comments.
How would you recommend me to test these additions?
arkane/explorer.py
Outdated
if forbiddenStructures.isMoleculeForbidden(spc.molecule[0]): | ||
reaction_model.removeSpeciesFromEdge(reaction_model.reactionSystems, spc) | ||
reaction_model.removeEmptyPdepNetworks() | ||
logging.error(spc.label) |
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.
Is this a leftover from debugging? If not, consider adding a message?
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.
removed
reaction_model.enlarge((network, spc), reactEdge=False, unimolecularReact=flags, | ||
logging.info('adding new isomer {0} to network'.format(spc)) | ||
flags = np.array([s.molecule[0].getFormula() == form for s in reaction_model.core.species]) | ||
reaction_model.enlarge((network, spc), reactEdge=False, unimolecularReact=flags, | ||
bimolecularReact=np.zeros((len(reaction_model.core.species), |
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.
fix the over-indentation?
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.
done
rmgpy/rmg/pdep.py
Outdated
@@ -472,22 +472,49 @@ def remove_disconnected_reactions(self): | |||
logging.info('Removing rxn: {}'.format(rxn)) | |||
self.pathReactions.remove(rxn) | |||
|
|||
nrxns = [] | |||
for nrxn in self.netReactions: | |||
prod = nrxn.products |
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 like prod
isn't used below
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.
fixed
nrxns = [] | ||
for nrxn in self.netReactions: | ||
prod = nrxn.products | ||
if nrxn.products not in keptProducts or nrxn.reactants not in keptProducts: |
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.
nrxn.products
is a list of length 1 to 3, right? Can an in
or not in
check be performed that way? Shouldn't we iterate through the products in nrxn.products
before the check?
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.
keptProducts is constructed as a list of lists of species (from a pdep network perspective this makes sense since each represents a configuration) so this should work fine.
rmgpy/rmg/pdep.py
Outdated
|
||
con = np.linalg.cond(A) | ||
|
||
try: |
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 the error message and comment are a bit confusing: So if it is ill-conditioned we raise an error, but if it is "very ill-conditioned" we troubleshoot?
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've adjusted this to use an if statement rather than the first try except, which makes it a bit clearer. In general if we expect we can handle the matrix we do it normally, otherwise we fall back to arbitrary precision arithmetic, and lastly if we can't manage that we just assume all the isomers that aren't reactant channels have zero concentration which makes the calculation trivial.
rmgpy/rmg/pdep.py
Outdated
@@ -354,32 +354,42 @@ def get_energy_filtered_reactions(self,T,tol): | |||
|
|||
return filtered_rxns | |||
|
|||
def get_rate_filtered_reactions(self,T,P,tol): | |||
def get_rate_filtered_products(self,T,P,tol): |
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.
Add space between comma and argument
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.
fixed
arkane/explorer.py
Outdated
for prod in productSet: | ||
logging.info([x.label for x in prod]) | ||
|
||
if rxnSet: |
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.
maybe combine these conditions into the ones above?
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.
done
rmgpy/rmg/pdep.py
Outdated
@@ -536,16 +536,45 @@ def remove_disconnected_reactions(self): | |||
self.Nreac = len(self.reactants) | |||
self.Nprod = len(self.products) | |||
|
|||
def remove_reactions(self,reactionModel,rxns): | |||
def remove_reactions(self,reactionModel,rxns=None,prods=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.
add spaces?
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.
done
for rxn in rxns: | ||
self.pathReactions.remove(rxn) | ||
|
||
if rxns: |
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.
shouldn't this be if rxns is not None
? Or is there no practical difference?
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.
There's no practical difference it won't trigger if rxns = None or rxns = [].
@@ -162,19 +162,14 @@ def setUp(self): | |||
self.pdepnetwork.index = 1 | |||
self.pdepnetwork.explored = [] | |||
|
|||
|
|||
def test_SS_solver(self): |
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.
But pdep.py still had the method, doesn't it? (or was the method itself removed as well?)
If we're still using the original method somewhere, lets keep/relocate the test for it?
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.
So the method exists, but the problem is that pdepTest doesn't have appropriate objects to test it directly after changes made in solve_SS_network. test_flux_filter does test it though, so it's still under coverage.
I invested sometime trying to figure out how to make it work, but given it's already under reasonable coverage (get_rate_filtered_products isn't a complicated function), it didn't seem worth it.
82e7071
to
2b0730a
Compare
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.
OK, looks good. Just a minor comment
|
||
c = c.astype(np.float64) | ||
|
||
try: |
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.
Maybe only leave the critical part (qr_solve
?) inside the try: except
block?
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.
So the problem is that nnls (non-negative least squares) is critical as well when required and may fail as well (although given the qr_solve has to succeed to try nnls it shouldn't fail that often, but it should still fall back properly if nnls is called and fails).
OK, I think we're all set. Can you rebase? |
… networks in Arkane
…recision also if arbitrary precision fails fall back to just using rate coefficients
this includes adding the fallback algorithm that simply uses the rate coefficients rather than the steady state analysis
…n terms of path reactions
note that the test_SS_solver is removed because we've switched from using pathReactions to netReactions
2b0730a
to
48f12c8
Compare
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.
Thanks!
This adds a number of miscellaneous bug fixes and improvements for automatic network generation. Forbidden structure checking is now done on the edge for automatic network generation, flux reduction is now done on netReactions instead of pathReactions and has an additional very robust fallback algorithm just using rate coefficients. Fixed a bug related to reduction when an isomer is removed.