Skip to content

Commit

Permalink
Implement dc powerflow (#19)
Browse files Browse the repository at this point in the history
* update formatting code

* rename file

* add new files

* run formatter

* update PowerNetwork

* add missing include

* first test

* added methods for solving the power flow problem with full PTDF, and with ABA and BA matrices

* formatter

* test and methods updated

* updated to avoid allocations

* tested funcions (temporary)

* tried also @threads for case 2k buses

* implement power flow data correctly

* add common methods

* move code

* update powerflow data

* api update for powerflow data

* update testing code

* add new dc powerflow type

* add more dependencies

* fix to tturbo usage

* clean up dc powerflow

* add dc powerflow testing

* add some fixes

* added bus angle evaluation - non parallel

* found bugs in look up tuple: not the same accross BA and ABA (to be finished)

* problem found, keep comments for now

* add bug fixes

* WIP matrix vector multiplication

* use zeros instead of undefs to initialize

* fix mult implementation

* use appropriate methods for multiplication

* set angles to 0.0

* remove unused methods

* formatter

* split functions for dcpower flow

* some changes to the mult operations

* correction to pfdata make function

* corrected and tested new functions

tests pending, 70k case still slow

* updated PTDF case testing, initialized Virtual PTDF

* multiplication methods selected, tests prepeared but partially passed

* add misc changes

* bump power network matrices

* changed interface for nlsolve_ac_powerflow to solve_powerflow

* adding specific function for exporting dc results

* updated write_results for dc case

* fixed test for PTDF and DC PowreFlow

* fixed sort! function

* fixed test for ABA and PTDF version of DC power flows

* crated and tested functions fo vPTDF case

* formetter

* removing temp lines

* test fixed

* formatter

* update formatter code

---------

Co-authored-by: Jose Daniel Lara <[email protected]>
  • Loading branch information
alefcastelli and jd-lara authored Apr 27, 2023
1 parent 8af179c commit a045367
Show file tree
Hide file tree
Showing 20 changed files with 1,011 additions and 371 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Format Check
on:
push:
branches:
- 'main'
- 'master'
- 'release-'
tags: '*'
pull_request:
Expand All @@ -21,10 +21,10 @@ jobs:
with:
version: ${{ matrix.julia-version }}

- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Install JuliaFormatter and format
run: |
julia -e 'include(".github/workflows/formatter/formatter_code.jl")'
julia -e 'include("scripts/formatter/formatter_code.jl")'
- uses: reviewdog/action-suggester@v1
if: github.event_name == 'pull_request'
with:
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/formatter/formatter_code.jl

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/formatter/formatter_docs.jl

This file was deleted.

4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "0.2.1"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
PowerNetworkMatrices = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
Expand All @@ -15,7 +16,8 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[compat]
DataFrames = "1"
InfrastructureSystems = "1"
LoopVectorization = "^0.12"
NLsolve = "4"
PowerNetworkMatrices = "^0.7"
PowerSystems = "2"
PowerNetworkMatrices = "^0.1.1"
julia = "^1.6"
26 changes: 13 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Documenter, PowerSystems, DocStringExtensions, PowerFlows

makedocs(
modules=[PowerFlows],
format=Documenter.HTML(mathengine=Documenter.MathJax()),
sitename="PowerFlows.jl",
pages=Any[
makedocs(;
modules = [PowerFlows],
format = Documenter.HTML(; mathengine = Documenter.MathJax()),
sitename = "PowerFlows.jl",
pages = Any[
"Welcome Page" => "index.md",
"Modeler Guide" => Any["modeler_guide/power_flow.md"],
"Code Base Developer Guide" => Any["Developer Guide" => "code_base_developer_guide/developer.md",],
Expand All @@ -13,12 +13,12 @@ makedocs(
],
)

deploydocs(
repo="github.com/NREL-SIIP/PowerFlows.jl.git",
target="build",
branch="gh-pages",
devbranch="main",
devurl="dev",
push_preview=true,
versions=["stable" => "v^", "v#.#"],
deploydocs(;
repo = "github.com/NREL-SIIP/PowerFlows.jl.git",
target = "build",
branch = "gh-pages",
devbranch = "main",
devurl = "dev",
push_preview = true,
versions = ["stable" => "v^", "v#.#"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[compat]
JuliaFormatter = "v0.22"
JuliaFormatter = "1.0"
julia = "^1.7"
28 changes: 28 additions & 0 deletions scripts/formatter/formatter_code.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Pkg
Pkg.activate(@__DIR__)
Pkg.instantiate()
Pkg.update()

using JuliaFormatter

main_paths = ["."]
for main_path in main_paths
for (root, dir, files) in walkdir(main_path)
for f in files
@show file_path = abspath(root, f)
!occursin(".jl", f) && continue
format(file_path;
whitespace_ops_in_indices = true,
remove_extra_newlines = true,
verbose = true,
always_for_in = true,
whitespace_typedefs = true,
conditional_to_if = true,
join_lines_based_on_source = true,
separate_kwargs_with_semicolon = true,

# always_use_return = true. # Disabled since it throws a lot of false positives
)
end
end
end
Loading

0 comments on commit a045367

Please sign in to comment.