Skip to content

Commit 9b80130

Browse files
authored
Merge pull request #97 from NREL-Sienna/jd/bump_psy_version
Jd/bump psy version
2 parents 355b2fb + 4c794b2 commit 9b80130

9 files changed

Lines changed: 54 additions & 29 deletions

File tree

.github/workflows/pr_testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
matrix:
1313
julia-version: ['1']
1414
julia-arch: [x64]
15-
os: [ubuntu-latest, windows-latest]
15+
os: [ubuntu-latest, windows-latest, macOS-latest]
1616

1717
steps:
1818
- uses: actions/checkout@v2

Project.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
name = "PowerNetworkMatrices"
22
uuid = "bed98974-b02a-5e2f-9fe0-a103f5c450dd"
33
authors = ["Jose Daniel Lara", "Alessandro Francesco Castelli", "Sourabh Dalvi"]
4-
version = "0.11.1"
4+
version = "0.12.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
88
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
99
InfrastructureSystems = "2cd47ed4-ca9b-11e9-27f2-ab636a7671f1"
1010
KLU = "ef3ab10e-7fda-4108-b977-705223b18434"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
12-
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
13-
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"
1412
PowerSystems = "bcd98974-b02a-5e2f-9ee0-a103f5c450dd"
1513
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
14+
AppleAccelerate = "13e28ba4-7ad8-5781-acae-3021b1ed3924"
15+
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
16+
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"
1617

1718
[compat]
19+
AppleAccelerate = "^0.4"
1820
DocStringExtensions = "~0.8, ~0.9"
1921
HDF5 = "0.17"
2022
InfrastructureSystems = "2"
21-
LinearAlgebra = "1"
22-
MKL = "0.6"
2323
KLU = "^0.6"
24+
LinearAlgebra = "1"
25+
MKL = "0.7"
2426
Pardiso = "^0.5.5"
25-
PowerSystems = "4"
27+
PowerSystems = "^4.5"
2628
SparseArrays = "1"
2729
julia = "^1.6"

src/PowerNetworkMatrices.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,28 @@ export VirtualPTDF
2222
export Ybus
2323

2424
using DocStringExtensions
25-
import MKL
2625
import InfrastructureSystems
2726
import PowerSystems
2827
import PowerSystems: ACBusTypes
2928

3029
const IS = InfrastructureSystems
3130
const PSY = PowerSystems
3231

32+
@static if (Sys.ARCH === :x86_64 || Sys.ARCH === :i686) && !Sys.isapple()
33+
using MKL
34+
using Pardiso
35+
const USE_MKL = MKL.MKL_jll.is_available()
36+
else
37+
const USE_MKL = false
38+
end
39+
40+
@static if Sys.isapple()
41+
using AppleAccelerate
42+
const USE_AA = true
43+
else
44+
const USE_AA = false
45+
end
46+
3347
import SparseArrays
3448
import SparseArrays: rowvals, nzrange
3549
import HDF5
@@ -39,7 +53,6 @@ import LinearAlgebra
3953
import LinearAlgebra: BLAS.gemm
4054
import LinearAlgebra: ldiv!, mul!, I, dot
4155
import LinearAlgebra: LAPACK.getrf!, LAPACK.getrs!
42-
import Pardiso
4356

4457
@template DEFAULT = """
4558
$(SIGNATURES)

src/lodf_calculations.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ function _buildlodf(
3737
elseif linear_solver == "Dense"
3838
lodf_t = _calculate_LODF_matrix_DENSE(a, ptdf)
3939
elseif linear_solver == "MKLPardiso"
40+
if !USE_MKL
41+
error(
42+
"The MKL library is not available. Check that your hardware and operating system support MKL.",
43+
)
44+
end
4045
lodf_t = _calculate_LODF_matrix_MKLPardiso(a, ptdf)
4146
end
4247
return lodf_t
@@ -52,7 +57,7 @@ function _buildlodf(
5257
if linear_solver == "KLU"
5358
lodf_t = _calculate_LODF_matrix_KLU(a, k, ba, ref_bus_positions)
5459
else
55-
error("Other methods still to be implemented.")
60+
error("Other linear solvers are not implemented.")
5661
end
5762
return lodf_t
5863
end

src/ptdf_calculations.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ function _buildptdf(
6565
dist_slack,
6666
)
6767
elseif linear_solver == "MKLPardiso"
68+
if !USE_MKL
69+
error(
70+
"The MKL library is not available. Check that your hardware and operating system support MKL.",
71+
)
72+
end
6873
PTDFm, A = calculate_PTDF_matrix_MKLPardiso(
6974
branches,
7075
buses,

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Aqua
1919
Aqua.test_unbound_args(PowerNetworkMatrices)
2020
Aqua.test_undefined_exports(PowerNetworkMatrices)
2121
Aqua.test_ambiguities(PowerNetworkMatrices)
22-
Aqua.test_stale_deps(PowerNetworkMatrices)
22+
Aqua.test_stale_deps(PowerNetworkMatrices; ignore = [:AppleAccelerate, :MKL, :Pardiso])
2323
Aqua.test_deps_compat(PowerNetworkMatrices)
2424

2525
include("testing_data.jl")

test/test_lodf.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@
2424
P5 = PTDF(sys5)
2525
L5NS_from_ptdf = LODF(A, P5)
2626
L5NS_from_ptdf2 = LODF(A, P5; linear_solver = "Dense")
27-
L5NS_from_ptdf3 = LODF(A, P5; linear_solver = "MKLPardiso")
2827
@test getindex(L5NS_from_ptdf, "5", "6") - -0.3071 <= 1e-4
2928
@test getindex(L5NS_from_ptdf2, "5", "6") - -0.3071 <= 1e-4
30-
@test getindex(L5NS_from_ptdf3, "5", "6") - -0.3071 <= 1e-4
3129
total_error = abs.(L5NS_from_ptdf.data' .- Lodf_5)
3230
total_error2 = abs.(L5NS_from_ptdf2.data' .- Lodf_5)
33-
total_error3 = abs.(L5NS_from_ptdf3.data' .- Lodf_5)
3431
@test isapprox(sum(total_error), 0.0, atol = 1e-3)
3532
@test isapprox(sum(total_error2), 0.0, atol = 1e-3)
36-
@test isapprox(sum(total_error3), 0.0, atol = 1e-3)
33+
34+
if !PowerNetworkMatrices.USE_AA
35+
L5NS_from_ptdf3 = LODF(A, P5; linear_solver = "MKLPardiso")
36+
@test getindex(L5NS_from_ptdf3, "5", "6") - -0.3071 <= 1e-4
37+
total_error3 = abs.(L5NS_from_ptdf3.data' .- Lodf_5)
38+
@test isapprox(sum(total_error3), 0.0, atol = 1e-3)
39+
end
3740

3841
# A, ABA, and BA case
3942
ABA = ABA_Matrix(sys5; factorize = true)

test/test_ptdf.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@testset "Test PTDF matrices, w/ and w/o tolerance" begin
22
sys5 = PSB.build_system(PSB.PSITestSystems, "c_sys5")
33
for solver in ["KLU", "Dense", "MKLPardiso"]
4+
if PowerNetworkMatrices.USE_AA && solver == "MKLPardiso"
5+
@info "Skipped MKLPardiso tests on Apple"
6+
continue
7+
end
48
for approach in ["standard", "separate_matrices"]
59
buses_5 = nodes5()
610
branches_5 = branches5(buses_5)
@@ -213,11 +217,12 @@ end
213217

214218
P5_1 = PTDF(sys5; dist_slack = slack_array, linear_solver = "KLU")
215219
P5_2 = PTDF(sys5; dist_slack = slack_array, linear_solver = "Dense")
216-
P5_3 = PTDF(sys5; dist_slack = slack_array, linear_solver = "MKLPardiso")
217-
218220
@test isapprox(P5_1.data, P5_2.data, atol = 1e-5)
219-
@test isapprox(P5_1.data, P5_3.data, atol = 1e-5)
220-
@test isapprox(P5_2.data, P5_3.data, atol = 1e-5)
221+
if !PowerNetworkMatrices.USE_AA
222+
P5_3 = PTDF(sys5; dist_slack = slack_array, linear_solver = "MKLPardiso")
223+
@test isapprox(P5_2.data, P5_3.data, atol = 1e-5)
224+
@test isapprox(P5_1.data, P5_3.data, atol = 1e-5)
225+
end
221226
end
222227

223228
@testset "Test PTDF matrix with distributed bus and with 2 reference buses" begin

test/test_ybus.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,14 @@
3434

3535
@test Ybus5[buses_5[1], buses_5[2]] == (-3.5234840209999647 + 35.234840209999646im)
3636

37-
c_sys5_re() = System(
38-
100.0,
39-
buses_5,
40-
thermal_generators5(buses_5),
41-
loads5(buses_5),
42-
branches5(buses_5),
43-
)
44-
45-
t_sys5_re = c_sys5_re()
37+
t_sys5_re = PSB.build_system(PSB.PSITestSystems, "c_sys5")
4638
# Make 2 islands. Island 1: 1 - 5. Island 2: 2, 3 ,4
4739
remove_component!(Line, t_sys5_re, "1")
4840
remove_component!(Line, t_sys5_re, "2")
4941
remove_component!(Line, t_sys5_re, "6")
5042
@test_throws IS.DataFormatError Ybus(t_sys5_re)
5143

52-
t2_sys5_re = c_sys5_re()
44+
t2_sys5_re = PSB.build_system(PSB.PSITestSystems, "c_sys5")
5345
# Remove lines. Don't cause islands
5446
remove_component!(Line, t2_sys5_re, "3")
5547
remove_component!(Line, t2_sys5_re, "5")

0 commit comments

Comments
 (0)