Adding additional fields

All components currently implemented in PowerSystems.jl have an ext field that contains an empty Dictionary. This empty dictionary can be accessed with the method get_ext. shows an example of adding additional data to the ThermalStandard structs for other modeling requirements.

This method is useful if there is no requirement to create new behaviours for components of a particular type but additional fields are required. A simple example is the addition of geographic information if needed.

julia> using PowerSystems
julia> const PSY = PowerSystemsPowerSystems
julia> file_dir = joinpath(pkgdir(PowerSystems), "docs", "src", "tutorials", "tutorials_data")"/home/runner/work/PowerSystems.jl/PowerSystems.jl/docs/src/tutorials/tutorials_data"
julia> system = System(joinpath(file_dir, "case5_re.m"))┌ Error: Matlab parser skipping line number 85 consisting of: │ }; └ @ PowerSystems ~/work/PowerSystems.jl/PowerSystems.jl/src/parsers/im_io/matlab.jl:64 [ Info: Correcting vm in bus 1 to 1.07762 to match generator set-point [ Info: Correcting vm in bus 3 to 1.1 to match generator set-point [ Info: Correcting vm in bus 4 to 1.06414 to match generator set-point [ Info: Correcting vm in bus 10 to 1.06907 to match generator set-point [ Info: extending matpower format with data: areas 1x3 [ Info: extending matpower format with data: gen_name 7x4 [ Info: extending matpower format by appending matrix "gen_name" in to "gen" [ Info: reversing the orientation of branch 6 (4, 3) to be consistent with other parallel branches [ Info: removing 1 cost terms from generator 4: [4000.0, 0.0] [ Info: removing 1 cost terms from generator 1: [1400.0, 0.0] [ Info: removing 1 cost terms from generator 5: [1000.0, 0.0] [ Info: removing 1 cost terms from generator 2: [1500.0, 0.0] [ Info: removing 3 cost terms from generator 6: Float64[] [ Info: removing 3 cost terms from generator 7: Float64[] [ Info: removing 1 cost terms from generator 3: [3000.0, 0.0] ┌ Info: Constructing System from Power Models │ data["name"] = "nesta_case5_pjm" └ data["source_type"] = "matpower" [ Info: Reading bus data [ Info: Reading Load data in PowerModels dict to populate System ... [ Info: Reading LoadZones data in PowerModels dict to populate System ... [ Info: Reading generator data [ Info: Reading branch data [ Info: Reading branch data [ Info: Reading DC Line data [ Info: Reading storage data System ┌───────────────────┬─────────────┐ │ Property │ Value │ ├───────────────────┼─────────────┤ │ Name │ │ │ Description │ │ │ System Units Base │ SYSTEM_BASE │ │ Base Power │ 100.0 │ │ Base Frequency │ 60.0 │ │ Num Components │ 30 │ └───────────────────┴─────────────┘ Static Components ┌──────────────────────────┬───────┬────────────────────────┬───────────────┐ │ Type │ Count │ Has Static Time Series │ Has Forecasts │ ├──────────────────────────┼───────┼────────────────────────┼───────────────┤ │ ACBus │ 5 │ false │ false │ │ Arc │ 6 │ false │ false │ │ Area │ 1 │ false │ false │ │ Line │ 5 │ false │ false │ │ LoadZone │ 1 │ false │ false │ │ PhaseShiftingTransformer │ 2 │ false │ false │ │ PowerLoad │ 3 │ false │ false │ │ RenewableDispatch │ 2 │ false │ false │ │ ThermalStandard │ 5 │ false │ false │ └──────────────────────────┴───────┴────────────────────────┴───────────────┘
julia> for g in get_components(ThermalStandard, system) external_field = get_ext(g) external_field["my_data"] = 1.0 end
julia> gen_alta = get_component(ThermalStandard, system, "Alta")Alta (ThermalStandard): name: Alta available: true status: true bus: bus1 (ACBus) active_power: 0.4 reactive_power: 0.3 rating: 0.5 active_power_limits: (min = 0.0, max = 0.4) reactive_power_limits: (min = -0.3, max = 0.3) ramp_limits: (up = 0.0, down = 0.0) operation_cost: ThreePartCost base_power: 100.0 time_limits: nothing must_run: false prime_mover_type: PrimeMovers.CT = 8 fuel: ThermalFuels.NATURAL_GAS = 7 services: 0-element Vector{Service} time_at_status: 10000.0 dynamic_injector: nothing ext: Dict{String, Any}("my_data" => 1.0) time_series_container: InfrastructureSystems.SystemUnitsSettings: base_value: 100.0 unit_system: UnitSystem.SYSTEM_BASE = 0
julia> my_data = get_ext(gen_alta)["my_data"]1.0