NREL-Sienna / PowerSystems.jl

Data structures in Julia to enable power systems analysis. Part of the Scalable Integrated Infrastructure Planning Initiative at the National Renewable Energy Lab.
https://www.nrel.gov/analysis/sienna.html
BSD 3-Clause "New" or "Revised" License
299 stars 71 forks source link

Solve the Units Issue Once and For All #1134

Open GabrielKS opened 2 weeks ago

GabrielKS commented 2 weeks ago

From time to time, issues come up relating to confusion about the various units systems PowerSystems uses — natural units (which may perhaps be subdivided into mega- vs. kilo-, etc.), device base units, and system base units; where in the latter two cases the units are defined in reference to a per-device or per-system reference quantity. Some of these issues are:

To be thorough, the units issue can be broken down into a few parts:

  1. What units are used when creating components, before the component is attached to a system?
  2. What units are used when calling setters on components?
  3. What units are used when interpreting data from getters?
  4. What units are used in the various built-in printout formats?
  5. What units are used internally (for numerical stability and such)?

In theory, most of these issues can be eliminated by forcing the user to specify units as a keyword argument all over the place, or by having sensible, well-documented defaults and allowing the user to specify units if they want something different. I think a more robust solution, which would put all the units logic in a single place and automatically provide a consistent interface wherever units appear, is something along the lines of Unitful.jl that attaches units directly to quantities themselves. In either case, a significant refactor is required. I'm hoping that for the next major release of PowerSystems, we can solve this problem holistically and give the user a simple mental model of how PowerSystems deals with units systems. Let's use this issue to track our progress.

jd-lara commented 1 week ago

one thing to consider in all of this is the fact that unitful.jl doesn't resolve the challenges of per unit modeling.