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.
|
alongd
left a comment
There was a problem hiding this comment.
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.
Is this a leftover from debugging? If not, consider adding a message?
| 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), |
rmgpy/rmg/pdep.py
Outdated
|
|
||
| nrxns = [] | ||
| for nrxn in self.netReactions: | ||
| prod = nrxn.products |
There was a problem hiding this comment.
Looks like prod isn't used below
| 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.
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.
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.
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.
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
| 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.
Add space between comma and argument
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.
maybe combine these conditions into the ones above?
rmgpy/rmg/pdep.py
Outdated
| self.Nprod = len(self.products) | ||
|
|
||
| def remove_reactions(self,reactionModel,rxns): | ||
| def remove_reactions(self,reactionModel,rxns=None,prods=None): |
| for rxn in rxns: | ||
| self.pathReactions.remove(rxn) | ||
|
|
||
| if rxns: |
There was a problem hiding this comment.
shouldn't this be if rxns is not None? Or is there no practical difference?
There was a problem hiding this comment.
There's no practical difference it won't trigger if rxns = None or rxns = [].
| self.pdepnetwork.explored = [] | ||
|
|
||
|
|
||
| def test_SS_solver(self): |
There was a problem hiding this comment.
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.
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
alongd
left a comment
There was a problem hiding this comment.
OK, looks good. Just a minor comment
|
|
||
| c = c.astype(np.float64) | ||
|
|
||
| try: |
There was a problem hiding this comment.
Maybe only leave the critical part (qr_solve?) inside the try: except block?
There was a problem hiding this comment.
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
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.