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://nrel-sienna.github.io/PowerSystems.jl/stable/
BSD 3-Clause "New" or "Revised" License
314 stars 79 forks source link

Unit Conversion Inconsistency Between Types #1164

Open GabrielKS opened 4 months ago

GabrielKS commented 4 months ago

Another sub-issue of https://github.com/NREL-Sienna/PowerSystems.jl/issues/1134 but this one is distinct enough to get its own issue: certain fields are units system-dependent in some structs but not in others. For instance, the result of get_active_power is units system-dependent in ThermalStandard: https://github.com/NREL-Sienna/PowerSystems.jl/blob/71b9bf406ef7001eb5d6b56cc780b73093c9eb54/src/models/generated/ThermalStandard.jl#L147 but not in Source: https://github.com/NREL-Sienna/PowerSystems.jl/blob/71b9bf406ef7001eb5d6b56cc780b73093c9eb54/src/models/generated/Source.jl#L105 making it frustrating to try to write polymorphic code that does the right thing for both.

As an incremental fix before the https://github.com/NREL-Sienna/PowerSystems.jl/issues/1134 overhaul, I propose we work towards the principle that each getter function (a) either performs conversion for all types or does not perform conversion for any types and (b) clearly states which of these it is in its docstrings.

jd-lara commented 4 months ago

This has a fix by defining correct getter in the JSON template.

GabrielKS commented 4 months ago

Update from synchronous discussion: there is a nuance here in that Source doesn't have a base power, so it cannot report quantities in device base units. @rodrigomha will add a base power field to Source.