Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Update to PSY 0.22 #56

Merged
merged 114 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
7aeebde
update toml file
jd-lara Apr 24, 2020
631b5d7
update to source model
jd-lara Apr 25, 2020
aaa2da5
ignore generators in static injections
jd-lara Apr 25, 2020
992eee9
remove type signature
jd-lara Apr 25, 2020
366f7b0
add files for test01
jd-lara Apr 25, 2020
1349483
add wecc 9 bus data
jd-lara Apr 25, 2020
936c595
add data utils
jd-lara Apr 25, 2020
9234ad2
fix paths in test01
jd-lara Apr 25, 2020
0aad6fb
update testing 2-3
jd-lara Apr 25, 2020
0b04e50
add newer test data
jd-lara Apr 26, 2020
88e4360
WIP update test data files [ci skip]
jd-lara Apr 26, 2020
70527e3
refactor inverter data
jd-lara Apr 27, 2020
f8c5c67
update inverter
jd-lara Apr 27, 2020
5aa4fd5
add updates to PSY v0.16
jd-lara Apr 28, 2020
15e1963
update to source model
jd-lara Apr 25, 2020
371d6ce
remove type signature
jd-lara Apr 25, 2020
76bca3f
add wecc 9 bus data
jd-lara Apr 25, 2020
6e8f859
add newer test data
jd-lara Apr 26, 2020
e46b46b
WIP update test data files [ci skip]
jd-lara Apr 26, 2020
be9d1a2
refactor inverter data
jd-lara Apr 27, 2020
ce10eb7
update inverter
jd-lara Apr 27, 2020
af5db40
Merge branch 'jd/update_test_files' of https://github.com/Energy-MAC/…
jd-lara May 15, 2020
46b90c7
update toml file
jd-lara May 15, 2020
3a752d7
update IS
jd-lara May 15, 2020
44bfbea
add logging
jd-lara May 15, 2020
5b2c0b1
update to PSY to v0.18 test01
jd-lara May 15, 2020
8ad94d7
add 3 bus radial case
jd-lara May 15, 2020
6ec92b4
Update load and source models
May 18, 2020
c26bbc3
update 3Bus Network
May 18, 2020
90857d4
Update tests 01-05
May 18, 2020
73c95df
eliminate sandbox
May 18, 2020
801c960
update runtests and add x0 results
May 18, 2020
6fd3705
[WIP] Finishing test 06
May 18, 2020
83c65f5
update formatting
May 18, 2020
db5a283
Import LinearAlgebra
May 18, 2020
625bf35
Update tolerance
rodrigomha May 18, 2020
9b42464
Update tolerances tests 02-05
rodrigomha May 18, 2020
426d476
Update basepower changes
rodrigomha Jun 3, 2020
091c6b3
update toml file
jd-lara Jul 1, 2020
dd44792
split initialization
jd-lara Jul 1, 2020
cd98795
remove sys base power from test files
jd-lara Jul 1, 2020
564672f
whitespace
jd-lara Jul 1, 2020
9e1c5e3
update to get_Vf
jd-lara Jul 1, 2020
5f31a60
move code
jd-lara Jul 1, 2020
de3b787
delete leeft over file
jd-lara Jul 1, 2020
d7d8eb6
whitespace
jd-lara Jul 6, 2020
36e7444
WIP initialization
jd-lara Jul 6, 2020
c79f61d
wip code reorganization
jd-lara Jul 6, 2020
999ff32
[WIP] Add hack for V_ref on AVRFixed
rodrigomha Jul 6, 2020
5b709dd
Update OMIB without loads
rodrigomha Jul 6, 2020
64f8935
Update Control Refs
rodrigomha Jul 6, 2020
99dce40
[WIP] Add initialization for params
rodrigomha Jul 6, 2020
800f395
Merge pull request #61 from Energy-MAC/jd/initial_conditions
jd-lara Jul 6, 2020
c9a0910
Add prototype of ordered print
rodrigomha Jul 7, 2020
d390dc4
update basepower on models
rodrigomha Jul 7, 2020
d643bb9
update init models
rodrigomha Jul 7, 2020
911cb9f
update initialization procedure
rodrigomha Jul 7, 2020
5cb63e1
update tests
rodrigomha Jul 7, 2020
4a2f597
delete initialize_device
rodrigomha Jul 7, 2020
2216e60
delete init device
rodrigomha Jul 7, 2020
9278b99
add function print init device states ordered
rodrigomha Jul 7, 2020
048adfd
update shaft 5mass init function
rodrigomha Jul 7, 2020
d1901fd
update test 5
rodrigomha Jul 7, 2020
1ef280e
update initialization for inverter
rodrigomha Jul 8, 2020
98a08ae
update darco raw
rodrigomha Jul 8, 2020
3721550
update basepower
rodrigomha Jul 8, 2020
0a4e635
update models
rodrigomha Jul 8, 2020
6920167
update control refs definitions and inner vars
rodrigomha Jul 8, 2020
33aa4a6
update test 06
rodrigomha Jul 8, 2020
de46db5
Update test 7
rodrigomha Jul 8, 2020
b4db00e
init tgtype2
rodrigomha Jul 9, 2020
3cbe744
update voltage guess better and reduce tolerance
rodrigomha Jul 9, 2020
450a551
update test 8
rodrigomha Jul 9, 2020
113ccc1
remove test 9 for now
rodrigomha Jul 9, 2020
a3b661d
eliminate small signal test
rodrigomha Jul 9, 2020
c623977
eliminate requirement for w_sys for ForwardDiff
rodrigomha Jul 9, 2020
1fe0b9b
Give warning for multimachine in small signal and strictly greater th…
rodrigomha Jul 9, 2020
2e560f8
update test 10
rodrigomha Jul 9, 2020
c9ded74
update formatting
rodrigomha Jul 9, 2020
6b8718b
Renaming tests
rodrigomha Jul 9, 2020
c29e1a9
update Anderson Initialization. Remove Kundur models
rodrigomha Jul 9, 2020
f221373
Update tests
rodrigomha Jul 9, 2020
fcb845f
update formatting
rodrigomha Jul 9, 2020
d499b65
update test naming
rodrigomha Jul 9, 2020
d9151b2
Print initial conditions
rodrigomha Jul 9, 2020
987759e
update tests
rodrigomha Jul 10, 2020
40eb124
add bus look up
jd-lara Jul 10, 2020
98b6f40
implement bus lookup
jd-lara Jul 10, 2020
8ca1d23
whitespace
jd-lara Jul 10, 2020
d6a19f1
add file system functions
jd-lara Jul 10, 2020
44e3adc
add file output to simulation
jd-lara Jul 10, 2020
46c13a0
update tests
jd-lara Jul 10, 2020
6a36798
whitespace
jd-lara Jul 10, 2020
fa78534
whitespace
jd-lara Jul 10, 2020
b0e6887
change perturbation structs
jd-lara Jul 10, 2020
63ff267
add AVR Type II initialization
rodrigomha Jul 10, 2020
c3b1a87
Merge pull request #63 from Energy-MAC/jd/required_updates
jd-lara Jul 10, 2020
d3e0687
Merge pull request #64 from Energy-MAC/jd/output_files
jd-lara Jul 10, 2020
7da31d1
update tests to use bus numbers
rodrigomha Jul 10, 2020
5a6e964
remove PSSSimple model
rodrigomha Jul 11, 2020
b478524
Add Inits for TG1 and AVRs
rodrigomha Jul 11, 2020
943ddef
Add test 13
rodrigomha Jul 11, 2020
ce6fbea
Merge pull request #62 from Energy-MAC/rh/init_models
jd-lara Jul 11, 2020
dbef31c
remove functions moved to PSY
jd-lara Jul 11, 2020
9c632e7
Add converter initialization
rodrigomha Jul 11, 2020
cf16366
Merge branch 'jd/update_test_files' of https://github.com/Energy-MAC/…
rodrigomha Jul 11, 2020
87d1b92
[WIP] Update documentation
rodrigomha Jul 13, 2020
35ebadc
update example 01 doc
rodrigomha Jul 13, 2020
af9f422
Update Example 0 and Docs
rodrigomha Jul 13, 2020
18e76a8
Update Example 2 Docs
rodrigomha Jul 13, 2020
565831f
Update Utils
rodrigomha Jul 13, 2020
da379b6
update formatting
rodrigomha Jul 14, 2020
1982d21
update semantics
rodrigomha Jul 14, 2020
7d9d46d
Merge pull request #65 from Energy-MAC/rh/update_docs
jd-lara Jul 14, 2020
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
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LITS"
uuid = "86b0dc02-7903-11e9-325f-f195ca7e6c1a"
version = "0.3.5"
version = "0.4.0"

[deps]
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
Expand All @@ -15,7 +15,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[compat]
DiffEqBase = "6"
ForwardDiff = "~v0.10"
InfrastructureSystems = "~0.6.3"
InfrastructureSystems = "~0.11"
NLsolve = "4"
PowerSystems = "~0.17"
PowerSystems = "~0.21"
julia = "^1.2"
18 changes: 9 additions & 9 deletions docs/src/Examples/example_OMIB.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ As mentioned earlier, we require to create a `Vector` of `PSY.Bus` to define the

```julia
#Define the vector of buses
nodes_OMIB = [
buses_OMIB = [
PSY.Bus(
1, #number
"Bus 1", #Name
Expand All @@ -55,7 +55,7 @@ nodes_OMIB = [
]
```

Note that two buses are defined in the vector `nodes_case1`. It is important that the bus numbers are ordered from ``1`` to ``n``, since that structure will be used to construct the vector of variables. Future versions of `LITS` will allow to relax this assumption. Similarly, to define the branches (that also has some parameters that are currently not used, such as the rate and angle limits):
Note that two buses are defined in the vector `buses_case1`. It is important that the bus numbers are ordered from ``1`` to ``n``, since that structure will be used to construct the vector of variables. Future versions of `LITS` will allow to relax this assumption. Similarly, to define the branches (that also has some parameters that are currently not used, such as the rate and angle limits):

```julia
#Define the vector of branches
Expand All @@ -64,7 +64,7 @@ branch_OMIB = [PSY.Line(
true, #available
0.0, #active power flow initial condition (from-to)
0.0, #reactive power flow initial condition (from-to)
Arc(from = nodes_OMIB[1], to = nodes_OMIB[2]), #Connection between buses
Arc(from = buses_OMIB[1], to = buses_OMIB[2]), #Connection between buses
0.01, #resistance in pu
0.05, #reactance in pu
(from = 0.0, to = 0.0), #susceptance in pu
Expand All @@ -82,7 +82,7 @@ branch_OMIB_fault = [PSY.Line(
true, #available
0.0, #active power flow initial condition (from-to)
0.0, #reactive power flow initial condition (from-to)
Arc(from = nodes_OMIB[1], to = nodes_OMIB[2]), #Connection between buses
Arc(from = buses_OMIB[1], to = buses_OMIB[2]), #Connection between buses
0.02, #resistance in pu
0.1, #reactance in pu
(from = 0.0, to = 0.0), #susceptance in pu
Expand All @@ -101,7 +101,7 @@ Secondly, we will define devices that can inject/withdraw electric current direc
loads_OMIB = [PSY.PowerLoad(
"LBus1", #name
true, #availability
nodes_OMIB[2], #bus
buses_OMIB[2], #bus
PSY.LoadModels.ConstantPower, #type
0.3, #P
0.01, #Q
Expand All @@ -112,7 +112,7 @@ loads_OMIB = [PSY.PowerLoad(
inf_gen_OMIB = [PSY.Source(
"InfBus", #name
true, #availability
nodes_OMIB[1], #bus
buses_OMIB[1], #bus
1.05, #VR
0.0, #VI
0.000005, #Xth
Expand Down Expand Up @@ -157,7 +157,7 @@ pss_OMIB = PSSFixed(0.0) #No PSS without AVR
gen_OMIB = PSY.DynamicGenerator(
1, #Number
"OMIB_Gen", #name
nodes_OMIB[2], #bus
buses_OMIB[2], #bus
1.0, #ω_ref
1.0, #V_ref
0.5, #P_ref
Expand All @@ -184,7 +184,7 @@ sys = PSY.System(
)

#Add the buses to the system
for bus in nodes_OMIB
for bus in buses_OMIB
PSY.add_component!(sys, bus)
end

Expand Down Expand Up @@ -218,7 +218,7 @@ In here, he will use a Three Phase Fault, that is modeled by modifying the admit
#Obtain the Ybus of the faulted system
Ybus_fault = PSY.Ybus(
branch_OMIB_fault, #fault set of lines
nodes_OMIB, #set of buses
buses_OMIB, #set of buses
)[:,:]

#Construct the perturbation
Expand Down
30 changes: 15 additions & 15 deletions docs/src/Examples/example_lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To start we will define the data structures for the network.
### Buses and Branches

```julia
nodes_case9 = [
buses_case9 = [
PSY.Bus(1, "Bus 1", "REF", 0, 1.02, (min = 0.94, max = 1.06), 138),
PSY.Bus(2, "Bus 2", "PV", 0, 1.00, (min = 0.94, max = 1.06), 138),
PSY.Bus(3, "Bus 3", "PQ", 0, 1.00, (min = 0.94, max = 1.06), 138),
Expand All @@ -37,7 +37,7 @@ branch_case9 = [
true,
0.0,
0.0,
Arc(from = nodes_case9[1], to = nodes_case9[3]),
Arc(from = buses_case9[1], to = buses_case9[3]),
0.01,
0.12,
(from = 0.1, to = 0.1),
Expand All @@ -49,7 +49,7 @@ branch_case9 = [
true,
0.0,
0.0,
Arc(from = nodes_case9[1], to = nodes_case9[2]),
Arc(from = buses_case9[1], to = buses_case9[2]),
0.01,
0.12,
(from = 0.1, to = 0.1),
Expand All @@ -61,7 +61,7 @@ branch_case9 = [
true,
0.0,
0.0,
Arc(from = nodes_case9[2], to = nodes_case9[3]),
Arc(from = buses_case9[2], to = buses_case9[3]),
0.02,
0.9,
(from = 0.5, to = 0.5),
Expand All @@ -77,7 +77,7 @@ branch_case9_fault = [
true,
0.0,
0.0,
Arc(from = nodes_case9[1], to = nodes_case9[3]),
Arc(from = buses_case9[1], to = buses_case9[3]),
0.03,
0.36,
(from = 0.03, to = 0.03),
Expand All @@ -89,7 +89,7 @@ branch_case9_fault = [
true,
0.0,
0.0,
Arc(from = nodes_case9[1], to = nodes_case9[2]),
Arc(from = buses_case9[1], to = buses_case9[2]),
0.01,
0.12,
(from = 0.1, to = 0.1),
Expand All @@ -101,7 +101,7 @@ branch_case9_fault = [
true,
0.0,
0.0,
Arc(from = nodes_case9[2], to = nodes_case9[3]),
Arc(from = buses_case9[2], to = buses_case9[3]),
0.02,
0.9,
(from = 0.5, to = 0.5),
Expand All @@ -115,15 +115,15 @@ branch_case9_fault = [

```julia
loads_case9 = [
PowerLoad("Bus1", true, nodes_case9[1], PSY.LoadModels.ConstantPower, 0.5, 0.1, 1.5, 0.8),
PowerLoad("Bus2", true, nodes_case9[2], PSY.LoadModels.ConstantPower, 1.0, 0.3, 1.5, 0.8),
PowerLoad("Bus3", true, nodes_case9[3], PSY.LoadModels.ConstantPower, 0.3, 0.1, 0.5, 0.3),
PowerLoad("Bus1", true, buses_case9[1], PSY.LoadModels.ConstantPower, 0.5, 0.1, 1.5, 0.8),
PowerLoad("Bus2", true, buses_case9[2], PSY.LoadModels.ConstantPower, 1.0, 0.3, 1.5, 0.8),
PowerLoad("Bus3", true, buses_case9[3], PSY.LoadModels.ConstantPower, 0.3, 0.1, 0.5, 0.3),
]

inf_gen_case9 = [PSY.Source(
"InfBus", #name
true, #availability
nodes_case9[1],#bus
buses_case9[1],#bus
1.00, #VR
0.0, #VI
0.000005, #Xth
Expand Down Expand Up @@ -185,7 +185,7 @@ case9_avr = PSY.AVRTypeI(
case9_gen = PSY.DynamicGenerator(
1, #Number
"Case9Gen",
nodes_case9[2], #bus
buses_case9[2], #bus
1.0, # ω_ref,
1.0124, #V_ref
0.6, #P_ref
Expand Down Expand Up @@ -252,7 +252,7 @@ vsc = PSY.CombinedVIwithVZ(
case9_inv = PSY.DynamicInverter(
2, #number
"DARCO", #name
nodes_case9[3], #bus location
buses_case9[3], #bus location
1.0, #ω_ref
0.8, #V_ref
0.5, #P_ref
Expand All @@ -277,7 +277,7 @@ sys = PSY.System(
)

#Add the buses to the system
for bus in nodes_case9
for bus in buses_case9
PSY.add_component!(sys, bus)
end

Expand Down Expand Up @@ -318,7 +318,7 @@ sys2 = PSY.System(
)

#Add the buses to the system
for bus in nodes_case9
for bus in buses_case9
PSY.add_component!(sys2, bus)
end

Expand Down
23 changes: 23 additions & 0 deletions src/LITS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export small_signal_analysis
export get_state_series
export get_voltagemag_series
export print_init_states
export print_device_states
export get_dict_init_states

####################################### Package Imports ####################################
import Logging
Expand All @@ -37,6 +39,8 @@ include("base/definitions.jl")
include("base/ports.jl")
include("base/perturbations.jl")
include("base/small_signal_results.jl")
include("base/simulation_initialization.jl")
include("base/file_system.jl")
include("base/simulation.jl")

#Common Models
Expand Down Expand Up @@ -65,6 +69,24 @@ include("models/inverter_models/converter_models.jl")
include("models/load_models.jl")
include("models/source_models.jl")

#Initialization Parameters
include("initialization/init_device.jl")

#Initialization Generator
include("initialization/generator_components/init_machine.jl")
include("initialization/generator_components/init_shaft.jl")
include("initialization/generator_components/init_avr.jl")
include("initialization/generator_components/init_tg.jl")
include("initialization/generator_components/init_pss.jl")

#Initialization Inverter
include("initialization/inverter_components/init_filter.jl")
include("initialization/inverter_components/init_DCside.jl")
include("initialization/inverter_components/init_converter.jl")
include("initialization/inverter_components/init_frequency_estimator.jl")
include("initialization/inverter_components/init_inner.jl")
include("initialization/inverter_components/init_outer.jl")

#System Model
include("models/system.jl")

Expand All @@ -73,5 +95,6 @@ include("utils/plot_utils.jl")
include("utils/immutable_dicts.jl")
include("utils/print.jl")
include("utils/kwargs_check.jl")
include("utils/logging.jl")

end # module
15 changes: 14 additions & 1 deletion src/base/definitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Vi_cnv_var :: Voltage supplied from the converter in the I-component
VI_inv_var = 11
Vr_cnv_var = 12
Vi_cnv_var = 13
P_ES_var = 14 #Power from energy source
end

Base.to_index(ix::inverter_inner_vars) = Int(ix)
Expand Down Expand Up @@ -100,5 +101,17 @@ const VOLTAGE_BUSES_NO = "voltage_buses_no"
const CURRENT_BUSES_NO = "current_buses_no"
const TOTAL_SHUNTS = "total_shunts"
const AUX_ARRAYS = "aux_arrays"
const LOOKUP = "lookup"

const SIMULATION_ACCEPTED_KWARGS = [:initial_guess, :initialize_simulation]
const SIMULATION_ACCEPTED_KWARGS = [:initial_guess, :initialize_simulation, :system_to_file]

PSY.get_V_ref(value::PSY.AVRFixed) = value.Vf
PSY.set_V_ref!(value::PSY.AVRFixed, val::Float64) = value.Vf = val

get_V_ref_control(value::PSY.DynamicGenerator) = PSY.get_V_ref(PSY.get_avr(value))
Copy link
Member

Choose a reason for hiding this comment

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

We should create these functions on PSY.

get_V_ref_control(value::PSY.DynamicInverter) =
PSY.get_V_ref(PSY.get_reactive_power(PSY.get_outer_control(value)))

get_P_ref_control(value::PSY.DynamicGenerator) = PSY.get_P_ref(PSY.get_prime_mover(value))
get_P_ref_control(value::PSY.DynamicInverter) =
PSY.get_P_ref(PSY.get_active_power(PSY.get_outer_control(value)))
9 changes: 9 additions & 0 deletions src/base/file_system.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function check_folder(folder::String)
!isdir(folder) && throw(IS.ConflictingInputsError("Specified folder is not valid"))
try
mkdir(joinpath(folder, "fake"))
rm(joinpath(folder, "fake"))
catch e
throw(IS.ConflictingInputsError("Specified folder does not have write access [$e]"))
end
end
12 changes: 7 additions & 5 deletions src/base/perturbations.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
abstract type Perturbation end

struct ThreePhaseFault <: Perturbation
mutable struct ThreePhaseFault <: Perturbation
time::Float64
Ybus::SparseMatrixCSC{Complex{Float64}, Int64}
end

get_affect(pert::ThreePhaseFault) =
get_affect(::PSY.System, pert::ThreePhaseFault) =
(integrator) -> PSY.get_ext(integrator.p)["Ybus"] = pert.Ybus

struct ControlReferenceChange <: Perturbation
mutable struct ControlReferenceChange <: Perturbation
time::Float64
device::PSY.DynamicInjection
signal_index::Int64
ref_value::Float64
end

function get_affect(pert::ControlReferenceChange)
function get_affect(system::PSY.System, pert::ControlReferenceChange)
device = PSY.get_component(typeof(pert.device), system, PSY.get_name(pert.device))
pert.device = device
return (integrator) -> begin
control_ref = PSY.get_ext(pert.device)[CONTROL_REFS]
control_ref = PSY.get_ext(device)[CONTROL_REFS]
return control_ref[pert.signal_index] = pert.ref_value
end
end
Loading