This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Energy-MAC/jd/dynamic_branch_refactoring
Jd/dynamic branch refactoring
- Loading branch information
Showing
13 changed files
with
157 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Kirchoff law for buses. | ||
I_gen_r[j]: Real current injection from all generators connected at bus j. | ||
It is zero if no generator is connected at bus j. | ||
I_gen_i[j]: Real current injection from all generators connected at bus j. | ||
It is zero if no generator is connected at bus j. | ||
""" | ||
function kirchoff_laws(sys, V_r, V_i, I_injections_r, I_injections_i, dx) | ||
Ybus = PSY.get_ext(sys)[YBUS] | ||
# TODO: Make more efficent calculation here. Note: BLAS doesn't work because the the type of Vr and Vi is not Matrix of Complex | ||
I_bus = Ybus * (V_r + V_i .* 1im) | ||
I_balance = [real(I_bus) - I_injections_r; imag(I_bus) - I_injections_i] | ||
|
||
voltage_buses = get_voltage_bus_no(sys) | ||
isempty(voltage_buses) && return I_balance | ||
|
||
sys_f = PSY.get_frequency(sys) | ||
ω_b = 2.0 * π * sys_f | ||
n_buses = length(PSY.get_components(PSY.Bus, sys)) | ||
shunts = get_total_shunts(sys) | ||
for bus_no in voltage_buses | ||
shunt_multiplier = shunts[bus_no] | ||
I_balance[bus_no] = | ||
-ω_b * I_balance[bus_no] * shunt_multiplier + ω_b * V_i[bus_no] - dx[bus_no] | ||
I_balance[bus_no + n_buses] = | ||
-ω_b * I_balance[bus_no + n_buses] * shunt_multiplier - ω_b * V_r[bus_no] - | ||
dx[bus_no + n_buses] | ||
end | ||
|
||
return I_balance | ||
end |
Oops, something went wrong.