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

Commit

Permalink
Merge pull request #22 from Energy-MAC/rh/update_test
Browse files Browse the repository at this point in the history
Rh/update tests
  • Loading branch information
jd-lara authored Feb 1, 2020
2 parents 5da69b3 + 77b623c commit cdff2c1
Show file tree
Hide file tree
Showing 36 changed files with 2,041 additions and 3,930 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/formatter_code.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
main_paths = ["./src", "./test"]
main_paths = ["."]
for main_path in main_paths
for folder in readdir(main_path)
@show folder_path = joinpath(main_path, folder)
if isfile(folder_path)
!occursin(".jl", folder_path) && continue
end
format(folder_path;
whitespace_ops_in_indices = true,
remove_extra_newlines = true,
verbose = true
)
end
format(
main_path;
whitespace_ops_in_indices = true,
remove_extra_newlines = true,
verbose = true,
always_for_in = true,
)
end
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ docs/site/
*.ipynb

Manifest.toml
.vscode

################################################################################
# Operating systems #
Expand Down
16 changes: 8 additions & 8 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ makedocs(
format = Documenter.HTML(),
sitename = "LITS.jl",
pages = Any[ # Compat: `Any` for 0.4 compat
"Home"=>"index.md",
"Home" => "index.md",
# "User Guide" => "man/guide.md",
"Tutorials"=>Any[
"Tutorial 1: OMIB"=>"Examples/example_OMIB.md",
"Tutorial 2: Dynamic Lines"=>"Examples/example_lines.md",
"Tutorials" => Any[
"Tutorial 1: OMIB" => "Examples/example_OMIB.md",
"Tutorial 2: Dynamic Lines" => "Examples/example_lines.md",
],
"Models"=>Any[
"Network"=>"Models/network.md",
"Generator"=>"Models/gens.md",
"Inverter"=>"Models/inverters.md",
"Models" => Any[
"Network" => "Models/network.md",
"Generator" => "Models/gens.md",
"Inverter" => "Models/inverters.md",
],
],
)
Expand Down
20 changes: 12 additions & 8 deletions src/base/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ function Simulation(
)

initialized = false
n_buses = length(PSY.get_components(PSY.Bus, system))
DAE_vector = collect(falses(n_buses * 2))
_index_dynamic_system!(DAE_vector, system)
DAE_vector = _index_dynamic_system!(system)
var_count = get_variable_count(system)

if initialize_simulation
Expand All @@ -35,7 +33,6 @@ function Simulation(

dx0 = zeros(var_count)
callback_set, tstops = _build_perturbations(perturbations::Vector{<:Perturbation})

prob = DiffEqBase.DAEProblem(
system_model!,
dx0,
Expand Down Expand Up @@ -103,7 +100,13 @@ function _calculate_initial_conditions(sys::PSY.System, initial_guess::Vector{Fl
sys, #Parameters
0.0,
) #time equals to zero.
sys_solve = NLsolve.nlsolve(inif!, initial_guess) #Solve using initial guess x0
sys_solve = NLsolve.nlsolve(
inif!,
initial_guess,
xtol = :1e-9,
ftol = :1e-9,
method = :trust_region,
) #Solve using initial guess x0
if !NLsolve.converged(sys_solve)
@warn("Initialization failed, initial conditions do not meet conditions for an stable equilibrium")
end
Expand Down Expand Up @@ -196,8 +199,9 @@ function _make_device_index!(device::PSY.DynamicInjection)
return
end

function _index_dynamic_system!(DAE_vector::Vector{Bool}, sys::PSY.System)

function _index_dynamic_system!(sys::PSY.System)
n_buses = length(PSY.get_components(PSY.Bus, sys))
DAE_vector = collect(falses(n_buses * 2))
global_state_index = Dict{String,Dict{Symbol,Int64}}()
n_buses = length(PSY.get_components(PSY.Bus, sys))
state_space_ix = n_buses * 2
Expand Down Expand Up @@ -274,7 +278,7 @@ function _index_dynamic_system!(DAE_vector::Vector{Bool}, sys::PSY.System)
sys_ext[YBUS] = Ybus
sys.internal.ext = sys_ext

return
return DAE_vector
end

get_injection_pointer(sys::PSY.System) =
Expand Down
110 changes: 0 additions & 110 deletions test/data/DAIB.jl

This file was deleted.

Loading

0 comments on commit cdff2c1

Please sign in to comment.