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

Hc/fixed admittance #28

Merged
merged 3 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions SiennaOpenAPIModels.jl/src/SiennaOpenAPIModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ include("modelincludes.jl")
@batteries AreaInterchange
@batteries AverageRateCurve
@batteries AverageRateCurveFunctionData
@batteries ComplexNumber
@batteries ConstantReserve
@batteries ConstantReserveGroup
@batteries ConstantReserveNonSpinning
Expand Down
4 changes: 4 additions & 0 deletions SiennaOpenAPIModels.jl/src/sienna_to_json/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ function get_from_to(from_to::NamedTuple{(:from, :to), Tuple{Float64, Float64}})
FromTo(from=from_to.from, to=from_to.to)
end

function get_complex_number(complex_number::ComplexF64)
ComplexNumber(real=real(complex_number), imag=imag(complex_number))
end

function get_startup(startup::Float64)
return ThermalGenerationCostStartUp(startup)
end
Expand Down
13 changes: 12 additions & 1 deletion SiennaOpenAPIModels.jl/src/sienna_to_json/static_injections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ function psy2openapi(renewnondispatch::PSY.RenewableNonDispatch, ids::IDGenerato
)
end

function psy2openapi(fixedadmit::PSY.FixedAdmittance, ids::IDGenerator)
FixedAdmittance(
id=getid!(ids, fixedadmit),
name=fixedadmit.name,
available=fixedadmit.available,
bus=getid!(ids, fixedadmit.bus),
Y=get_complex_number(fixedadmit.Y),
dynamic_injector=getid!(ids, fixedadmit.dynamic_injector),
)
end

function psy2openapi(hydro::PSY.HydroDispatch, ids::IDGenerator)
HydroDispatch(
id=getid!(ids, hydro),
Expand All @@ -143,4 +154,4 @@ function psy2openapi(hydro::PSY.HydroDispatch, ids::IDGenerator)
time_limits=get_up_down(hydro.time_limits),
dynamic_injector=getid!(ids, hydro.dynamic_injector),
)
end
end
9 changes: 9 additions & 0 deletions SiennaOpenAPIModels.jl/test/test-basic-roundtrip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ end
@test test_convert.power_factor == 1.0
@test test_convert.base_power == 101.7
end
@testset "FixedAdmittance to JSON" begin
fixedadmit = PSY.get_component(PSY.FixedAdmittance, RTS_GMLC_RT_sys, "Camus")
@test isa(fixedadmit, PSY.FixedAdmittance)
test_convert = SiennaOpenAPIModels.psy2openapi(fixedadmit, IDGenerator())
test_roundtrip(SiennaOpenAPIModels.FixedAdmittance, test_convert)
@test test_convert.id == 1
@test test_convert.available
@test isnothing(test_convert.dynamic_injector)
end
end

@testset "c_sys5_all" begin
Expand Down