KingsburyLab / pyEQL

A Python library for solution chemistry
Other
66 stars 20 forks source link

Replace autogenerate() with a Solution class method #63

Closed rkingsbury closed 12 months ago

rkingsbury commented 1 year ago

pyEQL.functions.autogenerate() provides an easy way to instantiate common solutions like seawater, rainwater, etc. This function should be deprecated in favor of a Solution classmethod that serves the same purpose. What I envision is

@classmethod
def from_preset(preset: str) -> Solution:
"""
Instatiate a solution from a preset composition

Args:
     preset: a named preset e.g. 'seawater' or the path to a .yaml file that defines the desired preset

Returns:
    Solution
"""

Instead of hard-coding the composition of each preset in the function body (like autogenerate does), the properties (solute concentrations, pH, etc. can be stored in yaml or json files that are read in by from_preset. That will make the presets more transparent and make it easier to add additional ones in the future.

So when all is said and done, a user could:

s = Solution.from_preset('seawater')
<pyEQL.Solution object>
kirill-push commented 1 year ago

Hi! Can I try to do this?