uncscode / particula

a simple, fast, and powerful particle simulator
https://uncscode.github.io/particula
MIT License
5 stars 7 forks source link

VaporPressure builder with validation and factory. #455

Closed Gorkowski closed 2 months ago

Gorkowski commented 2 months ago

Independent of other PRs

Purpose: This PR introduces a two-fold enhancement to the vapor pressure strategy management. Firstly, it implements a builder interface for vapor pressure strategies (vapor_pressure_builders) that supports different units for input parameters and ensures these are correctly converted to the units required by the strategies. Secondly, the builder checks for the completeness of the parameters and raises errors if any are missing.

Implementation: The factory method (vapor_pressure_factories) has been refactored into its own module, utilizing the builder pattern to create the strategy objects. This approach ensures all parameters are validated during the build process. While direct instantiation of strategies via vapor_pressure_strategies is still possible, using the builder or factory methods is now the recommended practice to ensure parameter integrity and unit consistency. The jupyter notebook for vapor_pressure has been update with the three usages.

Files Added:

Future Considerations: Post implementation of similar builder and factory patterns for gas species and particle classes, there is potential to further streamline the code structure. Each vapor pressure strategy, along with its associated builder, could be isolated into separate files. I think the pattern will become clear after making builders-validations/factories for the gas species and particle classes.

github-actions[bot] commented 2 months ago

PR Preview Action v1.4.7 :---: :rocket: Deployed preview to https://uncscode.github.io/particula/pr-preview/pr-455/ on branch gh-pages at 2024-05-12 19:13 UTC