exanauts / ExaPF.jl

A Power Flow Solver for GPUs in Julia
MIT License
58 stars 5 forks source link

Add BLOCK-GMRES in ExaPF.jl #281

Closed amontoison closed 11 months ago

amontoison commented 11 months ago
using ExaPF.LS

A = rand(10,10)
B = rand(10,4)
X0 = ones(10,4)

solver = BlockGmresSolver(A, B)
block_gmres!(solver, A, B, verbose=1)
R = B - A * solver.X
println(norm(R))

block_gmres!(solver, A, B, X0, verbose=1)
R = B - A * solver.X
println(norm(R))

block_gmres(A, B, verbose=1)
R = B - A * solver.X
println(norm(R))

block_gmres(A, B, X0, verbose=1)
R = B - A * solver.X
println(norm(R))
julia> block_gmres!(solver, A, B, verbose=1)
BLOCK-GMRES: system of size 10 with 4 right-hand sides
 pass      k     ‖Rₖ‖  timer
    0      0  3.8e+00  0.50s
    1      1  1.4e+00  0.88s
    1      2  7.4e-01  0.88s
    1      3  1.0e-15  0.88s

┌──────────────────┬────────────────────────┬──────────────────┐
│  BlockGmresSolver│               nrows: 10│         ncols: 10│
├──────────────────┼────────────────────────┼──────────────────┤
│Precision: Float64│       Architecture: CPU│Storage: 1.314 KiB│
├──────────────────┼────────────────────────┼──────────────────┤
│         Attribute│                    Type│              Size│
├──────────────────┼────────────────────────┼──────────────────┤
│                 m│                   Int64│           8 bytes│
│                 n│                   Int64│           8 bytes│
│                 p│                   Int64│           8 bytes│
│                 X│         Matrix{Float64}│         320 bytes│
│                 W│         Matrix{Float64}│         320 bytes│
│                 C│         Matrix{Float64}│         128 bytes│
│                 D│         Matrix{Float64}│         256 bytes│
│                 V│ Vector{Matrix{Float64}}│          24 bytes│
│                 Z│ Vector{Matrix{Float64}}│          24 bytes│
│                 R│ Vector{Matrix{Float64}}│          48 bytes│
│                 H│ Vector{Matrix{Float64}}│          24 bytes│
│                 τ│ Vector{Vector{Float64}}│         120 bytes│
│        warm_start│                    Bool│            1 byte│
│             stats│BlockGmresStats{Float64}│          57 bytes│
└──────────────────┴────────────────────────┴──────────────────┘

BlockGmresStats
 niter: 3
 solved: true
 residuals: []
 timer: 902.33ms
 status: solution good enough given atol and rtol
michel2323 commented 11 months ago

We just need docs for

│     ExaPF.LinearSolvers.block_gmres
│     ExaPF.LinearSolvers.BlockKrylovSolver
│     ExaPF.LinearSolvers.BlockGmresSolver
│     ExaPF.LinearSolvers.block_gmres!

and we are good to go!

codecov[bot] commented 11 months ago

Codecov Report

Merging #281 (eeb2876) into main (f28191f) will decrease coverage by 4.95%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
- Coverage   74.38%   69.44%   -4.95%     
==========================================
  Files          33       35       +2     
  Lines        4185     4483     +298     
==========================================
  Hits         3113     3113              
- Misses       1072     1370     +298     
Files Coverage Δ
src/LinearSolvers/LinearSolvers.jl 74.62% <ø> (ø)
src/LinearSolvers/utils.jl 0.00% <0.00%> (ø)
src/LinearSolvers/block_gmres.jl 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more