OpenPNM icon indicating copy to clipboard operation
OpenPNM copied to clipboard

Add a property attribute to algorithm objects that retrieves a list of applied source terms

Open ma-sadeghi opened this issue 2 years ago • 3 comments

ma-sadeghi avatar Jul 06 '22 18:07 ma-sadeghi

One possbiel solution is to subclass __getitem__ on ReactiveTransport so that if a KeyError occurs after calling super, then is check for the special case of if key in ['pore.source'] return {}, else re-raise KeyError exception.

jgostick avatar Jul 11 '22 15:07 jgostick

I am thinking this is too much magic just to avoid a few try/excepts. I can imagine a few ways to make this work, but in the name of keep the code simple and maintainable, I think it's more obvious and explicit to actually check if any source terms have been defined.

jgostick avatar Aug 04 '22 15:08 jgostick

After some discussion is seems like a good refactor candidate to add sources attribute (or get_sources method) that returns a dict with source names as the keys and locations as the values. This can be added in future though, since it won't change the user api, only enhance it. Hence we're moving this issue to "future" changes.

jgostick avatar Aug 08 '22 14:08 jgostick

In the V3, the sources are now indicated in the algorithm dict as pore.source.<name>...so just doing alg['pore.source'] will return a dict with all defined sources given in a dict. The only thing we might do is make it so that alg['pore.source'] returns {} if there are no sources defined yet. This would eliminate the need for any try/except checks.

jgostick avatar Nov 05 '22 03:11 jgostick