File IO
General Data Formats
PowerModels.parse_file — Functionparse_file(io::String; import_all=false, validate=true)
parse_file(io::IO; import_all=false, validate=true, filetype="json")Parse a file into a PowerModels data structure.
The supported file types are:
.m: a Matpower file.raw: a PTI (PSS(R)E-v33).json: a PowerModels.jl JSON file
All fields from PTI files will be imported if import_all is true.
If validate = true, PowerModels will validate the imported data for correctness.
PowerModels.parse_json — FunctionParses json from iostream or string
Matpower Data Files
The following method is the main exported methods for parsing Matpower data files:
PowerModels.parse_matpower — FunctionParses the matpwer data from either a filename or an IO object
We also provide the following (internal) helper methods:
PowerModels._add_dcline_costs! — Methodadds dcline costs, if gen costs exist
PowerModels._export_cost_data — MethodExport cost data
PowerModels._export_extra_data — FunctionExport fields of a component type
PowerModels._get_default — FunctionGet a default value for dict entry
PowerModels._matpower_to_powermodels! — MethodConverts a Matpower dict into a PowerModels dict
PowerModels._merge_bus_name_data! — Methodmerges bus name data into buses, if names exist
PowerModels._merge_cost_data! — Methodmerges generator cost functions into generator data, if costs exist
PowerModels._merge_generic_data! — Methodmerges Matpower tables based on the table extension syntax
PowerModels._mp2pm_branch! — Methodsets all branch transformer taps to 1.0, to simplify branch models
PowerModels._mp2pm_dcline! — Methodadds pmin and pmax values at to and from buses
PowerModels._split_loads_shunts! — Method_split_loads_shunts!(data)Seperates Loads and Shunts in data under separate "load" and "shunt" keys in the PowerModels data format. Includes references to originating bus via "loadbus" and "shuntbus" keys, respectively.
PowerModels.export_matpower — MethodExport power network data to a file in the matpower format
PowerModels.export_matpower — MethodExport power network data in the matpower format
PowerModels.export_matpower — MethodExport power network data in the matpower format
PowerModels.parse_matpower — MethodParses the matpwer data from either a filename or an IO object
PTI Data Files (PSS/E)
Note: This feature supports the parsing and conversion of PTI files into a PowerModels format for the following power network components: buses, loads, shunts (fixed and approximation of switched), branches, two-winding and three-winding transformers (incl. magnetizing admittance), generators, two-terminal dc lines, and voltage source converter HVDC lines.
The following method is the main exported method for parsing PSS(R)E v33 specified PTI data files:
PowerModels.parse_pti — Functionparse_pti(filename::String)Open PTI raw file given by filename, returning a Dict of the data parsed into the proper types.
parse_pti(io::IO)Reads PTI data in io::IO, returning a Dict of the data parsed into the proper types.
PowerModels.parse_psse — Functionparse_psse(filename::String; kwargs...)::DictParses directly from file
function parse_psse(io::IO; kwargs...)::DictParses directly from iostream
The following internal helper methods are also provided:
PowerModels._create_starbus_from_transformer — Methodcreate_starbus(pm_data, transformer)Creates a starbus from a given three-winding transformer. "sourceid" is given by `["busi", "name", "I", "J", "K", "CKT"]` where "bus_i" and "name" are the modified names for the starbus, and "I", "J", "K" and "CKT" come from the originating transformer, in the PSS(R)E transformer specification.
PowerModels._find_max_bus_id — Method_find_max_bus_id(pm_data)Returns the maximum bus id in pm_data
PowerModels._get_bus_value — Method_get_bus_value(bus_i, field, pm_data)Returns the value of field of bus_i from the PowerModels data. Requires "bus" Dict to already be populated.
PowerModels._import_remaining_comps! — MethodImports remaining top level component lists from data_in into data_out, excluding keys in exclude
PowerModels._import_remaining_keys! — MethodImports remaining keys from a source component into detestation component, excluding keys in exclude
PowerModels._init_bus! — Method_init_bus!(bus, id)Initializes a bus of id id with default values given in the PSS(R)E specification.
PowerModels._psse2pm_branch! — Method_psse2pm_branch!(pm_data, pti_data)Parses PSS(R)E-style Branch data into a PowerModels-style Dict. "source_id" is given by ["I", "J", "CKT"] in PSS(R)E Branch specification.
PowerModels._psse2pm_bus! — Method_psse2pm_bus!(pm_data, pti_data)Parses PSS(R)E-style Bus data into a PowerModels-style Dict. "source_id" is given by ["I", "NAME"] in PSS(R)E Bus specification.
PowerModels._psse2pm_dcline! — Method_psse2pm_dcline!(pm_data, pti_data)Parses PSS(R)E-style Two-Terminal and VSC DC Lines data into a PowerModels compatible Dict structure by first converting them to a simple DC Line Model. For Two-Terminal DC lines, "sourceid" is given by ["IPR", "IPI", "NAME"] in the PSS(R)E Two-Terminal DC specification. For Voltage Source Converters, "sourceid" is given by ["IBUS1", "IBUS2", "NAME"], where "IBUS1" is "IBUS" of the first converter bus, and "IBUS2" is the "IBUS" of the second converter bus, in the PSS(R)E Voltage Source Converter specification.
PowerModels._psse2pm_generator! — Method_psse2pm_generator!(pm_data, pti_data)Parses PSS(R)E-style Generator data in a PowerModels-style Dict. "source_id" is given by ["I", "ID"] in PSS(R)E Generator specification.
PowerModels._psse2pm_load! — Method_psse2pm_load!(pm_data, pti_data)Parses PSS(R)E-style Load data into a PowerModels-style Dict. "source_id" is given by ["I", "ID"] in the PSS(R)E Load specification.
PowerModels._psse2pm_shunt! — Method_psse2pm_shunt!(pm_data, pti_data)Parses PSS(R)E-style Fixed and Switched Shunt data into a PowerModels-style Dict. "source_id" is given by ["I", "ID"] for Fixed Shunts, and ["I", "SWREM"] for Switched Shunts, as given by the PSS(R)E Fixed and Switched Shunts specifications.
PowerModels._psse2pm_transformer! — Method_psse2pm_transformer!(pm_data, pti_data)Parses PSS(R)E-style Transformer data into a PowerModels-style Dict. "source_id" is given by ["I", "J", "K", "CKT", "winding"], where "winding" is 0 if transformer is two-winding, and 1, 2, or 3 for three-winding, and the remaining keys are defined in the PSS(R)E Transformer specification.
PowerModels._pti_to_powermodels! — Method_pti_to_powermodels!(pti_data)Converts PSS(R)E-style data parsed from a PTI raw file, passed by pti_data into a format suitable for use internally in PowerModels. Imports all remaining data from the PTI file if import_all is true (Default: false).
PowerModels.parse_psse — Methodfunction parse_psse(io::IO; kwargs...)::DictParses directly from iostream
PowerModels.parse_psse — Methodparse_psse(filename::String; kwargs...)::DictParses directly from file
PowerModels._export_remaining! — MethodExport remaining keys of a componet
PowerModels._get_line_elements — Method_get_line_elements(line)Internal function. Uses regular expressions to extract all separate data elements from a line of a PTI file and populate them into an Array{String}. Comments, typically indicated at the end of a line with a '/' character, are also extracted separately, and Array{Array{String}, String} is returned.
PowerModels._parse_elements — MethodThis is an experimental method for parsing elements and setting defaults at the same time. It is not currently working but would reduce memory allocations if implemented correctly.
PowerModels._parse_line_element! — Method_parse_line_element!(data, elements, section)Internal function. Parses a single "line" of data elements from a PTI file, as given by elements which is an array of the line, typically split at ,. Elements are parsed into data types given by section and saved into data::Dict.
PowerModels._parse_pti_data — Method_parse_pti_data(data_string, sections)Internal function. Parse a PTI raw file into a Dict, given the data_string of the file and a list of the sections in the PTI file (typically given by default by get_pti_sections().
PowerModels._pm2psse_2w_tran — FunctionParses PM transformer branch to PSS(R) E-style. returns a dict with all the keys later pass this dict to printptistr with differents _transformerdtypes
Reference: PSSE 33 - POM - 5-20
PowerModels._pm2psse_3w_tran — MethodParses 3 PM transformer branch to PSS(R) E-style.
PowerModels._pm2psse_area_interchange — MethodParses PM area interchange to PSS(R) E-style
PowerModels._pm2psse_branch — MethodParses PM branch data to PSS(R) E-style.
PowerModels._pm2psse_bus — MethodParses PM Bus data to PSS(R)E-style.
PowerModels._pm2psse_fixed_shunt — MethodParses PM fixed shunt to PSS(R)E-style
PowerModels._pm2psse_generator — MethodParses PM generator data to PSS(R)E-style.
PowerModels._pm2psse_header — MethodCreate a header for the case
PowerModels._pm2psse_interarea — MethodParses PM interarea to PSS(R) E-style
PowerModels._pm2psse_load — MethodParses PM Load data to PSS(R)E-style.
PowerModels._pm2psse_owner — MethodParses PM zone to PSS(R) E-style
PowerModels._pm2psse_switched_shunt — MethodParses PM fixed shunt to PSS(R)E-style
PowerModels._pm2psse_tt_dc_line — MethodParses PM dcline to PSS(R)E style
PowerModels._pm2psse_zone — MethodParses PM zone to PSS(R) E-style
PowerModels._populate_defaults! — Method_populate_defaults!(pti_data)Internal function. Populates empty fields with PSS(R)E PTI v33 default values
PowerModels._print_pti_str — MethodGiven a PTI component dict print it in the .raw file
PowerModels.export_pti — MethodExport power network data to a file in the pti format
PowerModels.export_pti — MethodExport power network data in the pti format
PowerModels.export_pti — Methodexport_pti(io::IO, data::Dict{String, Any})Export PowerModels network data dictionary to the as a power flow raw data acording to the pti format RAW V33.
It is highly recommend to export the PowerModel data dictionary in the same format as the source data.
The export_pti function exports the essential components of a network:
- Buses
- Loads
- Fixed Shunts
- Generators
- Non Tansformers Branchs
- Transformers (Two-Windings and Three-Windings)
- Switched Shunts (aproximate)
If the PowerModels was parsed from a pti file with the import_all=true parameter: data = parse_file(case3.raw, import_all=true)
It will export these aditionals items:
- Header Options
- Comment Lines
- Zone Data
- Area Data
- Owner Data
- Switched Shunts (with block steps)
Things that are not exported:
- TNEP network specification
- Generation Cost Data
- Storage
- Switches
- DC Lines (future work, #754)
Things that are not exported if you use import_all = true to make the PowerModel data dict:
- FACTS (Maybe in future work)
- GNE (No intentions to export it)
- Inter Area Transfer Data (No intentions to export it)
PowerModels.parse_pti — Methodparse_pti(io::IO)Reads PTI data in io::IO, returning a Dict of the data parsed into the proper types.
PowerModels.parse_pti — Methodparse_pti(filename::String)Open PTI raw file given by filename, returning a Dict of the data parsed into the proper types.