Skip to content
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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions src/psse_exporter/compare_psse_results.jl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Collaborator

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.

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)

Check warning on line 10 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L10

Added line #L10 was not covered by tests

GabrielKS marked this conversation as resolved.
Show resolved Hide resolved
gen_pf = PSY.get_power_factor(gen)

Check warning on line 12 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L12

Added line #L12 was not covered by tests

gen_q = PSY.get_max_active_power(gen)*sqrt((1/gen_pf^2)-1)

Check warning on line 14 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L14

Added line #L14 was not covered by tests
GabrielKS marked this conversation as resolved.
Show resolved Hide resolved

return (min = 0.0, max=gen_q)

Check warning on line 16 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L16

Added line #L16 was not covered by tests
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"))

Check warning on line 25 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L25

Added line #L25 was not covered by tests
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"))

Check warning on line 32 in src/psse_exporter/compare_psse_results.jl

View check run for this annotation

Codecov / codecov/patch

src/psse_exporter/compare_psse_results.jl#L32

Added line #L32 was not covered by tests
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
Loading
Loading