Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions .claude/claude.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ Efficient computation of power network matrices for large-scale systems. Support
### `ext/`

- **MKLPardisoExt.jl**: MKL-Pardiso sparse solver (Windows/Linux)
- **AppleAccelerateExt.jl**: native macOS BLAS acceleration

### `test/`

Expand Down Expand Up @@ -112,7 +111,7 @@ Documentation source
### Optional Extensions

- **MKL + Pardiso**: high-performance sparse factorization
- **AppleAccelerate**: native macOS dense linear algebra
- **AppleAccelerate**: native macOS sparse direct solver (libSparse `SparseFactorizationLU`, built-in via `src/AccelerateWrapper/`, macOS 15.5+)

## Core Abstractions

Expand Down Expand Up @@ -160,7 +159,7 @@ Documentation source
- **Indexing**: `matrix[bus_num, branch_tuple]` auto-maps to internal indices
- **Subnetworks**: `subnetwork_axes` Dict maps reference buses to island components
- **Caching**: VirtualPTDF/LODF use LRU cache (default 100 MiB) for row storage
- **Solvers**: KLU (default), Dense, MKLPardiso, AppleAccelerate via extensions
- **Solvers**: KLU, Dense, MKLPardiso (ext), and built-in AppleAccelerateLU (libSparse `SparseFactorizationLU` + Inf-norm equilibration scaling, macOS 15.5+) via `src/AccelerateWrapper/`; KLU is the default on non-Apple / macOS < 15.5; AppleAccelerateLU is the default on macOS ≥ 15.5.

## Test Patterns

Expand Down
3 changes: 0 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SuiteSparse_jll = "bea87d4a-7f5b-5778-9afe-8cc45184846c"

[weakdeps]
AppleAccelerate = "13e28ba4-7ad8-5781-acae-3021b1ed3924"
Pardiso = "46dd5b70-b6fb-5a00-ae2d-e8fea33afaf2"

[extensions]
AppleAccelerateExt = "AppleAccelerate"
MKLPardisoExt = "Pardiso"

[compat]
AppleAccelerate = "^0.4"
DataStructures = "^0.19"
DocStringExtensions = "~0.8, ~0.9"
HDF5 = "0.17"
Expand Down
11 changes: 11 additions & 0 deletions docs/src/reference/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ symbols are exported from `PowerNetworkMatrices`.
```@autodocs
Modules = [PowerNetworkMatrices.KLUWrapper]
```

## `AccelerateWrapper`

`PowerNetworkMatrices.AccelerateWrapper` is a thin, allocation-aware wrapper over Apple's
`libSparse.dylib` (provided by the system Accelerate framework) used internally for sparse
linear solves on macOS. Non-Apple builds load stub fallbacks that throw on use. None of
these symbols are exported from `PowerNetworkMatrices`.

```@autodocs
Modules = [PowerNetworkMatrices.AccelerateWrapper]
```
112 changes: 0 additions & 112 deletions ext/AppleAccelerateExt.jl

This file was deleted.

27 changes: 7 additions & 20 deletions ext/MKLPardisoExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,28 +171,15 @@ function PNM._calculate_LODF_matrix_MKLPardiso(
a::SparseArrays.SparseMatrixCSC{Int8, Int},
ptdf::Matrix{Float64},
)
# The demand matrix `diag(1 - PTDF·A[i,i])` is diagonal, so the
# "solve" is a row-wise element-wise division. The Pardiso path that
# used to factor it and back-solve via `_pardiso_sequential_LODF!` /
# `_pardiso_single_LODF!` is no longer needed for this stage.
linecount = size(ptdf, 2)
ptdf_denominator_t = a * ptdf
m_I = Int[]
m_V = Float64[]
for iline in 1:linecount
if (1.0 - ptdf_denominator_t[iline, iline]) < PNM.LODF_ENTRY_TOLERANCE
push!(m_I, iline)
push!(m_V, 1.0)
else
push!(m_I, iline)
push!(m_V, 1 - ptdf_denominator_t[iline, iline])
end
end
lodf_t = zeros(linecount, linecount)
A = SparseArrays.sparse(m_I, m_I, m_V)
if linecount > PNM.DEFAULT_LODF_CHUNK_SIZE
PNM._pardiso_sequential_LODF!(lodf_t, A, ptdf_denominator_t)
else
PNM._pardiso_single_LODF!(lodf_t, A, ptdf_denominator_t)
end
lodf_t[LinearAlgebra.diagind(lodf_t)] .= -1.0
return lodf_t
m_V = PNM._build_lodf_demand(ptdf_denominator_t, linecount)
PNM._apply_lodf_demand!(ptdf_denominator_t, m_V)
return ptdf_denominator_t
end

end # module
Loading
Loading