Hey @dlakes94 @Inyoung-Hur . I have an idea that came out when I was trying to create a function to plot PharmaPy results. Right now, we are using different attribute names to access dynamic results, e.g.
uo.timeProf, uo.xliqProf
There are two potentially problematic situations with the current state of things:
The user has to know the attribute names in advance in order to access dynamic results
The current names are not consistent with the name_states attributes for some UOs. For example, the vaporizer has the name x_liq in self.name_states but its corresponding dynamic output attribute is self.xliqProf.
I think this is not very user-friendly and can cause confusion. It occurred to me to do the following: instead of returning each dynamic output separately as an instance attribute, why not just return a dictionary with the dynamic states labelled in it? @dlakes94 and I worked recently on unravel_states on the Commons.py module, which turns a 1D or 2D array into a dictionary of states. We could exploit this functionality to deliver a much more user-friendly structure to read the dynamic results. The only caveat I would see is that the user now would have to do uo.dynamic_results['x_liq'] instead of uo.xliqProf, but I think in terms of usability the dictionary is better. The user only needs to do print(uo.dynamic_results.keys()) to know the available information contained in the dict.
Please let me know what you think about this. I made changes to Evaporators.py as a prototype of this idea. You will see that I used unravel_states in the unit_model method of the Evaporator class, which, in my opinion, is a much better and cleaner way of working.
Hey @dlakes94 @Inyoung-Hur . I have an idea that came out when I was trying to create a function to plot PharmaPy results. Right now, we are using different attribute names to access dynamic results, e.g.
uo.timeProf, uo.xliqProf
There are two potentially problematic situations with the current state of things:
name_states
attributes for some UOs. For example, the vaporizer has the namex_liq
inself.name_states
but its corresponding dynamic output attribute isself.xliqProf
.I think this is not very user-friendly and can cause confusion. It occurred to me to do the following: instead of returning each dynamic output separately as an instance attribute, why not just return a dictionary with the dynamic states labelled in it? @dlakes94 and I worked recently on
unravel_states
on theCommons.py
module, which turns a 1D or 2D array into a dictionary of states. We could exploit this functionality to deliver a much more user-friendly structure to read the dynamic results. The only caveat I would see is that the user now would have to douo.dynamic_results['x_liq']
instead ofuo.xliqProf
, but I think in terms of usability the dictionary is better. The user only needs to doprint(uo.dynamic_results.keys())
to know the available information contained in the dict.Please let me know what you think about this. I made changes to
Evaporators.py
as a prototype of this idea. You will see that I usedunravel_states
in theunit_model
method of theEvaporator
class, which, in my opinion, is a much better and cleaner way of working.Looking forward to your comments!!