Architecture#
HydroGenerate is currently implemented as three separate Python scripts: turbine_calculation.py, hydropower_potential.py, and hydraulic_processing.py. turbine_calculation.py handles turbine efficiency calculations for different turbine types and the calculation of design flow by percent exceedance. hydraulic_processing.py handles head losses calculation in the penstock by Darcy-Weisbach or Hazen Williams. The scripts use classes and functions for different implementation.
The code is modular, and several steps were followed to facilitate the process of integrating functionality. Classes are single-function, small, and simple to facilitate overview of the code. Abstract Base Classes (ABC) are used to group methods that belong to the same category, e.g., calculation of efficiency of different turbine types. All turbine efficiency calculations belong to the same abstract class and use a method that is inherited from the ABC class. ABC classes facilitate the addition of new methods, e.g., the efficiency of a new turbine. The efficiency of a new turbine can be included in the code without modifying any of the existing turbines, minimizing the opportunity for errors while keeping all turbine efficiency methods under the same class. This facilitates code reuse and modularity by enforcing consistency. All turbine types in HydroGenerate must implement the method turbine_calculator. The same principle is followed by all other abstract classes. In some instances, an ABC is defined, and a single class is implemented. This reflects the intention to add additional methods. For example, the class Cost contains a single model (described in the documentation) but the addition of others models as they become available is anticipated.
New features, functionalities, or additional work should not affect an existing feature. While it is likely that new features utilizing additional variables will require modifying the variable definitions for existing classes, this should not impact the already implemented methods or functions. The existing code in HydroGenerate contains extensive comments along all code files that document what the variables being used are, what chunk of codes are doing, and why (when needed) certain implementations were used. New code added to HydroGenerate should follow a similar approach.
Currently, users can access all functionalities by using a single function (hydropower_potential). Future development could maintain interactions via a single function, however, adding more user executable functions is not discouraged.