Detailed API
HarmonicPowerFlow
— ModuleA simple and fast module to solve the harmonic power flow problem for given distribution grids.
HarmonicPowerFlow.PowerGrid
— TypeStruct containing information about nodes and lines.
HarmonicPowerFlow.Settings
— TypeStruct containing simulation settings.
HarmonicPowerFlow.THD
— MethodTHD(u)
Calculate the Total Harmonic Distortion at all nodes.
THD is a measure for the amount of voltage distortion present at a node. This function calculates two alternative definitions
- THD_F: relative to fundamental, more commonly used and
- THD_R: RMS, relative to all frequencies
- THD_40: relative to fundamental, only until h = 40 (or 39) as used by standard EN 61000.
HarmonicPowerFlow.admittance_matrices
— Methodadmittance_matrices(nodes, lines, harmonics)
Build the nodal admittance matrices (admittance laplacian) for all harmonics.
Admittance scales with frequency: Xh = Xf * h. Return a dictionary of DataFrames.
HarmonicPowerFlow.barplot_THD
— Methodbarplot_THD(u, nodeID; h_min=1, h_max=0, yticks=0:0.1:1)
Barplot of harmonic voltage magnitudes at one node.
HarmonicPowerFlow.build_harmonic_jacobian
— Methodbuild_harmonic_jacobian(net, settings, u, LY, NE)
Construct harmonic Jacobian J
containing all derivatives of power and current mismatches wrt voltages from harmonic state vector.
HarmonicPowerFlow.create_nodes_manually
— Methodcreatenodesmanually()
Manually create a nodes DataFrame.
Note that linear nodes are added first, then nonlinear ones. Within the linear ones, first add PV, then PQ nodes. First node contains the slack.
HarmonicPowerFlow.current_balance
— Methodcurrent_balance(net, settings, u, LY, NE)
Evaluate current balance at all nodes and frequencies, except linear nodes at fundamental frequency.
HarmonicPowerFlow.current_injections
— Methodcurrent_injections(nodes, nodeID, u, NE, harmonics)
Calculate the harmonic current injections at one node.
Uses coupled or uncoupled method based on dimensions of NE.
HarmonicPowerFlow.fund_jacobian
— Methodfund_jacobian(net, u, LY)
Construct fundamental Jacobian, containing powers derived wrt voltages.
HarmonicPowerFlow.fund_mismatch
— Methodfund_mismatch(net, u, LY)
Evaluate active and reactive power mismatch at fundamental frequency.
HarmonicPowerFlow.fund_state_vec
— Methodfund_state_vec(net, u)
Take the voltage DataFrame u
and return a vector of voltage phases and magnitudes.
HarmonicPowerFlow.harmonic_mismatch
— Methodharmonic_mismatch(net, settings, u, LY, NE)
Combine current and power mismatch to construct harmonic mismatch vector f
.
HarmonicPowerFlow.harmonic_state_vec
— Methodharmonic_state_vec(net, u, harmonics)
Construct harmonic state vector x
from fundamental and harmonic voltages.
HarmonicPowerFlow.heatmap_NE
— Methodheatmap_NE(nodes, settings; save=png)
Export heatmap indicating magnitude of Norton equivalent parameters tp .png
or .pdf
.
HarmonicPowerFlow.hpf
— Methodhpf(net, settings)
Solve the harmonic power flow problem for a given PowerGrid
and Settings
.
HarmonicPowerFlow.import_Norton_Equivalents
— Functionimport_Norton_Equivalents(nodes, settings, folder_path="devices\")
Import NE parameters for all nonlinear devices in nodes from folder devices.
HarmonicPowerFlow.init_power_grid
— Methodinit_power_grid(nodes, lines, settings)
Create a PowerGrid struct from nodes and lines DataFrames and converts all quantities to the p.u. system.
Indexing (c, m, n) could be done better by being based on number of nodes of certain type. It could make sense to also add LY to PowerGrid struct.
HarmonicPowerFlow.init_settings
— Methodinit_settings(coupled, harmonics; ...)
Initialize settings struct.
Default values:
- base_frequency=50
- base_voltage=230
- base_power=1000
- thresh_f = 1e-6
- maxiterf = 30
- thresh_h=1e-4
- maxiterh=50
- v_f=1
- ϕ_f = 0
- v_h=0.1
- ϕ_h=0
HarmonicPowerFlow.init_voltages
— Methodinit_voltages(nodes, settings)
Initialize voltages for all nodes and harmonics using guesses from on Settings
.
HarmonicPowerFlow.limits
— Methodlimits(u, nodeID)
Check if harmonic limits according to EN 50160 and EN 61000 are met at node.
HarmonicPowerFlow.pf
— Functionpf(net, settings, LY, plt_convergence = false)
Perform fundamental power flow, iterate until mismatch is smaller than threshold.
HarmonicPowerFlow.update_fund_voltages!
— Methodupdate_fund_voltages!(net, u, x)
Write new voltages from x
to u
.
HarmonicPowerFlow.update_harmonic_voltages!
— Methodupdate_fund_voltages!(net, u, x, settings)
Write new voltages from x
to u
for all harmonics.
HarmonicPowerFlow.update_state_vec!
— Methodupdate_state_vec!(J, x, f)
Perform Newton-Raphson iteration and update the fundamental state vector.