W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER
pyMOR
Model Order Reduction with Python
living knowledge
WWU Münster R. Milk, S. Rave PDESoft 2014
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Discrete Problem
For given parameter µ ∈ P, find uµ,h ∈ Vh satisfying
K
X
θk (µ)Bk (uµ,h , vh ) = F (vh ) ∀vh ∈ Vh . (∗)
k=1
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Discrete Problem
For given parameter µ ∈ P, find uµ,h ∈ Vh satisfying
K
X
θk (µ)Bk (uµ,h , vh ) = F (vh ) ∀vh ∈ Vh . (∗)
k=1
living knowledge
WWU Münster
I Assume that solving (∗) is very expensive.
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Discrete Problem
For given parameter µ ∈ P, find uµ,h ∈ Vh satisfying
K
X
θk (µ)Bk (uµ,h , vh ) = F (vh ) ∀vh ∈ Vh . (∗)
k=1
living knowledge
WWU Münster
I Assume that solving (∗) is very expensive.
I Need to solve for many µ ∈ P.
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Discrete Problem
For given parameter µ ∈ P, find uµ,h ∈ Vh satisfying
K
X
θk (µ)Bk (uµ,h , vh ) = F (vh ) ∀vh ∈ Vh . (∗)
k=1
living knowledge
WWU Münster
I Assume that solving (∗) is very expensive.
I Need to solve for many µ ∈ P.
I Offline-Phase: Use some fancy algorithm to
I compute snapshots S := {uµs ,h | s = 1, . . . , S}
I determine VN ⊆ span(S) with N = dim VN dim Vh .
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Discrete Problem
For given parameter µ ∈ P, find uµ,h ∈ Vh satisfying
K
X
θk (µ)Bk (uµ,h , vh ) = F (vh ) ∀vh ∈ Vh . (∗)
k=1
living knowledge
WWU Münster
I Assume that solving (∗) is very expensive.
I Need to solve for many µ ∈ P.
I Offline-Phase: Use some fancy algorithm to
I compute snapshots S := {uµs ,h | s = 1, . . . , S}
I determine VN ⊆ span(S) with N = dim VN dim Vh .
I Online-Phase: For new µ, solve (∗) restricted to VN .
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 2 /19
What is MOR
Reduced Problem
For given parameter µ ∈ P, find uµ,N ∈ VN satisfying
K
X
θk (µ)Bk (uµ,N , vN ) = F (vN ) ∀vN ∈ VN . (∗∗)
k=1
living knowledge
WWU Münster
I Assume that solving (∗) is very expensive.
I Need to solve for many µ ∈ P.
I Offline-Phase: Use some fancy algorithm to
I compute snapshots S := {uµs ,h | s = 1, . . . , S}
I determine VN ⊆ span(S) with N = dim VN dim Vh .
I Online-Phase: For new µ, solve (∗) restricted to VN .
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 3 /19
What is pyMOR
I fast way of integrating MOR algorithms with existing
high-dimensional solvers
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 3 /19
What is pyMOR
I fast way of integrating MOR algorithms with existing
high-dimensional solvers
I tool for interactive parameter studies
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 3 /19
What is pyMOR
I fast way of integrating MOR algorithms with existing
high-dimensional solvers
I tool for interactive parameter studies
living knowledge
I Testbed for prototyping new methods
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 3 /19
What is pyMOR
I fast way of integrating MOR algorithms with existing
high-dimensional solvers
I tool for interactive parameter studies
living knowledge
I Testbed for prototyping new methods
WWU Münster
I Free and Open Source Software (FreeBSD-2)
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 4 /19
pyMOR principles
I Generic algorithms on abstract interfaces
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 4 /19
pyMOR principles
I Generic algorithms on abstract interfaces
I Modern OO design based on immutable types modeling
mathematical entities
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 4 /19
pyMOR principles
I Generic algorithms on abstract interfaces
I Modern OO design based on immutable types modeling
mathematical entities
living knowledge
I Codebase tailored for interactive use and ease of
WWU Münster
experimentation
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 5 /19
pyMOR Building Blocks
I Vector arrays
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 5 /19
pyMOR Building Blocks
I Vector arrays
I Operators
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 5 /19
pyMOR Building Blocks
I Vector arrays
I Operators
living knowledge
I Discretizations
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 6 /19
Batteries included
I Abstract grid interface with implementations for structured,
uniform triangle/quadrilateral cells designed for vectorized
operations with NumPy
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 6 /19
Batteries included
I Abstract grid interface with implementations for structured,
uniform triangle/quadrilateral cells designed for vectorized
operations with NumPy
I stationary elliptic and instationary advection-diffusion
living knowledge
Discretizations and Operators
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 6 /19
Batteries included
I Abstract grid interface with implementations for structured,
uniform triangle/quadrilateral cells designed for vectorized
operations with NumPy
I stationary elliptic and instationary advection-diffusion
living knowledge
Discretizations and Operators
WWU Münster
I glumpy and matplotlib based data visualization
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 7 /19
MOR(e) algorithms
I generic, VectorArrayInterface-based POD, Greedy and
Gram-Schmidt implementations
I automatic reduction of arbitrarily nested affine combinations
living knowledge
of operators
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 8 /19
Parameter dependencies
I encapsulated in class Parameter, with a ParameterType
I model dependency by deriving from Parametric interface
I powerful automatic dependency injection method
living knowledge
I ParameterSpaceInterface as a model for P
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 9 /19
Anatomy of a reduction process
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 10 /19
Coupling external solvers I
I need to expose operators and vector data to pyMOR
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 10 /19
Coupling external solvers I
I need to expose operators and vector data to pyMOR
I Possibilities include:
I Python bindings via pybindgen, Boost.Python, Python C-API, . . .
I Communication via sockets, MPI, . . .
living knowledge
I Data exchange through actual files
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 10 /19
Coupling external solvers I
I need to expose operators and vector data to pyMOR
I Possibilities include:
I Python bindings via pybindgen, Boost.Python, Python C-API, . . .
I Communication via sockets, MPI, . . .
living knowledge
I Data exchange through actual files
WWU Münster
I Example: pymor/src/pymordemos/minimal_cpp_example
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 11 /19
Coupling external solvers II
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 12 /19
Caching
I automatic and explicit method call caching using decorators
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 12 /19
Caching
I automatic and explicit method call caching using decorators
I Immutable types allow automatic state-id generation
living knowledge
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 12 /19
Caching
I automatic and explicit method call caching using decorators
I Immutable types allow automatic state-id generation
I swappable cache backends, in-memory and on-disk are
living knowledge
included
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 13 /19
Live Demo
from multibat_experiments import *
p = params.best_shiquan_with_corner_1000s()
d = DuneDiscretization(**p)
d.parameter_space
u = d.solve((298,-0.0006))
living knowledge
d.visualize(u)
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 13 /19
Live Demo
from multibat_experiments import *
p = params.best_shiquan_with_corner_1000s()
d = DuneDiscretization(**p)
d.parameter_space
u = d.solve((298,-0.0006))
living knowledge
d.visualize(u)
WWU Münster
pymor/src/pymordemos/thermalblock_gui.py –grid=140 2 2
3 3
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 14 /19
Tested
I Unittests with py.test
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 14 /19
Tested
I Unittests with py.test
I Functional testing
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 14 /19
Tested
I Unittests with py.test
I Functional testing
living knowledge
I leveraging Travis CI integration with GitHub
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 15 /19
Users
I MULTIBAT: German Federal Ministry of Education and Research
project [1, 2]
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 15 /19
Users
I MULTIBAT: German Federal Ministry of Education and Research
project [1, 2]
I dune-hdd via dune-pymor
living knowledge
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 15 /19
Users
I MULTIBAT: German Federal Ministry of Education and Research
project [1, 2]
I dune-hdd via dune-pymor
I Practial course for lecture: Model Order Reduction for partial
living knowledge
differential equations
WWU Münster
René Milk ([email protected])
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 15 /19
Users
I MULTIBAT: German Federal Ministry of Education and Research
project [1, 2]
I dune-hdd via dune-pymor
I Practial course for lecture: Model Order Reduction for partial
living knowledge
differential equations
WWU Münster
I Andreas Buhr: Interactive Simulations Using Parallel,
Event-Driven Localized Reduced Basis
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 16 /19
How to get pyMOR
I Ubuntu(12.04,13.10,14.04) packages:
$ apt-add-repository ppa:pymor/stable && apt-get
update && apt-get install python-pymor-demos
I via pypi into a virtualenv:
basically $ pip install pymor
living knowledge
but see http://pymor.org first
WWU Münster
I from source:
$ git clone https://github.com/pymor/pymor
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 17 /19
I Currently 3 active developers: Stephan Rave, Felix Schindler,
René Milk
I ~13000 lines of code (Ohloh)
I ~1600 commits
Contact us at http://listserv.uni-muenster.de/
living knowledge
I
mailman/listinfo/pymor-dev
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 18 /19
Mario Ohlberger, Stephan Rave, Sebastian Schmidt, and Shiquan Zhang.
A model reduction framework for efficient simulation of li-ion batteries.
In Finite Volumes for Complex Applications VII-Elliptic, Parabolic and Hyperbolic Problems, pages 695–702.
Springer, 2014.
Stephan Rave.
BMBF-PROJEKT: MULTIBAT.
http://wwwmath.uni-muenster.de/num/ohlberger/research/projects/MULTIBAT/home.html?lang=de,
living knowledge
2014.
WWU Münster
,
,
W ESTFÄLISCHE
W ILHELMS -U NIVERSITÄT
M ÜNSTER pyMOR 19 /19
Thank you for
your attention.
living knowledge
WWU Münster
,
,