PowerSystems.jl Documentation

repository·main·Indexed 18 days ago

https://github.com/sienna-platform/powersystems.jl

A rigorous data modeling package for power systems analysis providing core data structures for the Sienna Platform ecosystem, including PowerSimulations.jl and PowerSimulationsDynamics.jl. It supports a wide range of device data (generators, transmission, HVDC, storage, loads), parsing for MATPOWER, PSS/e, and RTS-GMLC formats, and a two-layer architecture separating static components from dynamic components. Requires Julia v1.6+.

Tokens
46.5K
Snippets
87
Records
183
Agent score
63%

What's inside PowerSystems.jl

  1. What is a `System`?

    main

    A System is the central data container in PowerSystems.jl. It acts as a registry that holds all Component objects (representing physical or logical elements like generators or buses) and references to their associated time series data.

    Data Storage Model: PowerSystems.jl uses a hybrid storage approach to manage memory efficiently:

    • Volatile Memory: Stores component data and time series references.
    • HDF5 File: Stores the actual time series data.

    This design ensures that only the relevant portions of data are loaded during a query, preventing high memory overhead when working with large datasets.

  2. What is a `Component`?

    main

    A Component is any element within a power system model, such as generators, loads, buses, transmission lines, or services. Components are organized into an abstract type hierarchy based on their role in the system.

    Ownership Constraint: A component instance can belong to at most one System at a time. If you attempt to add a component to a second System without first removing it from its original System, an error will be raised. This prevents silent aliasing and ensures unambiguous data ownership.

  3. Requirements for serializing custom components

    main

    To support serialization and de-serialization of custom components, your struct must meet these criteria:

    1. Subtyping: Your struct should be a subtype of PowerSystems.Component (which is a subtype of InfrastructureSystemsType). This ensures InfrastructureSystems handles the serialize and deserialize methods automatically.
    2. Field Compatibility: All struct fields must be JSON-encodable (numbers, strings, arrays, or dictionaries of these) or handled by custom serialize/deserialize methods.
    3. Constructor: Structs relying on the default deserialize method must have a keyword-only constructor, as the deserialization process splats dictionary key/value pairs into the constructor.
    4. Component References: If a struct contains other PowerSystems.jl components, you must serialize those components as UUIDs rather than actual values. This allows the deserializer to restore references to existing objects rather than creating duplicate copies.

    Troubleshooting Serialization

    • Abstract Fields: If a field is defined as an abstract type, the deserializer won't know which concrete type to build. Solution: Encode the concrete type name as a string in the serialized dictionary.
    • Parameterized Abstract Fields: If a field is an abstract type but the struct is parameterized on a concrete type. Solution: Extract the concrete type from the serialized type information in a custom deserialize method.
  4. Use Forecasts for predicted data

    main

    Forecasts are used for simulation with receding horizons. They are defined by a resolution (time between steps in the horizon), an interval (time between forecast updates), and a horizon (number of forecasted values).

    PowerSystems.jl provides three specific types of forecast structs:

    • Deterministic: A point forecast containing only predicted values without uncertainty.
    • Probabilistic: Stores discretized cumulative distribution functions (CDFs) or probability distribution functions (PDFs) for each time step.
    • Scenarios: Stores a set of probable trajectories, where each trajectory is assumed to have equal probability.
  5. Understand the PowerSystems.jl type hierarchy

    main

    The PowerSystems.jl library uses a structured type hierarchy to categorize different components of a power system. You can explore the complete tree of types by using the TypeTree utility within a Julia environment. This hierarchy is organized around a root type (such as InfrastructureSystemsType) and branches out into specific system components.

    using PowerSystems
    # To visualize the hierarchy, you can use the TypeTree utility
    # (Note: This requires the TypeTree package and specific doc utilities)
    import TypeTree: tt
    # Example of printing the hierarchy under InfrastructureSystemsType
    print(join(tt(PowerSystems.IS.InfrastructureSystemsType), ""))
  6. Supported device data in PowerSystems.jl

    main

    PowerSystems.jl supports a wide range of device data types for modeling power systems, including:

    • Generators: Thermal, Renewable, and Hydro
    • Transmission: Lines, Transformers, DC Lines, and Phase Shifting Transformers
    • HVDC: TwoTerminal and Multiterminal HVDC
    • Topological elements: Buses, Arcs, and Areas
    • Storage: Batteries
    • Load: Static and Curtailable
    • Services: Reserves and Transfers
    • TimeSeries: Deterministic, Scenarios, and Probabilistic
    • Dynamic Models: Dynamic Generators and Dynamic Inverters
  7. Model hydro reservoir topology

    main

    In PowerSystems.jl, hydro reservoir topology is used to define the source and destination of water for hydropower units. This is achieved by linking HydroReservoir components to HydroTurbine or HydroPumpTurbine units through explicit component relationships.

    Key distinction:

    • Reservoir topology describes where water comes from (the hydraulic connection).
    • Penstock grouping (using the HydroPowerPlant supplemental attribute) describes which units share the same intake pipe for plant-level constraints.

    Elevations defined on the reservoir and turbine structs are used to support head calculations for downstream simulation packages.

  8. Understand the role of PowerSystems.jl in the Sienna ecosystem

    main

    PowerSystems.jl provides a rigorous data model using Julia structures for electric energy systems modeling. It is designed to be agnostic to specific mathematical models and serves as the foundation for the following Sienna applications:

    • Sienna\Data: Efficient data input, analysis, and transformation.
    • Sienna\Ops: System scheduling simulations via optimization problems.
    • Sienna\Dyn: System transient analysis (small signal stability and full system dynamic simulations).

    Key capabilities include:

    • An extensible library of data structures for modeling.
    • Parsing tools for common formats like PSS/e (.raw, .dyr), MATPOWER, and configurable tabular data (e.g., CSV).
    • Optimized containers for component data and time series with support for serialization and validation.