developing scalable applications using portable extensible...

56
Developing Scalable Applications using Portable Extensible Toolkit for Scientific Computation (PETSc) for the Next-Generation Power Grid Shrirang Abhyankar Mathematics and Computer Science Division Argonne National Laboratory November 15, 2011 Shrirang Abhyankar (ANL) PETSc November 15, 2011 1 / 49

Upload: others

Post on 14-Sep-2019

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Developing Scalable Applications using PortableExtensible Toolkit for Scientific Computation (PETSc)

for the Next-Generation Power Grid

Shrirang Abhyankar

Mathematics and Computer Science DivisionArgonne National Laboratory

November 15, 2011

Shrirang Abhyankar (ANL) PETSc November 15, 2011 1 / 49

Page 2: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 2 / 49

Page 3: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 3 / 49

Page 4: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Next-Generation Power Grid

• Next-generation power grid• PMUs, smart meters, Distributed Generation, Plug-in hybrid vehicles,

Smart and Micro-grids, Power electronics, Increased communication

• Computational challenges• Data explosion , Real-time simulation requirements , Larger or denser

network , Multi-scale (temporal, geographical)

Can we develop applications for large systems that run in real-time andcapture behavior at a sub-cycle level?

Shrirang Abhyankar (ANL) PETSc November 15, 2011 4 / 49

Page 5: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Next-Generation Power Grid

• Next-generation power grid• PMUs, smart meters, Distributed Generation, Plug-in hybrid vehicles,

Smart and Micro-grids, Power electronics, Increased communication

• Computational challenges• Data explosion , Real-time simulation requirements , Larger or denser

network , Multi-scale (temporal, geographical)

Can we develop applications for large systems that run in real-time andcapture behavior at a sub-cycle level?

Shrirang Abhyankar (ANL) PETSc November 15, 2011 4 / 49

Page 6: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Next-Generation Power Grid

• Next-generation power grid• PMUs, smart meters, Distributed Generation, Plug-in hybrid vehicles,

Smart and Micro-grids, Power electronics, Increased communication

• Computational challenges• Data explosion , Real-time simulation requirements , Larger or denser

network , Multi-scale (temporal, geographical)

Can we develop applications for large systems that run in real-time andcapture behavior at a sub-cycle level?

Shrirang Abhyankar (ANL) PETSc November 15, 2011 4 / 49

Page 7: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Computational challenges

One possible solution: Parallel computingNeed to develop parallel scientific computational tool (solver) for specificapplication (physics) ..... not so easy!!High performance computing libraries, such as PETSc, can aid in

• Reduce the computational time

• Rapid development of parallel applications

• Reduce the experimentation time and effort

Shrirang Abhyankar (ANL) PETSc November 15, 2011 5 / 49

Page 8: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Computational challenges

One possible solution: Parallel computingNeed to develop parallel scientific computational tool (solver) for specificapplication (physics) ..... not so easy!!High performance computing libraries, such as PETSc, can aid in

• Reduce the computational time

• Rapid development of parallel applications

• Reduce the experimentation time and effort

Shrirang Abhyankar (ANL) PETSc November 15, 2011 5 / 49

Page 9: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Computational challenges

One possible solution: Parallel computingNeed to develop parallel scientific computational tool (solver) for specificapplication (physics) ..... not so easy!!High performance computing libraries, such as PETSc, can aid in

• Reduce the computational time

• Rapid development of parallel applications

• Reduce the experimentation time and effort

Shrirang Abhyankar (ANL) PETSc November 15, 2011 5 / 49

Page 10: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Power system computational challenges

Computational challenges

One possible solution: Parallel computingNeed to develop parallel scientific computational tool (solver) for specificapplication (physics) ..... not so easy!!High performance computing libraries, such as PETSc, can aid in

• Reduce the computational time

• Rapid development of parallel applications

• Reduce the experimentation time and effort

Shrirang Abhyankar (ANL) PETSc November 15, 2011 5 / 49

Page 11: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 6 / 49

Page 12: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc What is PETSc?

What is PETSc?

Portable Extensible Toolkit for Scientific Computation

• High performance library for the scalable (parallel)solution of scientific applications

• Developed at Argonne National Laboratory

• Mostly used by researchers in PDE applications

• Free for anyone to use, including industrial users

• Download from http://www.mcs.anl.gov/petsc• Funding

• Department of Energy• National Science Foundation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 7 / 49

Page 13: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc History

History of PETSc

• Begun in September 1991 as a platform for experimentation

• More than 60,000 downloads since 1995 (version 2)

• About 400 downloads per month

• Awards• Top 100 R & D award in 2009• Cited as the Top 10 computational science accomplishments of DOE in

2008

Shrirang Abhyankar (ANL) PETSc November 15, 2011 8 / 49

Page 14: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc About PETSc

Portable Extensible Toolkit for Scientific computing

• Architecture• tightly coupled (e.g. Cray XT5, BG/P, Earth Simulator)• loosely coupled (network of workstations)• GPU clusters (many vector and sparse matrix kernels)

• Operating systems (Linux, Unix, Mac, Windows)

• Any compiler

• Real/complex, single/double/quad precision, 32/64-bit int

• Usable from C, C++, Fortran 77/90, Python, and MATLAB

• Free to everyone, open development, including industrial users

Shrirang Abhyankar (ANL) PETSc November 15, 2011 9 / 49

Page 15: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc About PETSc

Portable Extensible Toolkit for Scientific computing

Interface for other HP libraries

• BLAS, LAPACK, BLACS, ScaLAPACK, PLAPACK

• MPICH, MPE, Open MPI

• ParMetis, Chaco, Jostle, Party, Scotch, Zoltan

• MUMPS, Spooles, SuperLU, SuperLU Dist, UMFPack, pARMS

• PaStiX, BLOPEX, FFTW, SPRNG

• Prometheus, HYPRE, ML, SPAI

• Sundials

• HDF5, Boost

Packages can be directly downloaded and installed at configure time--download-<packagename>=1

Shrirang Abhyankar (ANL) PETSc November 15, 2011 10 / 49

Page 16: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc About PETSc

Who uses PETSc?

• Computational Scientists• PyLith (CIG), Underworld (Monash), Magma Dynamics (LDEO,

Columbia), PFLOTRAN (DOE), SHARP/UNIC (DOE)

• Algorithm Developers (iterative methods and preconditioning)

• Package Developers• SLEPc, TAO, Deal.II, Libmesh, FEniCS, PETSc-FEM, MagPar,

OOFEM, FreeCFD, OpenFVM

• Hardware and software vendors• Cray and SiCortex• Fluent, Tech-X, Actel

Shrirang Abhyankar (ANL) PETSc November 15, 2011 11 / 49

Page 17: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Introduction to PETSc About PETSc

What can we handle?

• PETSc has run implicit problems with 1 billion unknowns• PFLOTRAN for flow in porous media

• PETSc has run on over 224, 000 cores efficiently• UNIC on the IBM BG/P at ANL• PFLOTRAN on the Cray XT5 Jaguar at ORNL

• PETSc applications have run at 3 Teraflops• LANL PFLOTRAN code

Shrirang Abhyankar (ANL) PETSc November 15, 2011 12 / 49

Page 18: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Applications

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 13 / 49

Page 19: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Applications

Applications of PETSc

• Nano-simulations

• BiologyMedical

• Cardiology

• Imaging and Surgery

• Fusion

• Geosciences

• Environmental/Subsurface Flow

• Computational Fluid Dynamics

• Wave propagation and the Helmholz equation

• Optimization

• Fast Algorithms

• Software engineering

• Algorithm analysis and design

• Electrical Power Systems

Shrirang Abhyankar (ANL) PETSc November 15, 2011 14 / 49

Page 20: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Applications Real-time laser surgery

Real-time laser surgery

Shrirang Abhyankar (ANL) PETSc November 15, 2011 15 / 49

Page 21: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Applications Subsurface flow processes

Estimating uranium concentration

Figure: Isopleths of uranium calculatedusing PFLOTRAN at the Hanford 300Area

Figure: PFLOTRAN scaling for 2Bdegrees of freedom

Shrirang Abhyankar (ANL) PETSc November 15, 2011 16 / 49

Page 22: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc Design

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 17 / 49

Page 23: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc Design

Design principles

• Linear algebra interface (Vectors, Matrices, Index sets)

• Distributed, shared nothing• User orchestrates communication through higher level interface• You almost never will have to use MPI directly

• Object-oriented design• Design based on the operations you perform• Example : A vector is

• not a 1-d array but• an object allowing addition and scalar multiplication

• Polymorphism• User does not need to know the underlying implementation

• Allow solver composition to be set at run-time• Great for experimentation./ex -snes_type <ls,tr,test> -ksp_type

<gmres,cg,bicg,preonly> -pc_type <lu,ilu,icc,jacobi>

-mat_type <aij,baij,sbaij>

Shrirang Abhyankar (ANL) PETSc November 15, 2011 18 / 49

Page 24: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc Design

Flow control of a PETSc application

Timestepping Solvers (TS)

Preconditioners (PC)

Nonlinear Solvers (SNES)

Linear Solvers (KSP)

Function

EvaluationPostprocessing

Jacobian

Evaluation

Application

Initialization

Main Routine

PETSc

Shrirang Abhyankar (ANL) PETSc November 15, 2011 19 / 49

Page 25: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc libraries

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 20 / 49

Page 26: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc libraries

Library Organization

Shrirang Abhyankar (ANL) PETSc November 15, 2011 21 / 49

Page 27: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PETSc libraries

Numerical Components

Krylov Subspace Methods

CG CGS OtherChebychevRichardsonTFQMRBi-CG-StabGMRES

VectorsOtherStrideBlock Indices

Index Sets

Indices

Block Compressed

Sparse Row

(BAIJ)

Block

Diagonal

(BDiag)

Compressed

Sparse Row

(AIJ)

OtherDense

Matrices

Backward

Euler

Pseudo-Time

Stepping

Time Steppers

Euler Other

Block

Jacobi

Additive

Schwarz (sequential only)LU

Parallel Numerical Components of PETSc

Jacobi ILU ICC Other

Preconditioners

Newton-based Methods

Trust RegionLine Search

Other

Nonlinear Solvers

Shrirang Abhyankar (ANL) PETSc November 15, 2011 22 / 49

Page 28: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Programming aids

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 23 / 49

Page 29: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Programming aids Debugging

Debugging

• Automatic generation of tracebacks

• Detection of memory corruption and leaks

• Optional user-defined error handlers

• Launch the debugger• -start_in_debugger [gdb, dbx, noxterm]• -on_error_attach_debugger [gdb, dbx, noxterm]

• Attach the debugger only to some parallel processes• -debugger_nodes 0, 1

• Use valgrind• http://www.valgrind.org• Checks memory access, cache performance, memory usage, etc.

• Check correctness of analytical Jacobian• -snes_type test -snes_test_display

Shrirang Abhyankar (ANL) PETSc November 15, 2011 24 / 49

Page 30: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Programming aids Profiling

Profiling

• -log_summary

• Prints a report at the end of the run• Reports time, calls, Flops for function calls (called Events)• Memory usage for Objects• Can set stages for code profiling

Shrirang Abhyankar (ANL) PETSc November 15, 2011 25 / 49

Page 31: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

Programming aids Profiling

Sample -log summary

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

"#$%&''''''''''''''''()*%&''''''+,-$'./$01'''''23)4/5/$0'''''''''''''''''''''''''!!!'63)783'!!!''!!!'9&8:$'!!!'''+)&83

''''''''''''''''''';8<'=8&,)'';8<'''''=8&,)''';8<''=8&,)'';$//'''>#:'3$%'=$?*0&''@+'@2'@;'@A'@=''@+'@2'@;'@A'@=';B3)45/

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!'"#$%&'9&8:$'CD';8,%'9&8:$

E$&/0F8GG,$G'''''''''''H'IJC'IJIKLL$!CM'IJC'CJCC$NCC'CJC'CJC$NCC'CJC$NCC'CJC$NCC''C''C''C''C''C'''C''C''C''C''C'''''C

!!!'"#$%&'9&8:$'ID'9$&O4

P$09$&'''''''''''''''''H'IJC'QJLRRS$!CR'IJC'CJCC$NCC'CJC'CJC$NCC'CJC$NCC'CJC$NCC''C''C''C''C''C'''C''C''C''C''C'''''C

;8&;*3&+G8%/4)/$'''''''I'IJC'IJSCHH$!CL'IJC'IJSM$NCS'IJC'CJC$NCC'CJC$NCC'CJC$NCC''C''C''C''C''C'''C'MK''C''C''C'''ISM

;8&>//$-73TF$:,%'''''''L'IJC'IJCCMK$!CM'IJC'CJCC$NCC'CJC'CJC$NCC'CJC$NCC'CJC$NCC''C''C''C''C''C'''C''C''C''C''C'''''C

;8&>//$-73T"%?'''''''''L'IJC'HJCLMU$!CH'IJC'CJCC$NCC'CJC'CJC$NCC'CJC$NCC'CJC$NCC''C''C''C''C''C'''M''C''C''C''C'''''C

;8&2V()3)G(G$8&$'''''''H'IJC'IJMLRI$!CI'IJC'CJCC$NCC'CJC'CJC$NCC'CJC$NCC'RJU$NCI''I''C''C''C'IU''LU''C''C''C'KR'''''C

!!!'"#$%&'9&8:$'HD'9)3#$

P$0V)&'''''''''''''''''H'IJC'LJHQSM$!CL'IJC'QJMU$NCK'IJC'CJC$NCC'CJC$NCC'HJC$NCC''C''C''C''C''I'''C''C''C''C''H''''QU

P$0;V)&'''''''''''''''RM'IJC'QJLCQL$!CH'IJC'IJMQ$NCS'IJC'CJC$NCC'CJC$NCC'IJM$NCI''C''C''C''C''M'''I''I''C''C'IQ'''IMQ

P$0W)G-''''''''''''''IIH'IJC'HJCSMI$!CI'IJC'SJRK$NCK'IJC'CJC$NCC'CJC$NCC'MJH$NCI''I''I''C''C'IS'''H''I''C''C'UR''''SM

Shrirang Abhyankar (ANL) PETSc November 15, 2011 26 / 49

Page 32: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 27 / 49

Page 33: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Splitting for Multiphysics[A BC D

] [xy

]=

[fg

]

• Relaxation: -pc_fieldsplit_type

[additive,multiplicative,symmetric_multiplicative][A

D

]−1 [AC D

]−1 [A

1

]−1(1−

[A B

1

] [AC D

]−1)

• Gauss-Seidel inspired, works when fields are loosely coupled

• Factorization: -pc_fieldsplit_type schur[A B

S

]−1 [1

CA−1 1

]−1

, S = D − CA−1B

Shrirang Abhyankar (ANL) PETSc November 15, 2011 28 / 49

Page 34: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Python bindings and MATLAB interface

• Python bindings (petsc4py)• Implemented with Cython• Easier to write code, maintain, and extend• Supports all PETSc libraries• http://code.google.com/p/petsc4py

• PETSc-MATLAB interface• PETSc functions can be called via MATLAB code.• Supports almost all PETSc functionalities• Uses 1-based indexing (consistent with MATLAB)

Shrirang Abhyankar (ANL) PETSc November 15, 2011 29 / 49

Page 35: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Memory-efficient LU factorization

• Revise LU data structure according to the elements accessed duringtriangular solves

• Store L forward followed by U backwards

• Provides better Cache performance

Typical LU data structure

[L(1, :),U(1, :), L(2, :),U(2, :), ..., L(n, :),U(n, :)]

Revised LU data structure

[L(1, :), L(2, :), ..., L(n, :),U(n, :), ...,U(2, :),U(1, :)]

Shrirang Abhyankar (ANL) PETSc November 15, 2011 30 / 49

Page 36: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Support for new architectures

• Graphical Processing Units (GPU)• PETSc-3.2 (current version) supports computations on the NViDia

GPUs• Uses CUSP and Thrust libraries provided by NViDia guys• Vec and Mat classes implemented on the GPU• Krylov solvers come for free

• Hybrid MPI-shared memory architectures• Shared-memory implementation of Vec and Mat using POSIX pthreads

Figure: Hybrid MPI-Shared memoryarchitecture

Figure: NViDia GTX 280 GPUarchitectureShrirang Abhyankar (ANL) PETSc November 15, 2011 31 / 49

Page 37: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

What’s new

Variational Inequalities

f (x) = 0

s.t. xl <= x <= xu

• Supports inequality and box constraints on solution variables.

• Solution methods• Semismooth Newton

• reformulate problem as a non-smooth system, Newton onsub-differential

• Newton step solves diagonally perturbed systems

• Active set• solve in reduced space by eliminating constrained variables• or enforce constraints by Lagrange multipliers• sometimes slower convergence or “bouncing”

Shrirang Abhyankar (ANL) PETSc November 15, 2011 32 / 49

Page 38: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 33 / 49

Page 39: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications

Power system applications

• Linear (KSP library)• DC Power Flow, Sensitivity factors

• Nonlinear (SNES library)• AC Power Flow, Contingency analysis, Continuation power flow• Distribution power flow, Combined Transmission-distribution power

flow

• Time-stepping (TS library)• Transient stability, Electromagnetic transients• Combined transient stabilty-electromagnetic transients (hybrid

simulation)

• Optimization (using TAO)• SCOPF

• Eigen-value analysis (using SLEPc)• Small signal stability analysis

Shrirang Abhyankar (ANL) PETSc November 15, 2011 34 / 49

Page 40: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications

Outline

1 Power system computational challenges

2 Introduction to PETSc

3 Application Areas

4 PETSc Design

5 PETSc libraries

6 Programming aidsDebuggingProfiling

7 What’s new

8 List of power system applications that can be developed using PETSc

9 PS applications developed using PETScReal-time electrical power system dynamicsCombined electromechanical-electromagnetic transients simulation

Shrirang Abhyankar (ANL) PETSc November 15, 2011 35 / 49

Page 41: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Transient Stability Simulators (TS)

• For studying relatively slow dynamic behavior (generator dynamics)

• Assumptions• Constant frequency (phasor representation of voltages/currents)

• Can use larger time step (in the order of milliseconds)• Allow analysis of large-scale systems.

• Balanced transmission network (positive sequence network)

• Limitations of balanced transmission network• Unbalanced operation or systems• Single phase switching operations• Only positive sequence information available

Shrirang Abhyankar (ANL) PETSc November 15, 2011 36 / 49

Page 42: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Three phase dynamics simulator (TS3ph)

• Full three-phase coupled network model of the transmission network.

• Still uses constant frequency assumption as in TS.

• Can additionally• Simulate unbalanced operation• Single phase switching operations• Provide information on dynamics of all three phases• Model individual load dynamics on different phases• Can be also used for distribution systems

Shrirang Abhyankar (ANL) PETSc November 15, 2011 37 / 49

Page 43: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Problem formulation• Nonlinear differential-algebraic three-phase power system model

dxgendt

= f (xgen, Idq,VDQ,abc)

0 = h(xgen, Idq,VDQ,abc)[G3ph −B3ph

B3ph G3ph

] [VD,abc

VQ,abc

]=

[IgenD,abc(xgen, Idq)IgenQ,abc(xgen, Idq)

]−[IloadD,abc(xload ,VDQ,abc)IloadQ,abc(xload ,VDQ,abc)

]dxloaddt

= f2(xload ,VDQ,abc)

• Equations to solve at each time step

x(t + ∆t) − x(t) − ∆t

2(f (x(t + ∆t), y(t + ∆t)) + f (x(t), y(t))) = 0

g(x(t + ∆t), y(t + ∆t)) = 0

• Variables

x ≡ [xgen, xload ]t

y ≡ [Id , Iq,VD,abc ,VQ,abc ]t

Shrirang Abhyankar (ANL) PETSc November 15, 2011 38 / 49

Page 44: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

TS3ph benchmarking with PSS/E on WECC 9-bus system

0 0.5 1 1.5 2 2.5 358

60

62

64

66

68

70

72

Ge

ne

rato

r speeds (

Hz)

Time(sec)

TS3phPSS/E

0 0.5 1 1.5 2 2.5 30

0.2

0.4

0.6

0.8

1

1.2

1.4

Po

sitiv

e S

equence V

oltage(p

u)

Time(sec)

TS3phPSS/E

0 0.5 1 1.5 2 2.5 30

0.5

1

1.5

Pha

se−

A (

pu)

Time(sec)

TS3ph

0 0.5 1 1.5 2 2.5 30

0.5

1

1.5

Pha

se−

B (

pu)

Time(sec)

TS3ph

0 0.5 1 1.5 2 2.5 30

0.5

1

1.5

Pha

se−

C (

pu)

Time(sec)

TS3ph

Shrirang Abhyankar (ANL) PETSc November 15, 2011 39 / 49

Page 45: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Unbalanced faults

Positive-sequence voltages

0 0.5 1 1.5 2 2.5 30.94

0.95

0.96

0.97

0.98

0.99

1

1.01

Po

sitiv

e S

eq

ue

nce

Vo

lta

ge

(pu

)

Time(sec)

TS3phPSS/E

Three-phase voltages

0 0.5 1 1.5 2 2.5 30

0.5

1

1.5

Phase−

A (

pu)

Time(sec)

TS3ph

0 0.5 1 1.5 2 2.5 30.5

1

1.5

Phase−

B (

pu)

Time(sec)

TS3ph

0 0.5 1 1.5 2 2.5 30.8

1

1.2

Phase−

C (

pu)

Time(sec)

TS3ph

Shrirang Abhyankar (ANL) PETSc November 15, 2011 40 / 49

Page 46: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Parallel performance of TS3ph

*Scalabilty results of 1180 bus, 2035 branches, 540 generator

system

• Parallel linear solves tooexpensive!!

• Results of experiments to speedup linear solves

• Preconditioner Iterative solverGMRES more scalable thanparallel direct solver(MUMPS)

• Parallel Block-Jacobi(Block-Diagonal)preconditioning

• Very dishonest preconditioningstrategy (Pai et. al.)

Shrirang Abhyankar (ANL) PETSc November 15, 2011 41 / 49

Page 47: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Real-time electrical power system dynamics

Parallel performance of TS3ph

• Scalabilty results of 2360 bus,4670 branches, 1080 generatorsystem

Shrirang Abhyankar (ANL) PETSc November 15, 2011 42 / 49

Page 48: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Power system dynamic analysis methods

• Electromechanical dynamics simulation• Assess “slow” generator dynamics• Time step in the order of milliseconds• Phasor modeling• Can be used for large-scale system analysis.

• Electromagnetic transients simulation• Analyze “faster” dynamics such as that of power electronics• Time step in the order of microseconds• No constant frequency assumption• Inefficient for large-scale system analysis

• Combined electromechanical-electromagnetic transients simulator(“hybrid” simulator)

• Capture “global” slow dynamics and “local” fast dynamics• Use TS globally and EMT locally• Need interface for

• Time step• Network modeling• Waveform

Shrirang Abhyankar (ANL) PETSc November 15, 2011 43 / 49

Page 49: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Power system dynamic analysis methods

• Electromechanical dynamics simulation• Assess “slow” generator dynamics• Time step in the order of milliseconds• Phasor modeling• Can be used for large-scale system analysis.

• Electromagnetic transients simulation• Analyze “faster” dynamics such as that of power electronics• Time step in the order of microseconds• No constant frequency assumption• Inefficient for large-scale system analysis

• Combined electromechanical-electromagnetic transients simulator(“hybrid” simulator)

• Capture “global” slow dynamics and “local” fast dynamics• Use TS globally and EMT locally• Need interface for

• Time step• Network modeling• Waveform

Shrirang Abhyankar (ANL) PETSc November 15, 2011 43 / 49

Page 50: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Power system dynamic analysis methods

• Electromechanical dynamics simulation• Assess “slow” generator dynamics• Time step in the order of milliseconds• Phasor modeling• Can be used for large-scale system analysis.

• Electromagnetic transients simulation• Analyze “faster” dynamics such as that of power electronics• Time step in the order of microseconds• No constant frequency assumption• Inefficient for large-scale system analysis

• Combined electromechanical-electromagnetic transients simulator(“hybrid” simulator)

• Capture “global” slow dynamics and “local” fast dynamics• Use TS globally and EMT locally• Need interface for

• Time step• Network modeling• Waveform

Shrirang Abhyankar (ANL) PETSc November 15, 2011 43 / 49

Page 51: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Existing “explicit” hybrid simulation approach

• Make separate TS and EMT programs talk to each other

• Explicit approach

• No iterations between TS and EMT

• Diverges for large changes in voltages/currents

Shrirang Abhyankar (ANL) PETSc November 15, 2011 44 / 49

Page 52: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Proposed “implicitly-coupled” hybrid simulation approach• Combine TS and EMT at the equation level rather than at the

application level• Solve TS equations and coupled-in-time EMT equations for each TS

time step together• More robust than the explicit approach• Allows a parallel implementation

• Proposed multi-scale dynamics simulation strategy• Only run hybrid simulator when needed, run TS for all other times

!! "

!"!#$!! %&'

!

Shrirang Abhyankar (ANL) PETSc November 15, 2011 45 / 49

Page 53: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Combined electromechanical-electromagnetic transientssimulation

• Time-comparison of different dynamic analyses

System size Simulated time (sec) TS3ph EMT Only TSEMT TS3ph-TSEMT

9 bus 3 0.13 4.96 5.46 0.41

118 bus 3 0.36 30.1 4.87 0.53

Shrirang Abhyankar (ANL) PETSc November 15, 2011 46 / 49

Page 54: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

Parallel implementation and performance results

• Partition TS network in space and EMT network in time

• Each processor gets equations for• TS subnetwork• EMT equations for multiple time-steps

*2360 buses total, 4 buses,3 transmission lines and 4 loads in EMT network

*Using GMRES + Very Dishonest preconditioning

Shrirang Abhyankar (ANL) PETSc November 15, 2011 47 / 49

Page 55: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

PETSc use in the example applications

• Easy parallel implementation

• Partitioning (using ParMetis)

• Linear solver (using KSP and PC libraries)

• Nonlinear solver (SNES library)

• Portable code

• Reduced experimentation time• Set different algorithms at run-time!!

Shrirang Abhyankar (ANL) PETSc November 15, 2011 48 / 49

Page 56: Developing Scalable Applications using Portable Extensible ...abhyshr/downloads/presentations/WSU_Power... · Developing Scalable Applications using Portable Extensible Toolkit for

PS applications Combined electromechanical-electromagnetic transients simulation

The Role of PETSc

Developing parallel, nontrivial applications that de-liver high performance is still difficult and requiresmonths (or even years) of concentrated effort.

PETSc is a toolkit that can ease these difficultiesand reduce the development time, but it is not ablack-box solver, nor a silver bullet.

— Barry Smith

Shrirang Abhyankar (ANL) PETSc November 15, 2011 49 / 49