-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSY -> PSSE Exporter #32
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using Revise | ||
using Logging | ||
|
||
using PowerSystems | ||
using PowerSystemCaseBuilder | ||
using PowerFlows | ||
|
||
PF = PowerFlows | ||
|
||
function PSY.get_reactive_power_limits(gen::PSY.RenewableFix) | ||
|
||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
gen_pf = PSY.get_power_factor(gen) | ||
|
||
gen_q = PSY.get_max_active_power(gen)*sqrt((1/gen_pf^2)-1) | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return (min = 0.0, max=gen_q) | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
end | ||
|
||
include("/Users/hross2/Julia/psse_exporter/src/support_tools.jl") | ||
|
||
# Import test cases | ||
# sys = build_system(PSIDSystems, "WECC 240 Bus") | ||
file_dir = "/Users/hross2/Julia/twofortybus/Marenas" | ||
sys = with_logger(SimpleLogger(Error)) do # Suppress system loading warnings | ||
System(joinpath(file_dir, "system_240[32].json")) | ||
end | ||
set_units_base_system!(sys, PSY.IS.UnitSystem.SYSTEM_BASE) | ||
|
||
# Load from .raw file | ||
file_dir2 = "/Users/hross2/Julia/psse_exporter/Raw_Export/basic/2024" | ||
sys2 = with_logger(SimpleLogger(Error)) do # Suppress system loading warnings | ||
System(joinpath(file_dir2, "basic 4_solved2.raw")) | ||
end | ||
set_units_base_system!(sys2, PSY.IS.UnitSystem.SYSTEM_BASE) | ||
|
||
# DC Powerflow testing | ||
orig_results = solve_powerflow(DCPowerFlow(), sys) | ||
old_bus_results = Bus_states(sys) | ||
old_branch_results = Branch_states(sys) | ||
orig_flow_results = sort!(orig_results["1"]["flow_results"], [:bus_from, :bus_to, :line_name]) | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
orig_bus_results = orig_results["1"]["bus_results"] | ||
|
||
psse_bus_results = Bus_states(sys2) | ||
psse_branch_results = Branch_states(sys2) | ||
new_results = solve_powerflow(DCPowerFlow(), sys2) | ||
new_flows = sort!(new_results["1"]["flow_results"], [:bus_from, :bus_to, :line_name]) | ||
new_bus_results = new_results["1"]["bus_results"] | ||
|
||
# Getter functions compare | ||
# @show del_Vm = old_bus_results[!, [:bus_number, :Vm]] .- psse_bus_results[!, [:bus_number, :Vm]] # e-6 | ||
# @show del_θ = old_bus_results[!, [:bus_number, :θ]] .- psse_bus_results[!, [:bus_number, :θ]] # e-7 | ||
# @show del_P_flow = old_branch_results[!, [:bus_from, :bus_to, :P_to_from]] .- psse_branch_results[!, [:bus_from, :bus_to, :P_to_from]] # not the same | ||
# @show del_Q_flow = orig_flow_results[!, [:bus_from, :bus_to, :Q_to_from]] .- psse_branch_results[!, [:bus_from, :bus_to, :Q_to_from]] # same | ||
|
||
# DC Powerflow results compare | ||
# @show del_Vm = orig_bus_results[!, [:bus_number, :Vm]] .- new_bus_results[!, [:bus_number, :Vm]] #e -6 | ||
# @show del_θ = orig_bus_results[!, [:bus_number, :θ]] .- new_bus_results[!, [:bus_number, :θ]] # e-15 | ||
# @show del_P_gen = orig_bus_results[!, [:bus_number, :P_gen]] .- new_bus_results[!, [:bus_number, :P_gen]] # e-6 | ||
# @show del_P_load = orig_bus_results[!, [:bus_number, :P_load]] .- new_bus_results[!, [:bus_number, :P_load]] # same | ||
# @show del_P_net = orig_bus_results[!, [:bus_number, :P_net]] .- new_bus_results[!, [:bus_number, :P_net]] # e-6 | ||
# @show del_P_flow = orig_flow_results[!, [:bus_from, :bus_to, :P_to_from]] .- new_flows[!, [:bus_from, :bus_to, :P_to_from]] # e-12 | ||
# @show del_Q_flow = orig_flow_results[!, [:bus_from, :bus_to, :Q_to_from]] .- new_flows[!, [:bus_from, :bus_to, :Q_to_from]] # same | ||
|
||
# AC Powerflow testing | ||
orig_ac_results = solve_ac_powerflow!(sys) | ||
orig_y_bus = PowerFlows.PowerFlowData(ACPowerFlow(), sys; check_connectivity = true).power_network_matrix.data | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
new_ac_results = solve_ac_powerflow!(sys2) | ||
new_y_bus = PowerFlows.PowerFlowData(ACPowerFlow(), sys2; check_connectivity = true).power_network_matrix.data | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
del_y_bus = findall(orig_y_bus .!= new_y_bus) | ||
|
||
quant_del_y_bus = DataFrame(Real = Float64[], Imag = Float64[]) | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for i in del_y_bus | ||
del_r = real(orig_y_bus[i] - new_y_bus[i]) | ||
del_i = imag(orig_y_bus[i] - new_y_bus[i]) | ||
push!(quant_del, [del_r, del_i]) | ||
end | ||
|
||
@show quant_del | ||
|
||
|
||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# gen_busses = ThermalStandard_states(sys2) | ||
# show(gen_busses, allrows=true) | ||
|
||
# gen_busses = sort!(append!(Generator_states(sys), Source_states(sys)), [:bus_number, :active_power]) | ||
# show(gen_busses, allrows=true) | ||
|
||
avaialabe_gens = DataFrame("gen_name" => collect(get_name.(get_components(RenewableFix, sys)))) | ||
show(avaialabe_gens, allrows = true) | ||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
print(get_component(Source, sys, "generator-4242-ND")) | ||
|
||
GabrielKS marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hasn't been cleaned up yet. I will make this a PR after we've cleaned it up and is ready for your review.