CryPTSys / PharmaPy

A numerical platform for the digital design of pharmaceutical processes
Other
23 stars 14 forks source link

Proposal - Different way of organizing dynamic results from simulations #32

Closed dcasasor-purdue closed 2 years ago

dcasasor-purdue commented 2 years ago

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:

  1. The user has to know the attribute names in advance in order to access dynamic results
  2. 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.

Looking forward to your comments!!

Inyoung-Hur commented 2 years ago

I can try using new plotting framework to on dryer model/ crystallizer model as well.