Skip to content

Commit e5e02f2

Browse files
committed
remove dynamic branch
1 parent 65c08ae commit e5e02f2

10 files changed

Lines changed: 16 additions & 215 deletions

File tree

.claude/claude.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Core component models and definitions:
4242
- `static_models.jl` -- static component definitions
4343
- `dynamic_generator.jl` -- dynamic generator models
4444
- `dynamic_inverter.jl` -- dynamic inverter models
45-
- `dynamic_branch.jl` -- dynamic branch models
4645
- `dynamic_loads.jl` -- dynamic load models
4746
- `HybridSystem.jl` -- hybrid renewable + storage systems
4847
- `serialization.jl` -- component serialization

docs/make.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pages["Model Library"] = make_model_library(
103103
exceptions = [PSY.DynamicComponent,
104104
PSY.ActivePowerControl,
105105
PSY.ReactivePowerControl,
106-
PSY.DynamicBranch,
107106
PSY.HybridSystem,
108107
PSY.OperationalCost,
109108
PSY.DynamicInverter,
@@ -115,7 +114,6 @@ pages["Model Library"] = make_model_library(
115114
"DynamicInjection" => ["Dynamic Inverter" => "model_library/dynamic_inverter.md",
116115
"Dynamic Generator" => "model_library/dynamic_generator.md",
117116
],
118-
"Branch" => ["Dynamic Lines" => "model_library/dynamic_branch.md"],
119117
"Operating Costs" => ["ThermalGenerationCost" =>"model_library/thermal_generation_cost.md",
120118
"HydroGenerationCost" =>"model_library/hydro_generation_cost.md",
121119
"HydroReservoirCost" =>"model_library/hydro_reservoir_cost.md",

docs/src/how_to/add_new_types.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ deserialization process doesn't know what concrete type to construct.
122122

123123
*Solution*: Encode the concrete type into the serialized dictionary as a string.
124124

125-
*Example*: `serialize` and `deserialize` methods for `DynamicBranch` in
126-
`src/models/dynamic_branch.jl`.
127-
128125
**Problem**: Similar to above in that a field is defined as an abstract type
129126
but the struct is parameterized on the actual concrete type.
130127

docs/src/model_library/dynamic_branch.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/src/tutorials/add_dynamic_data.jl

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -276,56 +276,19 @@ dynamic_inv = DynamicInverter(;
276276

277277
add_component!(threebus_sys, dynamic_inv, gen_103)
278278

279-
# Both generators have now been updated with dynamic data. Let's complete the [`System`](@ref)
280-
# updates by adding dynamic lines.
279+
# Both generators have now been updated with dynamic data.
281280

282-
# ## Adding Dynamic Lines
283-
# !!! warning
284-
# A [`System`](@ref) must have at least two buses and one branch to run a dynamic simulation in
285-
# [`PowerSimulationsDynamics.jl`](https://sienna-platform.github.io/PowerSimulationsDynamics.jl/stable/).
286-
# Let's review the AC branches currently in the system:
287-
288-
get_components(ACBranch, threebus_sys)
289-
290-
# Notice that we have three static [`Line`](@ref) components.
291-
# Let's also print the first line to review its format:
292-
293-
first(get_components(Line, threebus_sys))
294-
295-
# See that these components do not have the fields for dynamic modeling, such as fields for
296-
# different [states](@ref S).
297-
# Let's update that by cycling through these lines and using [`DynamicBranch`](@ref) to extend
298-
# each static line with the necessary fields:
299-
300-
for l in get_components(Line, threebus_sys)
301-
## create a dynamic branch
302-
dyn_branch = DynamicBranch(l)
303-
## add dynamic branch to the system, replacing the static branch
304-
add_component!(threebus_sys, dyn_branch)
305-
end
306-
307-
# Take a look at the AC branches in the system again:
308-
309-
branches = get_components(ACBranch, threebus_sys)
310-
311-
# Notice that now there are 3 [`DynamicBranch`](@ref) components instead of the `Line` components.
312-
# Let's take a look by printing the first one:
313-
314-
first(branches)
315-
316-
# Observe that this is a wrapper around the static data, with the additional states
317-
# data for dynamic modeling.
318281
# Finally, let's print the [`System`](@ref) again to summarize our additions:
319282

320283
threebus_sys
321284

322-
# Verify that the additions were successful, with an added voltage [`Source`](@ref), [`DynamicBranch`](@ref)es
323-
# replacing the static [`Line`](@ref), and two new dynamic components with the generator and inverter models.
285+
# Verify that the additions were successful, with an added voltage [`Source`](@ref) and two new
286+
# dynamic components with the generator and inverter models.
324287

325288
# ## Next Steps
326289
# In this tutorial, you have updated a static system with a second dynamic data layer.
327290
# The data you added can enable a phasor-based simulation using the dynamic generator, or
328-
# a more complex EMT simulation with the additional dynamic inverter and dynamic lines.
291+
# a more complex EMT simulation with the additional dynamic inverter.
329292
# Next, you might like to:
330293
# - Read more about the static and dynamic data layers and the dynamic data format in
331294
# [Dynamic Devices](@ref).

src/PowerSystems.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export DynamicInjection
170170
export DynamicGenerator
171171

172172
export DynamicInverter
173-
export DynamicBranch
174173
export HybridSystem
175174

176175
export GenericDER
@@ -936,7 +935,6 @@ include("models/RoundRotorExponential.jl")
936935
include("models/RoundRotorQuadratic.jl")
937936
include("models/SalientPoleExponential.jl")
938937
include("models/SalientPoleQuadratic.jl")
939-
include("models/dynamic_branch.jl")
940938

941939
include("impedance_correction.jl")
942940
include("models/supplemental_constructors.jl")

src/base.jl

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,6 @@ function deserialize_components!(sys::System, raw)
25902590
)
25912591
deserialize_and_add!(; include_types = [HydroReservoir])
25922592
deserialize_and_add!(; include_types = [Branch])
2593-
deserialize_and_add!(; include_types = [DynamicBranch])
25942593
deserialize_and_add!(; include_types = [ConstantReserveGroup, DynamicInjection])
25952594
deserialize_and_add!(; skip_types = [StaticInjectionSubsystem])
25962595
deserialize_and_add!()
@@ -2613,19 +2612,6 @@ Allow types to implement handling of special cases during deserialization.
26132612
"""
26142613
handle_deserialization_special_cases!(component::Dict, ::Type{<:Component}) = nothing
26152614

2616-
# TODO DT: Do I need to handle this in the new format upgrade?
2617-
#function handle_deserialization_special_cases!(component::Dict, ::Type{DynamicBranch})
2618-
# # IS handles deserialization of supplemental attribues in each component.
2619-
# # In this case the DynamicBranch's composed branch is not part of the system and so
2620-
# # IS will not handle it. It can never attributes.
2621-
# if !isempty(component["branch"]["supplemental_attributes_container"])
2622-
# error(
2623-
# "Bug: serialized DynamicBranch.branch has supplemental attributes: $component",
2624-
# )
2625-
# end
2626-
# return
2627-
#end
2628-
26292615
# This function does an iterative union find to handle the ordering of the reservoir chains
26302616
function _handle_hydro_reservoirs_deserialization_special_cases(
26312617
components::Vector{Dict},
@@ -2831,11 +2817,6 @@ function check_attached_buses(
28312817
return
28322818
end
28332819

2834-
function check_attached_buses(sys::System, component::DynamicBranch)
2835-
check_attached_buses(sys, get_branch(component))
2836-
return
2837-
end
2838-
28392820
function check_attached_buses(sys::System, component::Arc)
28402821
throw_if_not_attached(get_from(component), sys)
28412822
throw_if_not_attached(get_to(component), sys)
@@ -2911,16 +2892,6 @@ function check_component_addition(
29112892
return
29122893
end
29132894

2914-
function check_component_addition(sys::System, dyn_branch::DynamicBranch; kwargs...)
2915-
if !_is_deserialization_in_progress(sys)
2916-
throw_if_not_attached(dyn_branch.branch, sys)
2917-
end
2918-
arc = get_arc(dyn_branch)
2919-
throw_if_not_attached(get_from(arc), sys)
2920-
throw_if_not_attached(get_to(arc), sys)
2921-
return
2922-
end
2923-
29242895
function check_component_addition(sys::System, dyn_injector::DynamicInjection; kwargs...)
29252896
if _is_deserialization_in_progress(sys)
29262897
# Ordering of component addition makes these checks impossible.
@@ -2977,12 +2948,6 @@ function handle_component_addition!(sys::System, component::Branch; kwargs...)
29772948
return
29782949
end
29792950

2980-
function handle_component_addition!(sys::System, component::DynamicBranch; kwargs...)
2981-
_handle_branch_addition_common!(sys, component)
2982-
remove_component!(sys, component.branch)
2983-
return
2984-
end
2985-
29862951
function handle_component_addition!(sys::System, dyn_injector::DynamicInjection; kwargs...)
29872952
static_injector = kwargs[:static_injector]
29882953
static_base_power = _get_base_power(static_injector)

src/models/dynamic_branch.jl

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/models/dynamic_models.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ end
2727

2828
supports_services(::DynamicInjection) = false
2929
get_states(::DynamicInjection) = Vector{Symbol}()
30+
31+
# `states` and `n_states` are fixed structural properties of dynamic components, marked
32+
# `exclude_setter` ("Do not modify") in the struct descriptors so no per-struct setters are
33+
# generated. The struct generator still exports the public `set_states!`/`set_n_states!`
34+
# names, so define them here to reject mutation rather than leave the exports undefined.
35+
set_states!(::Union{DynamicComponent, DynamicInjection}, ::Any) = throw(
36+
ArgumentError("`states` is a fixed property of dynamic components and cannot be set"),
37+
)
38+
set_n_states!(::Union{DynamicComponent, DynamicInjection}, ::Any) = throw(
39+
ArgumentError("`n_states` is a fixed property of dynamic components and cannot be set"),
40+
)
41+
3042
"""
3143
Default implementation of get_state_types for dynamic components. Assumes all states are
3244
Differential

test/test_serialization.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,8 @@
3131

3232
@testset "Test JSON serialization of dynamic inverter" begin
3333
sys = PSB.build_system(PSB.PSYTestSystems, "dynamic_inverter_sys")
34-
35-
# Add a dynamic branch to test that code.
36-
branch = collect(get_components(Branch, sys))[1]
37-
dynamic_branch = DynamicBranch(branch)
38-
add_component!(sys, dynamic_branch)
3934
_, result = validate_serialization(sys)
4035
@test result
41-
42-
test_accessors(dynamic_branch)
4336
end
4437

4538
@testset "Test JSON serialization of StaticGroupReserve" begin

0 commit comments

Comments
 (0)