API Reference

Input Interface

HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_ac_pv_system!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing AC PV system data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_buses!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing bus data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_converters!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing converter data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_dclines!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing DC line data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_dcloads!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing DC load data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_ext_grids!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing external grid data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_generators!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing generator data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_lines!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing line data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_loads!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing load data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_pv_arrays!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing PV array data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_static_generators!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing static generator data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_storages!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing energy storage device data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_switches!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing switch data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_trafo!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing two-winding transformer data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_trafo3ws!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing three-winding transformer data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.load_virtual_power_plants!Method
load_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 case
  • file_path::String: Excel file path
  • sheet_name::String: Worksheet name containing virtual power plant data
source

Data Structure

HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPCType
Definition 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.
source
Base.getindexMethod
getindex(jpc::JPC_3ph, key::String)

Access JPC_3ph components by string key.

Arguments

  • jpc: JPC_3ph structure
  • key: String key representing the component to access

Returns

  • The requested component data
source
Base.getindexMethod
getindex(jpc::JPC, key::String)

Access JPC components by string key.

Arguments

  • jpc: JPC structure
  • key: String key representing the component to access

Returns

  • The requested component data
source
Base.setindex!Method
setindex!(jpc::JPC_3ph, value, key::String)

Set JPC_3ph components by string key.

Arguments

  • jpc: JPC_3ph structure
  • value: Value to assign
  • key: String key representing the component to modify
source
Base.setindex!Method
setindex!(jpc::JPC, value, key::String)

Set JPC components by string key.

Arguments

  • jpc: JPC structure
  • value: Value to assign
  • key: String key representing the component to modify
source

Inner Interface

HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_ac_pv_system_processMethod
JPC_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:

  1. 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
  2. Calculates maximum power output accounting for system losses
  3. Determines the control mode (Voltage Control or MVar Control)
  4. Stores all parameters in a standardized matrix format

The function performs the following steps:

  1. Filters the input case to identify in-service AC-side PV systems
  2. If no in-service systems exist, returns the JPC object unchanged
  3. Creates a matrix to store PV system data
  4. For each PV system:
    • Calculates electrical parameters based on environmental conditions
    • Sets control mode flags
    • Populates the matrix with all required parameters
  5. 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 data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_branch_processMethod
JPC_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:

  1. From bus: Virtual battery bus (created in JPCbatterybus_process)
  2. To bus: Actual bus where the battery is physically connected
  3. Branch resistance: Calculated from battery internal resistance in per unit
  4. Branch reactance: Set to 0 (DC branches have no reactance)
  5. Branch rating: Based on battery package size and open-circuit voltage
  6. Branch status: 1.0 if in service, 0.0 if not
  7. Angle limits: Set to -360° and 360°

The function performs the following steps:

  1. Creates a deep copy of the battery storage data
  2. If no batteries exist, returns the JPC object unchanged
  3. Initializes a matrix to store battery branch data
  4. 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
  5. Appends the processed battery branch data to the JPC object's branchDC field

Arguments

  • case::JuliaPowerCase: The original power system case containing battery storage data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_bus_processMethod
JPC_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:

  1. Bus ID assigned sequentially after existing DC buses
  2. Bus type set to PV node (value 2.0)
  3. No initial power demand or generation
  4. Voltage magnitude initialized to 1.0 p.u.
  5. Voltage angle initialized to 0.0 degrees
  6. Base voltage set to the battery's open-circuit voltage
  7. Area and zone IDs set to 1.0
  8. Voltage limits set to 0.95 (min) and 1.05 (max) p.u.

Arguments

  • case::JuliaPowerCase: The original power system case containing battery storage data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_gens_processMethod
JPC_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:

  1. Makes a deep copy of the storage devices from the input case
  2. If no batteries exist, returns without modifications
  3. Determines virtual node numbers based on the current busDC matrix size
  4. Creates matrices for battery generators and storage information
  5. 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
  6. Adds the battery generators to the JPC's genDC field
  7. Adds the storage information to the JPC's storageetap field

Arguments

  • case::JuliaPowerCase: The original power system case containing battery storage data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_battery_soc_processMethod
JPC_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:

  1. A battery SOC matrix containing parameters related to battery energy storage capabilities
  2. Load entries in the loadDC matrix to represent battery connections to the power system

For each battery, the following SOC parameters are stored:

  1. Bus ID where the battery is connected
  2. Power capacity in MW (maximum charge/discharge rate)
  3. Energy capacity in MWh
  4. Initial state of charge (SOC)
  5. Minimum allowable SOC
  6. Maximum allowable SOC
  7. Round-trip efficiency (0.0-1.0)
  8. Status indicator (1.0 if in service, 0.0 if not)

Additionally, for each battery, the function:

  1. Creates a corresponding load entry in the loadDC matrix
  2. Sets the load ID, bus index, and status parameters
  3. Initializes power values to zero

The function performs the following steps:

  1. Creates a deep copy of the battery storage data
  2. If no batteries exist, returns the JPC object unchanged
  3. Initializes a matrix to store battery SOC data
  4. Populates the SOC matrix with battery parameters
  5. For each battery, creates a corresponding load entry in the loadDC matrix
  6. 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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_branches_processMethod
JPC_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:

  1. AC transmission lines by calling calculatelineparameters()
  2. 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 data
  • jpc::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)

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_buses_processMethod
JPC_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:

  1. Bus ID
  2. Bus type (all initialized as PQ nodes with value 1.0)
  3. Active power demand (PD) in MW (initialized to 0.0)
  4. Reactive power demand (QD) in MVAR (initialized to 0.0)
  5. Active power shunt conductance (GS) in MW (initialized to 0.0)
  6. Reactive power shunt susceptance (BS) in MVAR (initialized to 0.0)
  7. Area ID
  8. Voltage magnitude (VM) in p.u. (initialized to 1.0)
  9. Voltage angle (VA) in degrees (initialized to 0.0)
  10. Base voltage (VN) in kV
  11. Zone ID
  12. Maximum voltage magnitude in p.u.
  13. Minimum voltage magnitude in p.u.

Arguments

  • case::JuliaPowerCase: The original power system case containing bus data
  • jpc::JPC: The JPC object where the processed bus data will be stored

Returns

The updated JPC object with the busAC field populated

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcbranches_processMethod
JPC_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:

  1. From bus index (F_BUS)
  2. To bus index (T_BUS)
  3. Branch resistance in p.u. (BR_R) - calculated from length and ohms/km
  4. Branch reactance in p.u. (BR_X) - set to 0 for DC branches
  5. Branch rating in MVA (RATE_A) - calculated from max current or set to default
  6. 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:

  1. Initializes a matrix to store DC branch data
  2. 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°
  3. Appends the processed branch data to the JPC object
  4. Processes battery branches by calling JPCbatterybranch_process

Arguments

  • case::JuliaPowerCase: The original power system case containing DC branch data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcbuses_processMethod
JPC_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:

  1. Bus ID
  2. Bus type (all initialized as PQ nodes with value 1.0)
  3. Active power demand (PD) in MW (initialized to 0.0)
  4. Reactive power demand (QD) in MVAR (initialized to 0.0)
  5. Active power shunt conductance (GS) in MW (initialized to 0.0)
  6. Reactive power shunt susceptance (BS) in MVAR (initialized to 0.0)
  7. Area ID
  8. Voltage magnitude (VM) in p.u. (initialized to 1.0)
  9. Voltage angle (VA) in degrees (initialized to 0.0)
  10. Base voltage (VN) in kV
  11. Zone ID
  12. Maximum voltage magnitude in p.u.
  13. 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 data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_dcloads_processMethod
JPC_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:

  1. Records its basic properties (index, bus connection)
  2. Calculates active power demand with scaling applied
  3. Stores load model composition (ZIP model percentages)
  4. Updates the connected DC bus with the additional power demand

The function performs the following steps:

  1. Filters the input case to identify in-service DC loads
  2. If no in-service loads exist, returns without modifications
  3. Creates a matrix to store DC load data with 8 columns
  4. For each DC load:
    • Populates the matrix with all required parameters
    • Updates the corresponding bus data with the load's power demand
  5. Adds the processed DC load data to the JPC object's loadDC field

Arguments

  • case::JuliaPowerCase: The original power system case containing DC load data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_gens_processMethod
JPC_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:

  1. External grids (typically serving as slack/reference nodes)
  2. Conventional generators (typically serving as PV nodes)
  3. 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:

  1. Counts the number of each type of generation device
  2. Creates a matrix to store generator data with 26 columns
  3. Processes each type of generator and populates the matrix
  4. Updates bus types in the JPC structure based on generator connections
  5. Removes entries for out-of-service generators
  6. Ensures at least one slack node exists in the system

Arguments

  • case::JuliaPowerCase: The original power system case containing generator data
  • jpc::JPC: The JPC object where the processed generator data will be stored

Returns

None. The JPC object is modified in-place.

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_inverters_processMethod
JPC_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:

  1. Determines the control mode and sets appropriate flags
  2. Calculates AC and DC side power flows considering efficiency losses
  3. Updates bus types for both AC and DC sides based on control mode
  4. Creates generator entries when needed for voltage control
  5. Updates load records for power injection/consumption
  6. 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 data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_loads_processMethod
JPC_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:

  1. Records its basic properties (index, bus connection)
  2. Calculates active and reactive power demand with scaling applied
  3. Stores load model composition (ZIP model percentages)
  4. Accumulates loads connected to the same bus

The function performs the following steps:

  1. Filters the input case to identify in-service AC loads
  2. If no in-service loads exist, returns without modifications
  3. Creates a matrix to store AC load data with 8 columns
  4. For each AC load:
    • Calculates actual power demand with scaling applied
    • Populates the matrix with all required parameters
    • Accumulates loads by bus connection
  5. Adds the processed AC load data to the JPC object's loadAC field
  6. Updates the busAC matrix with the accumulated load values for each bus

Arguments

  • case::JuliaPowerCase: The original power system case containing AC load data
  • jpc::JPC: The JPC object where the processed AC load data will be stored

Returns

None. The JPC object is modified in-place.

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_pv_processMethod
JPC_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:

  1. 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
  2. Stores all parameters in a standardized matrix format

The function performs the following steps:

  1. Filters the input case to identify in-service PV arrays
  2. If no in-service arrays exist, returns without modifications
  3. Creates a matrix to store PV array data with 9 columns
  4. For each PV array:
    • Calculates electrical parameters based on temperature and irradiance conditions
    • Populates the matrix with all required parameters
  5. Adds the processed PV array data to the JPC object's pv field

Arguments

  • case::JuliaPowerCase: The original power system case containing PV array data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JuliaPowerCase2JpcMethod
JuliaPowerCase2Jpc(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:

  1. Merging virtual nodes to ensure a proper network topology
  2. 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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_line_parametersMethod

JPCbatterysoc_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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_transformer2w_parametersMethod
calculate_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:

  1. From bus (high voltage side) and to bus (low voltage side) indices
  2. Per-unit resistance and reactance values, adjusted to system base
  3. Shunt susceptance (typically zero for transformers)
  4. Tap ratio and phase shift angle
  5. Power rating and operational status
  6. Angle limits

The function performs the following steps:

  1. Extracts two-winding transformer data from the input case
  2. If no transformers exist, returns without modification
  3. Creates a branch matrix to store transformer parameters
  4. 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
  5. Adds the transformer branch data to the JPC object's branchAC field

Arguments

  • case::JuliaPowerCase: The original power system case containing transformer data
  • jpc::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

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.merge_virtual_nodesMethod
merge_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:

  1. Identifying virtual nodes and their connections
  2. Creating a mapping strategy for node merging
  3. Updating all elements (lines, transformers, circuit breakers, loads, generators)
  4. Removing virtual nodes and their associated circuit breakers
  5. 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
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.resolve_node_mappingMethod
resolve_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 resolve
  • node_merge_map: A dictionary mapping source nodes to destination nodes

Returns

The final resolved node ID after following all mappings

source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_add_grid_external_sc_impedanceMethod
JPC_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object
  • sequence::Int: Sequence component identifier (0=zero, 1=positive, 2=negative)

Returns

  • jpc_3ph::Utils.JPC_3ph: The updated JPC_3ph object
  • gs_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)
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_branches_processMethod
JPC_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 data
  • jpc_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
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_buses_processMethod
JPC_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 data
  • jpc_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
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_gens_processMethod
JPC_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object to be populated

Side effects

  • Updates jpc_3ph.genAC_1, jpc_3ph.genAC_2, and jpc_3ph.genAC_0 with generator data
  • Updates bus types in jpc_3ph.busAC_1, jpc_3ph.busAC_2, and jpc_3ph.busAC_0
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JPC_3ph_loads_processMethod
JPC_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object to be populated

Side effects

  • Updates jpc_3ph.loadAC_1, jpc_3ph.loadAC_2, and jpc_3ph.loadAC_0 with load data
  • Updates PD and QD fields in bus matrices for all sequence components
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.JuliaPowerCase2Jpc_3phMethod
JuliaPowerCase2Jpc_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 model
  • gs_eg::Vector{Float64}: Conductance values for external grids
  • bs_eg::Vector{Float64}: Susceptance values for external grids

Process

  1. Merges virtual nodes
  2. Creates a new JPC_3ph object
  3. Sets base parameters
  4. Processes bus data for all sequence components
  5. Processes branch data for all sequence components
  6. Processes generator data for all sequence components
  7. Processes load data for all sequence components
  8. Adds external grid short circuit impedance data
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.add_line_sc_impedance_zeroMethod
add_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object
  • branch: The branch matrix to be updated with zero sequence parameters

Returns

  • Updated branch matrix with zero sequence line parameters
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.add_trafo_sc_impedance_zeroMethod
add_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object
  • branch: The branch matrix to be updated with zero sequence parameters

Returns

  • Updated branch matrix with zero sequence transformer parameters
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_3ph_line_parametersMethod
calculate_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object to be populated

Side effects

  • Updates jpc_3ph.branchAC_1 (positive sequence) and jpc_3ph.branchAC_2 (negative sequence)
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_3ph_transformer2w_parametersMethod
calculate_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 data
  • jpc_3ph::Utils.JPC_3ph: The three-phase JPC object to be populated

Side effects

  • Updates jpc_3ph.branchAC_1 (positive sequence) and jpc_3ph.branchAC_2 (negative sequence)
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.calculate_branch_JPC_zeroMethod
calculate_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 data
  • jpc_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
source

Other Functions

HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.extract_islandsMethod
extract_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 island
  • Vector{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
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.extract_islands_acdcMethod
extract_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 island
  • Vector{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
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.find_islandsMethod
find_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)
source
HyDistFlow.TimeDomainPowerFlow.PowerFlow.Utils.find_islands_acdcMethod
find_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
source