API Reference
Input Interface
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_ac_pv_system!
— Methodload_ac_pv_system!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load AC PV system data from Excel file and add to power system case. Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing AC PV system data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_buses!
— Methodload_buses!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load bus data from Excel file and add to power system case. Also creates mappings from bus names to integer IDs and from zone names to integer IDs.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing bus data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_converters!
— Methodload_converters!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load converter data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing converter data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_dclines!
— Methodload_dclines!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load DC line data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing DC line data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_dcloads!
— Methodload_dcloads!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load DC load data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing DC load data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_ext_grids!
— Methodload_ext_grids!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load external grid data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing external grid data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_generators!
— Methodload_generators!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load generator data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing generator data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_julia_power_data
— Methodload_julia_power_data(file_path::String)
Load power system data from an Excel file and convert it to a JuliaPowerCase structure.
Parameters:
file_path::String
: Path to the Excel file
Returns:
JuliaPowerCase
: Structure containing all power system components
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_lines!
— Methodload_lines!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load line data from Excel file and add to power system case. Uses case.busnameto_id to map bus names to integer IDs.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing line data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_loads!
— Methodload_loads!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load load data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing load data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_pv_arrays!
— Methodload_pv_arrays!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load PV array data from Excel file and add to power system case. Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing PV array data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_static_generators!
— Methodload_static_generators!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load static generator data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing static generator data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_storages!
— Methodload_storages!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load energy storage device data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing energy storage device data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_switches!
— Methodload_switches!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load switch data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing switch data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_trafo!
— Methodload_trafo!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load two-winding transformer data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing two-winding transformer data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_trafo3ws!
— Methodload_trafo3ws!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load three-winding transformer data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing three-winding transformer data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_virtual_power_plants!
— Methodload_virtual_power_plants!(case::JuliaPowerCase, file_path::String, sheet_name::String)
Load virtual power plant (VPP) data from Excel file and add to power system case.
Parameters:
case::JuliaPowerCase
: Power system casefile_path::String
: Excel file pathsheet_name::String
: Worksheet name containing virtual power plant data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.validate_case
— Methodvalidate_case(case::JuliaPowerCase)
Validate the integrity and consistency of the loaded power system case data.
Data Structure
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC
— TypeDefinition of the JPC structure as one matrix format.
This structure represents a power system case in a one matrix format,
including buses, generators, branches, loads, and other power system components.
Each matrix is sized according to the number of attributes defined in idx.jl.
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph
— TypeDefinition of the JPC_3ph structure for three-phase power flow analysis.
This structure extends the JPC format to support three-phase power flow calculations.
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JuliaPowerCase
— TypeDefinition of the power flow problem structure.
Aligned with JPC structure for consistency.
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.MicrogridPlanningProblem
— TypeDefinition of the Microgrid Planning Problem structure. This structure contains all parameters and variables for microgrid planning optimization.
Base.getindex
— Methodgetindex(jpc::JPC_3ph, key::String)
Access JPC_3ph components by string key.
Arguments
jpc
: JPC_3ph structurekey
: String key representing the component to access
Returns
- The requested component data
Base.getindex
— Methodgetindex(jpc::JPC, key::String)
Access JPC components by string key.
Arguments
jpc
: JPC structurekey
: String key representing the component to access
Returns
- The requested component data
Base.setindex!
— Methodsetindex!(jpc::JPC_3ph, value, key::String)
Set JPC_3ph components by string key.
Arguments
jpc
: JPC_3ph structurevalue
: Value to assignkey
: String key representing the component to modify
Base.setindex!
— Methodsetindex!(jpc::JPC, value, key::String)
Set JPC components by string key.
Arguments
jpc
: JPC structurevalue
: Value to assignkey
: String key representing the component to modify
Inner Interface
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_ac_pv_system_process
— MethodJPC_ac_pv_system_process(case::JuliaPowerCase, jpc::JPC)
Processes AC-side photovoltaic (PV) systems from a JuliaPowerCase and converts them to JPC format.
This function extracts information about AC-connected PV systems from the input case, performs necessary calculations to determine their electrical characteristics, and stores the processed data in the JPC structure.
For each AC-side PV system, the function:
- Calculates operating voltages and currents based on panel configuration and conditions:
- Maximum power point voltage (Vmpp) adjusted for series-connected panels
- Open-circuit voltage (Voc) adjusted for temperature and series connections
- Short-circuit current (Isc) adjusted for temperature, irradiance, and parallel connections
- Maximum power point current (Impp) adjusted for parallel-connected panels
- Calculates maximum power output accounting for system losses
- Determines the control mode (Voltage Control or MVar Control)
- Stores all parameters in a standardized matrix format
The function performs the following steps:
- Filters the input case to identify in-service AC-side PV systems
- If no in-service systems exist, returns the JPC object unchanged
- Creates a matrix to store PV system data
- For each PV system:
- Calculates electrical parameters based on environmental conditions
- Sets control mode flags
- Populates the matrix with all required parameters
- Adds the processed PV system data to the JPC object's pv_acsystem field
Arguments
case::JuliaPowerCase
: The original power system case containing AC-side PV system datajpc::JPC
: The JPC object where the processed PV system data will be stored
Returns
The updated JPC object with AC-side PV system data in the pv_acsystem field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_branch_process
— MethodJPC_battery_branch_process(case::JuliaPowerCase, jpc::JPC)
Processes battery storage branches from a JuliaPowerCase and converts them to JPC format.
This function creates DC branch connections between virtual battery buses and their corresponding actual buses in the power system. Each battery is represented as a DC branch with the following characteristics:
- From bus: Virtual battery bus (created in JPCbatterybus_process)
- To bus: Actual bus where the battery is physically connected
- Branch resistance: Calculated from battery internal resistance in per unit
- Branch reactance: Set to 0 (DC branches have no reactance)
- Branch rating: Based on battery package size and open-circuit voltage
- Branch status: 1.0 if in service, 0.0 if not
- Angle limits: Set to -360° and 360°
The function performs the following steps:
- Creates a deep copy of the battery storage data
- If no batteries exist, returns the JPC object unchanged
- Initializes a matrix to store battery branch data
- For each battery:
- Identifies the actual bus where the battery is connected
- Calculates the virtual bus ID for the battery
- Retrieves the base voltage from the actual bus
- Calculates the per unit resistance using the base impedance
- Sets all branch parameters including status and ratings
- Appends the processed battery branch data to the JPC object's branchDC field
Arguments
case::JuliaPowerCase
: The original power system case containing battery storage datajpc::JPC
: The JPC object where the battery branch data will be added
Returns
The updated JPC object with battery branches added to the branchDC field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_bus_process
— MethodJPC_battery_bus_process(case::JuliaPowerCase, jpc::JPC)
Processes battery storage data from a JuliaPowerCase and creates virtual DC buses for them in the JPC format.
This function extracts battery storage information from the input case, creates virtual DC buses to represent the batteries in the power system model, and appends these buses to the existing DC bus matrix in the JPC object.
Each battery is represented as a virtual DC bus with the following characteristics:
- Bus ID assigned sequentially after existing DC buses
- Bus type set to PV node (value 2.0)
- No initial power demand or generation
- Voltage magnitude initialized to 1.0 p.u.
- Voltage angle initialized to 0.0 degrees
- Base voltage set to the battery's open-circuit voltage
- Area and zone IDs set to 1.0
- Voltage limits set to 0.95 (min) and 1.05 (max) p.u.
Arguments
case::JuliaPowerCase
: The original power system case containing battery storage datajpc::JPC
: The JPC object where the virtual battery buses will be added
Returns
The updated JPC object with virtual battery buses added to the busDC field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_gens_process
— MethodJPC_battery_gens_process(case::JuliaPowerCase, jpc::JPC)
Process battery storage devices and create virtual generators for them in the JPC structure.
This function creates virtual generators to represent battery storage devices in the power system model. Each battery is assigned a virtual bus and corresponding generator parameters based on its characteristics.
The function performs the following steps:
- Makes a deep copy of the storage devices from the input case
- If no batteries exist, returns without modifications
- Determines virtual node numbers based on the current busDC matrix size
- Creates matrices for battery generators and storage information
- For each battery:
- Assigns a virtual bus number
- Calculates power capacity based on battery parameters
- Sets generator parameters (power limits, voltage setpoint, status, etc.)
- Configures storage-specific parameters
- Adds the battery generators to the JPC's genDC field
- Adds the storage information to the JPC's storageetap field
Arguments
case::JuliaPowerCase
: The original power system case containing battery storage datajpc::JPC
: The JPC object where the virtual generators will be added
Returns
The updated JPC object with battery virtual generators added to genDC and storage information added to storageetap
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_soc_process
— MethodJPC_battery_soc_process(case::JuliaPowerCase, jpc::JPC)
Processes battery state of charge (SOC) data from a JuliaPowerCase and converts it to JPC format.
This function extracts battery storage information from the input case and creates two data structures:
- A battery SOC matrix containing parameters related to battery energy storage capabilities
- Load entries in the loadDC matrix to represent battery connections to the power system
For each battery, the following SOC parameters are stored:
- Bus ID where the battery is connected
- Power capacity in MW (maximum charge/discharge rate)
- Energy capacity in MWh
- Initial state of charge (SOC)
- Minimum allowable SOC
- Maximum allowable SOC
- Round-trip efficiency (0.0-1.0)
- Status indicator (1.0 if in service, 0.0 if not)
Additionally, for each battery, the function:
- Creates a corresponding load entry in the loadDC matrix
- Sets the load ID, bus index, and status parameters
- Initializes power values to zero
The function performs the following steps:
- Creates a deep copy of the battery storage data
- If no batteries exist, returns the JPC object unchanged
- Initializes a matrix to store battery SOC data
- Populates the SOC matrix with battery parameters
- For each battery, creates a corresponding load entry in the loadDC matrix
- Adds the processed battery SOC data to the JPC object's storage field
Arguments
case::JuliaPowerCase
: The original power system case containing battery storage datajpc::JPC
: The JPC object where the battery SOC data will be stored
Returns
The updated JPC object with battery SOC data in the storage field and corresponding load entries in the loadDC field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_branches_process
— MethodJPC_branches_process(case::JuliaPowerCase, jpc::JPC)
Processes AC branch data from a JuliaPowerCase and converts it to JPC format.
This function handles the calculation and conversion of various branch elements in the power system to the format required by JPC. It processes:
- AC transmission lines by calling calculatelineparameters()
- Two-winding transformers by calling calculatetransformer2wparameters()
The function is structured to potentially handle different sequence components (positive, negative, zero), though the conditional logic for sequence selection is currently commented out. In its current implementation, it processes only the positive sequence components.
Note: The commented code suggests that for sequence 1 or 2 (positive or negative sequence), the function processes lines and transformers with their standard parameters, while for sequence 0 (zero sequence), it would call a different function (calculatebranchJPC_zero).
Arguments
case::JuliaPowerCase
: The original power system case containing branch datajpc::JPC
: The JPC object where the processed branch data will be stored
Returns
The updated JPC object with branch data processed (implicitly, as the jpc object is modified in place)
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_buses_process
— MethodJPC_buses_process(case::JuliaPowerCase, jpc::JPC)
Processes AC bus data from a JuliaPowerCase and converts it to JPC format.
This function extracts AC bus information from the input case, transforms it into the standard matrix format required by JPC, and stores it in the JPC object. Each bus is represented as a row in the matrix with the following columns:
- Bus ID
- Bus type (all initialized as PQ nodes with value 1.0)
- Active power demand (PD) in MW (initialized to 0.0)
- Reactive power demand (QD) in MVAR (initialized to 0.0)
- Active power shunt conductance (GS) in MW (initialized to 0.0)
- Reactive power shunt susceptance (BS) in MVAR (initialized to 0.0)
- Area ID
- Voltage magnitude (VM) in p.u. (initialized to 1.0)
- Voltage angle (VA) in degrees (initialized to 0.0)
- Base voltage (VN) in kV
- Zone ID
- Maximum voltage magnitude in p.u.
- Minimum voltage magnitude in p.u.
Arguments
case::JuliaPowerCase
: The original power system case containing bus datajpc::JPC
: The JPC object where the processed bus data will be stored
Returns
The updated JPC object with the busAC field populated
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcbranches_process
— MethodJPC_dcbranches_process(case::JuliaPowerCase, jpc::JPC)
Processes DC branch data from a JuliaPowerCase and converts it to JPC format.
This function extracts DC branch information from the input case, transforms it into the standard matrix format required by JPC, and stores it in the JPC object. Each DC branch is represented as a row in the matrix with the following columns:
- From bus index (F_BUS)
- To bus index (T_BUS)
- Branch resistance in p.u. (BR_R) - calculated from length and ohms/km
- Branch reactance in p.u. (BR_X) - set to 0 for DC branches
- Branch rating in MVA (RATE_A) - calculated from max current or set to default
- Branch status (BR_STATUS) - 1.0 if in service, 0.0 if not
7-14. Various parameters including angle limits (ANGMIN, ANGMAX)
The function performs the following steps:
- Initializes a matrix to store DC branch data
- For each DC branch in the case:
- Identifies the from and to bus indices
- Calculates the base impedance using the from bus base voltage
- Converts resistance from ohms to per unit values
- Sets the branch parameters including status and ratings
- Sets angle limits to -360° and 360°
- Appends the processed branch data to the JPC object
- Processes battery branches by calling JPCbatterybranch_process
Arguments
case::JuliaPowerCase
: The original power system case containing DC branch datajpc::JPC
: The JPC object where the processed DC branch data will be stored
Returns
The updated JPC object with the branchDC field populated and battery branch data processed
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcbuses_process
— MethodJPC_dcbuses_process(case::JuliaPowerCase, jpc::JPC)
Processes DC bus data from a JuliaPowerCase and converts it to JPC format.
This function extracts DC bus information from the input case, transforms it into the standard matrix format required by JPC, and stores it in the JPC object. Each DC bus is represented as a row in the matrix with the following columns:
- Bus ID
- Bus type (all initialized as PQ nodes with value 1.0)
- Active power demand (PD) in MW (initialized to 0.0)
- Reactive power demand (QD) in MVAR (initialized to 0.0)
- Active power shunt conductance (GS) in MW (initialized to 0.0)
- Reactive power shunt susceptance (BS) in MVAR (initialized to 0.0)
- Area ID
- Voltage magnitude (VM) in p.u. (initialized to 1.0)
- Voltage angle (VA) in degrees (initialized to 0.0)
- Base voltage (VN) in kV
- Zone ID
- Maximum voltage magnitude in p.u.
- Minimum voltage magnitude in p.u.
After processing the basic DC bus data, this function also calls JPCbatterybus_process to handle battery-specific bus information.
Arguments
case::JuliaPowerCase
: The original power system case containing DC bus datajpc::JPC
: The JPC object where the processed DC bus data will be stored
Returns
The updated JPC object with the busDC field populated and battery bus data processed
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcloads_process
— MethodJPC_dcloads_process(case::JuliaPowerCase, jpc::JPC)
Process DC load data from a JuliaPowerCase and convert it to JPC format.
This function extracts information about DC loads from the input case, applies scaling factors, and stores the processed data in the JPC structure. It also updates the power demand values in the corresponding DC bus data.
For each DC load, the function:
- Records its basic properties (index, bus connection)
- Calculates active power demand with scaling applied
- Stores load model composition (ZIP model percentages)
- Updates the connected DC bus with the additional power demand
The function performs the following steps:
- Filters the input case to identify in-service DC loads
- If no in-service loads exist, returns without modifications
- Creates a matrix to store DC load data with 8 columns
- For each DC load:
- Populates the matrix with all required parameters
- Updates the corresponding bus data with the load's power demand
- Adds the processed DC load data to the JPC object's loadDC field
Arguments
case::JuliaPowerCase
: The original power system case containing DC load datajpc::JPC
: The JPC object where the processed DC load data will be stored
Returns
The updated JPC object with DC load data in the loadDC field and updated busDC power demands
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_gens_process
— MethodJPC_gens_process(case::JuliaPowerCase, jpc::JPC)
Process generator data from a JuliaPowerCase and convert it to JPC format.
This function processes three types of generation devices:
- External grids (typically serving as slack/reference nodes)
- Conventional generators (typically serving as PV nodes)
- Static generators (typically serving as PQ nodes, but can be PV nodes if controllable)
For each generation device, the function:
- Extracts its parameters from the input case
- Converts them to the format required by JPC
- Assigns appropriate bus types based on generator characteristics
- Ensures proper handling of power outputs, limits, and ramp rates
The function performs the following steps:
- Counts the number of each type of generation device
- Creates a matrix to store generator data with 26 columns
- Processes each type of generator and populates the matrix
- Updates bus types in the JPC structure based on generator connections
- Removes entries for out-of-service generators
- Ensures at least one slack node exists in the system
Arguments
case::JuliaPowerCase
: The original power system case containing generator datajpc::JPC
: The JPC object where the processed generator data will be stored
Returns
None. The JPC object is modified in-place.
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_inverters_process
— MethodJPC_inverters_process(case::JuliaPowerCase, jpc::JPC)
Process converters/inverters from a JuliaPowerCase and integrate them into the JPC format.
This function handles the conversion of power electronic converters (inverters) from the JuliaPowerCase format to the JPC format, updating the relevant bus types and power flow parameters according to each inverter's control mode.
For each in-service inverter, the function:
- Determines the control mode and sets appropriate flags
- Calculates AC and DC side power flows considering efficiency losses
- Updates bus types for both AC and DC sides based on control mode
- Creates generator entries when needed for voltage control
- Updates load records for power injection/consumption
- Handles ZIP load model parameters through weighted averaging
The function supports the following control modes:
- δs_Us: Slack bus on AC side, P node on DC side
- Ps_Qs: PQ node on AC side, P node on DC side
- Ps_Us: PV node on AC side, P node on DC side
- Udc_Qs: PQ node on AC side, slack node on DC side
- Udc_Us: PV node on AC side, slack node on DC side
- DroopUdcQs: PQ node on AC side with droop control, slack node on DC side
- DroopUdcUs: PV node on AC side with droop control, slack node on DC side
Arguments
case::JuliaPowerCase
: The original power system case containing converter datajpc::JPC
: The JPC object where the processed converter data will be stored
Returns
The updated JPC object with converter data integrated into the appropriate fields
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_loads_process
— MethodJPC_loads_process(case::JuliaPowerCase, jpc::JPC)
Process AC load data from a JuliaPowerCase and convert it to JPC format.
This function extracts information about AC loads from the input case, applies scaling factors, and stores the processed data in the JPC structure. It also updates the power demand values in the corresponding AC bus data.
For each AC load, the function:
- Records its basic properties (index, bus connection)
- Calculates active and reactive power demand with scaling applied
- Stores load model composition (ZIP model percentages)
- Accumulates loads connected to the same bus
The function performs the following steps:
- Filters the input case to identify in-service AC loads
- If no in-service loads exist, returns without modifications
- Creates a matrix to store AC load data with 8 columns
- For each AC load:
- Calculates actual power demand with scaling applied
- Populates the matrix with all required parameters
- Accumulates loads by bus connection
- Adds the processed AC load data to the JPC object's loadAC field
- Updates the busAC matrix with the accumulated load values for each bus
Arguments
case::JuliaPowerCase
: The original power system case containing AC load datajpc::JPC
: The JPC object where the processed AC load data will be stored
Returns
None. The JPC object is modified in-place.
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_pv_process
— MethodJPC_pv_process(case::JuliaPowerCase, jpc::JPC)
Process photovoltaic (PV) array data from a JuliaPowerCase and convert it to JPC format.
This function extracts information about PV arrays from the input case, performs necessary calculations to determine their electrical characteristics based on environmental conditions, and stores the processed data in the JPC structure.
For each PV array, the function:
- Calculates key electrical parameters adjusted for environmental conditions:
- Open-circuit voltage (Voc) adjusted for temperature and series connections
- Maximum power point voltage (Vmpp) adjusted for series-connected panels
- Short-circuit current (Isc) adjusted for temperature, irradiance, and parallel connections
- Maximum power point current (Impp) adjusted for irradiance and parallel-connected panels
- Stores all parameters in a standardized matrix format
The function performs the following steps:
- Filters the input case to identify in-service PV arrays
- If no in-service arrays exist, returns without modifications
- Creates a matrix to store PV array data with 9 columns
- For each PV array:
- Calculates electrical parameters based on temperature and irradiance conditions
- Populates the matrix with all required parameters
- Adds the processed PV array data to the JPC object's pv field
Arguments
case::JuliaPowerCase
: The original power system case containing PV array datajpc::JPC
: The JPC object where the processed PV array data will be stored
Returns
The updated JPC object with PV array data in the pv field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JuliaPowerCase2Jpc
— MethodJuliaPowerCase2Jpc(case::Utils.JuliaPowerCase)
Converts a JuliaPowerCase object to a JPC (Julia Power Case) format for power flow analysis.
This function performs a complete transformation of the power system case data, processing all components and preparing them for power flow calculations. The conversion process includes:
- Merging virtual nodes to ensure a proper network topology
- Creating and populating a new JPC object with the following data:
- Basic parameters (base MVA)
- AC buses
- DC buses
- AC branches (lines and transformers)
- DC branches
- AC generators
- Battery systems (as DC generators)
- Battery state of charge data
- AC loads
- DC loads
- PV array data
- Inverters (AC/DC converters)
- AC-connected PV systems
Arguments
case::Utils.JuliaPowerCase
: The original power system case data
Returns
A fully populated JPC object ready for power flow analysis
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_line_parameters
— MethodJPCbatterysoc_process(case::JuliaPowerCase, jpc::JPC) Processes battery state of charge (SOC) data from a JuliaPowerCase and converts it to JPC format. This function extracts battery storage information from the input case and creates two data structures:
A battery SOC matrix containing parameters related to battery energy storage capabilities Load entries in the loadDC matrix to represent battery connections to the power system
For each battery, the following SOC parameters are stored:
Bus ID where the battery is connected Power capacity in MW (maximum charge/discharge rate) Energy capacity in MWh Initial state of charge (SOC) Minimum allowable SOC Maximum allowable SOC Round-trip efficiency (0.0-1.0) Status indicator (1.0 if in service, 0.0 if not)
Additionally, for each battery, the function:
Creates a corresponding load entry in the loadDC matrix Sets the load ID, bus index, and status parameters Initializes power values to zero
The function performs the following steps:
Creates a deep copy of the battery storage data If no batteries exist, returns the JPC object unchanged Initializes a matrix to store battery SOC data Populates the SOC matrix with battery parameters For each battery, creates a corresponding load entry in the loadDC matrix Adds the processed battery SOC data to the JPC object's storage field
Arguments
case::JuliaPowerCase: The original power system case containing battery storage data jpc::JPC: The JPC object where the battery SOC data will be stored
Returns The updated JPC object with battery SOC data in the storage field and corresponding load entries in the loadDC field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_transformer2w_parameters
— Methodcalculate_transformer2w_parameters(case::JuliaPowerCase, jpc::JPC)
Processes two-winding transformer data from a JuliaPowerCase and converts it to JPC format.
This function extracts two-winding transformer information from the input case and creates branch entries in the JPC object to represent transformers in the power system model.
For each transformer, the following parameters are calculated and stored:
- From bus (high voltage side) and to bus (low voltage side) indices
- Per-unit resistance and reactance values, adjusted to system base
- Shunt susceptance (typically zero for transformers)
- Tap ratio and phase shift angle
- Power rating and operational status
- Angle limits
The function performs the following steps:
- Extracts two-winding transformer data from the input case
- If no transformers exist, returns without modification
- Creates a branch matrix to store transformer parameters
- For each transformer:
- Identifies the high and low voltage bus connections
- Calculates impedance parameters based on transformer specifications
- Adjusts values for the system base power
- Accounts for parallel transformers if present
- Sets default values for tap ratio, phase shift, and other parameters
- Adds the transformer branch data to the JPC object's branchAC field
Arguments
case::JuliaPowerCase
: The original power system case containing transformer datajpc::JPC
: The JPC object where the transformer branch data will be stored
Returns
The updated JPC object with transformer data added to the branchAC field
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.merge_virtual_nodes
— Methodmerge_virtual_nodes(case::JuliaPowerCase)
Merges virtual nodes in a power system case and updates all connected elements.
This function identifies virtual nodes (nodes with "_虚拟节点" in their name), merges them with their connected real nodes, and updates all references in the system. The process includes:
- Identifying virtual nodes and their connections
- Creating a mapping strategy for node merging
- Updating all elements (lines, transformers, circuit breakers, loads, generators)
- Removing virtual nodes and their associated circuit breakers
- Merging loads connected to the same bus after node consolidation
Arguments
case::JuliaPowerCase
: The original power system case
Returns
A new JuliaPowerCase with virtual nodes merged and all references updated
Note
- Virtual nodes are identified by the substring "_虚拟节点" in their names
- At least two connections are required for a virtual node to be merged
- Self-loops created during merging are disabled
- Loads at the same bus after merging are consolidated into a single load
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.resolve_node_mapping
— Methodresolve_node_mapping(node_id, node_merge_map)
Resolves the final mapping of a node by traversing through a node merge map.
This function follows the chain of node mappings to find the final destination node. It handles multiple levels of redirection by iteratively looking up each node ID in the mapping until it finds a node that doesn't have a further mapping.
Arguments
node_id
: The initial node ID to resolvenode_merge_map
: A dictionary mapping source nodes to destination nodes
Returns
The final resolved node ID after following all mappings
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_add_grid_external_sc_impedance
— MethodJPC_3ph_add_grid_external_sc_impedance(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph, sequence::Int)
Add external grid short circuit impedance to the appropriate sequence component.
This function calculates and adds short circuit impedance for external grids to the specified sequence component. For positive sequence (sequence=1), no additional impedance is added. For negative (sequence=2) and zero (sequence=0) sequences, short circuit impedance is added as shunt admittance to the connected buses.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC objectsequence::Int
: Sequence component identifier (0=zero, 1=positive, 2=negative)
Returns
jpc_3ph::Utils.JPC_3ph
: The updated JPC_3ph objectgs_eg::Vector{Float64}
: Conductance values for external grids (only for sequence=2)bs_eg::Vector{Float64}
: Susceptance values for external grids (only for sequence=2)
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_branches_process
— MethodJPC_3ph_branches_process(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Process branch data from a JuliaPowerCase and populate the JPC_3ph object with sequence component branch data.
This function calculates parameters for lines and transformers for all sequence components (positive, negative, and zero).
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Returns
jpc_3ph::Utils.JPC_3ph
: The updated JPC_3ph object with branch data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_buses_process
— MethodJPC_3ph_buses_process(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Process bus data from a JuliaPowerCase and populate the JPC_3ph object with sequence component bus data.
This function creates bus matrices for positive, negative, and zero sequence components. For positive sequence, voltage magnitude is initialized to 1.0 p.u., while for negative and zero sequence components, voltage magnitude is initialized to 0.0 p.u.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Returns
jpc_3ph::Utils.JPC_3ph
: The updated JPC_3ph object with bus data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_gens_process
— MethodJPC_3ph_gens_process(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Process generator data from a JuliaPowerCase and populate the JPC_3ph object with sequence component generator data.
This function handles different types of generators including conventional generators, static generators, and external grids. It also sets appropriate bus types (PQ, PV, or reference) based on the generators.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Side effects
- Updates
jpc_3ph.genAC_1
,jpc_3ph.genAC_2
, andjpc_3ph.genAC_0
with generator data - Updates bus types in
jpc_3ph.busAC_1
,jpc_3ph.busAC_2
, andjpc_3ph.busAC_0
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_loads_process
— MethodJPC_3ph_loads_process(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Process load data from a JuliaPowerCase and populate the JPC_3ph object with sequence component load data.
This function handles different types of loads (wye and delta connected) and distributes their power appropriately across sequence components. For balanced loads, only positive sequence components have non-zero values.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Side effects
- Updates
jpc_3ph.loadAC_1
,jpc_3ph.loadAC_2
, andjpc_3ph.loadAC_0
with load data - Updates PD and QD fields in bus matrices for all sequence components
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JuliaPowerCase2Jpc_3ph
— MethodJuliaPowerCase2Jpc_3ph(case::JuliaPowerCase)
Convert a JuliaPowerCase object to a three-phase JPC_3ph object.
This function processes a power system case in JuliaPowerCase format and converts it into a three-phase sequence component model (JPC_3ph) for three-phase power flow analysis.
Arguments
case::JuliaPowerCase
: The power system case data in JuliaPowerCase format
Returns
jpc_3ph::JPC_3ph
: The converted three-phase power system modelgs_eg::Vector{Float64}
: Conductance values for external gridsbs_eg::Vector{Float64}
: Susceptance values for external grids
Process
- Merges virtual nodes
- Creates a new JPC_3ph object
- Sets base parameters
- Processes bus data for all sequence components
- Processes branch data for all sequence components
- Processes generator data for all sequence components
- Processes load data for all sequence components
- Adds external grid short circuit impedance data
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.add_line_sc_impedance_zero
— Methodadd_line_sc_impedance_zero(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph, branch)
Add zero sequence impedance parameters for lines to the branch matrix.
This function calculates and adds zero sequence parameters for transmission lines. If specific zero sequence data is not available, it approximates using positive sequence data.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC objectbranch
: The branch matrix to be updated with zero sequence parameters
Returns
- Updated branch matrix with zero sequence line parameters
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.add_trafo_sc_impedance_zero
— Methodadd_trafo_sc_impedance_zero(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph, branch)
Add zero sequence impedance parameters for transformers to the branch matrix.
This function calculates and adds zero sequence parameters for two-winding transformers, considering different transformer vector groups (winding connections). For some connections, transformers are represented as shunt admittances rather than branches in the zero sequence network.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC objectbranch
: The branch matrix to be updated with zero sequence parameters
Returns
- Updated branch matrix with zero sequence transformer parameters
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_3ph_line_parameters
— Methodcalculate_3ph_line_parameters(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Calculate line parameters for positive and negative sequence components.
This function processes line data from a JuliaPowerCase and converts it to JPC format for both positive and negative sequence components. For most lines, negative sequence parameters are equal to positive sequence parameters.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Side effects
- Updates
jpc_3ph.branchAC_1
(positive sequence) andjpc_3ph.branchAC_2
(negative sequence)
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_3ph_transformer2w_parameters
— Methodcalculate_3ph_transformer2w_parameters(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Calculate two-winding transformer parameters for positive and negative sequence components.
This function processes two-winding transformer data from a JuliaPowerCase and converts it to JPC format for both positive and negative sequence components. For most transformers, negative sequence parameters are equal to positive sequence parameters.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Side effects
- Updates
jpc_3ph.branchAC_1
(positive sequence) andjpc_3ph.branchAC_2
(negative sequence)
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_branch_JPC_zero
— Methodcalculate_branch_JPC_zero(case::JuliaPowerCase, jpc_3ph::Utils.JPC_3ph)
Calculate zero sequence branch parameters for lines and transformers.
This function creates the zero sequence branch matrix and populates it with parameters for lines and transformers. Zero sequence parameters often differ significantly from positive sequence parameters, especially for transformers with different winding connections.
Arguments
case::JuliaPowerCase
: The power system case datajpc_3ph::Utils.JPC_3ph
: The three-phase JPC object to be populated
Returns
jpc_3ph::Utils.JPC_3ph
: The updated JPC_3ph object with zero sequence branch data
Other Functions
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.extract_islands
— Methodextract_islands(jpc::JPC)
Extract electrically isolated islands from a power system case.
This function identifies separate electrical islands in the power system and creates individual JPC objects for each valid island. It also identifies isolated buses that don't belong to any energized island.
Arguments
jpc::JPC
: Power system case data structure
Returns
Vector{JPC}
: List of JPC objects, each representing an energized islandVector{Int}
: List of isolated buses (buses not connected to any energized island)
Notes
- An island is considered valid/energized if it contains at least one generator or reference bus
- Islands with only PQ buses and no generation are considered isolated
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.extract_islands_acdc
— Methodextract_islands_acdc(jpc::JPC)
Extract electrically isolated islands from a hybrid AC-DC power system case.
This function identifies separate electrical islands in a hybrid AC-DC power system and creates individual JPC objects for each valid island. It handles the complexity of interconnected AC and DC subsystems through converters.
Arguments
jpc::JPC
: Power system case data structure containing both AC and DC components
Returns
Vector{JPC}
: List of JPC objects, each representing an energized islandVector{Int}
: List of isolated AC buses (buses not connected to any energized island)
Notes
- An island is considered valid/energized if it contains at least one generator, reference bus, or has a power source in its connected DC subsystem
- Islands with only PQ buses and no generation capability are considered isolated
- The function checks for potential issues like multiple reference nodes or batteries in constant Vdc mode that might cause power flow calculation errors
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.find_islands
— Methodfind_islands(jpc::JPC)
Find electrically isolated islands in an AC power system.
This function identifies connected components in the power network by analyzing the branch connections between buses. It also identifies isolated PQ buses and islands that contain only PQ buses (no generators or reference buses).
Arguments
jpc::JPC
: Power system case data structure
Returns
Vector{Vector{Int}}
: List of islands (each containing bus IDs)Vector{Int}
: List of isolated buses (PQ buses with no connections)
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.find_islands_acdc
— Methodfind_islands_acdc(jpc::JPC)
Find electrically isolated islands in a hybrid AC-DC power system.
This function extends the island detection to handle both AC and DC subsystems, including converter connections between them. It identifies connected components across the entire network and classifies islands based on their generation capabilities.
Arguments
jpc::JPC
: Power system case data structure containing both AC and DC components
Returns
Vector{Vector{Int}}
: List of AC islands (each containing bus IDs)Vector{Int}
: List of isolated AC buses (PQ buses with no viable connections)
Notes
- Islands with only PQ buses and no generation capability (either directly or through DC connections) are considered isolated
- If no DC buses exist, the function falls back to the standard AC island detection