Dec 21, 2018 - The quantities Ïj are called the singular values of matrix X. ... j=1. ãx,ujãuj. F. De Vuyst. Design, optimization and reduced-order models .... Compute the correlation matrix S = XT X â MN (R);. 3. ... Consider the snaphost matrix computed from the following script: ... x = linspace (0, 1, d); x=x'; ...... Matlab code.
Design, optimization and reduced-order models as part of the SMC4 M2 course Piotr Breitkopf, Florian De Vuyst Universit´e de Technologie de Compi`egne Master M2 Mention Ing´enierie des Syst`emes Complexes (ISC) Parcours SMC (resp. Alain Rassineux)
December 21, 2018
F. De Vuyst
Design, optimization and reduced-order models
1 / 110
Part II Model order reduction (MOR) & Proper Orthogonal Decomposition (POD)
F. De Vuyst
Design, optimization and reduced-order models
2 / 110
Data dimensionality reduction
Consider a set of vector (dataset) in Rd : n o S N = x1 , x2 , ..., xN ∈ Rd Context: high-dimensional data (d 1), N = O(100) samples. In all cases, we will assume that N ≤ d.
Goal ˜ i of elements xi of S N , We look for high-fidelity approximations x expressed in a vector space of low dimension (dimensionality reduction).
F. De Vuyst
Design, optimization and reduced-order models
3 / 110
Singular Value Decomposition (SVD)
Singular Value Decomposition theorem Let X ∈ MdN (R). There exists a matrix U of size d × d, U T U = Id , a matrix V of size N × N , V T V = IN , and a matrix Σ of size d × N , Σ = diag(σj ) with σj ≥ 0 ∀j such that X = |{z} U |{z} Σ |{z} VT . |{z} d×N
d×d d×N N ×N
The quantities σj are called the singular values of matrix X.
F. De Vuyst
Design, optimization and reduced-order models
4 / 110
SVD (2) Application: consider X = x1 , x2 , ..., xN . Notations: h i U = u1 , u2 , ..., ud ,
V = v 1 , v 2 , ..., v N .
SVD : X = U ΣV T , then xi =
N X
σj hv j , ei i uj
∀i ∈ {1, ..., N }
j=1
with ei = (0, ..., 0, |{z} 1 , 0, ..., 0)T . (to check as exercise). pos. i
F. De Vuyst
Design, optimization and reduced-order models
5 / 110
Introducing reduction Let us assume that the σj are arranged in decreasing order: σ1 ≥ σ2 ≥ ... ≥ σN ≥ 0.
Projection Consider E K le vector space of dimension K spanned by the K first eigenvectors uj : E K = span u1 , u2 , ..., uK . Consider the orthogonal projection over E K defined by ΠK x =
K X
hx, uj i uj .
j=1
F. De Vuyst
Design, optimization and reduced-order models
6 / 110
Reduction (2) In particular, for x = xi we have K X Π x = hxi , uj i uj K
i
j=1
=
K X
σj hv j , ei i uj .
j=1
Projection error : N X
xi − ΠK xi =
σj hv j , ei i uj .
j=K+1
Then i
K
i 2
kx − Π x k =
N X
σj2 hv j , ei i2 .
j=K+1 F. De Vuyst
Design, optimization and reduced-order models
7 / 110
Reduction (3)
As a consequence, N X
i
K
i 2
kx − Π x k =
i=1
N N X X
σj2 hv j , ei i2
i=1 j=K+1
=
N X
σj2
N X
hei , v j i2
|i=1 {z
j=K+1
=kei k2 =1
=
N X
}
σj2 .
j=K+1
F. De Vuyst
Design, optimization and reduced-order models
8 / 110
Reduction (3) Because the singular values σj are arranged in decreasing order, PN PN i K i 2 2 i=1 kx − Π x k cannot be lower than j=K+1 σj . Actually we have the optimality principle E K = arg
min
V K vector space, dim(V K )=K
N X
K
kxi − projV (xi )k2
i=1
with E K = span(u1 , ..., uK ).
Definition The vectors u1 , ..., uK are called the K first principal components of X. Related vocabulary: Principal Component Analysis (or PCA). F. De Vuyst
Design, optimization and reduced-order models
9 / 110
Relative error estimation Recall that xi =
N X
σj hv j , ei i uj
j=1
so that
N X
kxi k2 =
i=1
N X
σj2 .
j=1
Then we have N X
i
K
N X
i 2
kx − Π x k
i=1 N X
= i 2
kx k
i=1
F. De Vuyst
σj2
j=K+1 N X
σj2
j=1
Design, optimization and reduced-order models
10 / 110
Choice of the rank K Optimal choice of K according to a tolerance ε > 0: Choose K = K(ε) that realizes K.
min K∈N /
PN
2 j=K+1 σj ≤ε 2 j=1 σj
PN
Then from the previous estimate, N X
kxi − ΠK xi k2
i=1 N X
≤ ε. i 2
kx k
i=1
F. De Vuyst
Design, optimization and reduced-order models
11 / 110
Rate of decay the singular value spectrum
The more the decay of the singular value spectrum is, the smaller the truncation rank K is. Surpinsingly, for many dataset coming from real applications, Principal Component Analysis shows an actual low-order dimension of the data. Even for high-dimensional data (dimension of order O(106 )), we may have K = O(10) for reasonable accuracy (ε = O(10−2 )).
F. De Vuyst
Design, optimization and reduced-order models
12 / 110
Correlation matrix
From X, consider the “small”, symmetric matrix S defined by S = X T X ∈ MN (R) called the correlation matrix (Sij = hxi , xi i, S is a Gram matrix). From the SVD of X, we get S = V ΣT Σ V T . Thus, the vector v 1 , ..., v N from V are the eigenvectors of S with eigenvalues λj = σj2 , j = 1, ..., N.
F. De Vuyst
Design, optimization and reduced-order models
13 / 110
Computation of the uj from X and V From X = U ΣV T , we have XV = U Σ. At column j, j = 1, ..., N we have Xv j = σ uj , or in other words 1 uj = p Xv j , λj
F. De Vuyst
j = 1, ..., N .
Design, optimization and reduced-order models
14 / 110
Summary: SVD algorithm 1. Consider the data set X = [x1 , ..., xN ]; 2. Compute the correlation matrix S = X T X ∈ MN (R); 3. Compute the eigenvalues λj and eigenvectors v j of S; 4. Fix tolerance ε, compute truncation rank K = K(ε); 5. Compute the K principal components uj , j = 1, ..., K as 1 uj = p Xv j . λj 6. Dimensionality reduction (by projection over E K ): ˜= x
K X
hx, uj i uj .
j=1
F. De Vuyst
Design, optimization and reduced-order models
15 / 110
Example in Matlab Consider the snaphost matrix computed from the following script: 1
3
5
7
9
11
clear all ; d = 200; N = 1000; x = l i n s p a c e ( 0 , 1 , d ) ; x=x ’ ; f o r j =1:N X ( : , j ) = s i n ( 2 ∗ p i ∗ x )+ 0 . 3 ∗ r a n d n ( d , 1 ) ; end ; [ U , S , V ] = s v d (X , ’ e c o n ’ ) ; % C a l l t o SVD d e c o m p o s i t i o n sigma = d i a g (S) ; % Diagonal o f s i n g u l a r v a l u e s f i g u r e ( 1 ) ; p l o t ( sigma , ’ o− ’ ) ; f i g u r e ( 2 ) ; p l o t ( x , U ( : , 1 ) , ’− ’ ) ;
The matrix X should have a main principal component, close to the vector sin(2*pi*x). F. De Vuyst
Design, optimization and reduced-order models
16 / 110
Example in Matlab (2)
Figure: Left: Spectrum of the correlation matrix. Right: First principal component
⇒ PCA can be used as a denoising algorithm. F. De Vuyst
Design, optimization and reduced-order models
17 / 110
Application to Finite Element discretized functions Notations Consider a polyhedral domain Ωh of R2 . Consider a triangulation T h of Ωh . Consider P 1 finite elements of triangles K ∈ T h , degrees of freedom at nodes. Let V h be associated (discrete) finite element space. dim(V h ) = d. Functional Hilbert space: V defined on Ωh , with scalar product (., .)V . Conformal FE space: V h ⊂ V . Finite element Lagrange basis ’hat’ functions : ωi (x). ( ) d X h h h h V = v ∈ V , v (x) = vi ωi (x) . i=1
F. De Vuyst
Design, optimization and reduced-order models
18 / 110
Bridges between functional and vector spaces h
h
v ∈V ,
h
v (x) =
d X
vi ωi (x).
i=1
Let us denote v = (v1 , v2 , ..., vd )T ∈ Rd . We have correspondence between v h and v. Let v h , wh ∈ V h , with respective vector representations v, w ∈ Rd . We have d d X X (v , w )V = ( vi ωi , wj ωj )V h
h
i=1
=
d X d X i=1 j=1
j=1
vi wj (ωi , ωj )V | {z } :=Mij
T
= w M v = hv, M wiRd = hv, wiM . F. De Vuyst
Design, optimization and reduced-order models
19 / 110
Functional and vector correspondence As a summary, (v h , wh )V = hv, wiM . Ex: V = L2 (Ωh ), Mij = (ωi , ωj )L2 then M is the FE mass matrix. In particular, kv h k2V = kvk2M .
Choleski factorization of M The matrix M is a Gram, symmetric positive definite matrix. Then there exists a lower triangular matrix B with diagonal elements Bii > 0 such that M = BB T . Then we also have (v h , wh )V = hB T v, B T wiRd . F. De Vuyst
Design, optimization and reduced-order models
20 / 110
PCA on Finite Element functions Let S N be a set of FE functions in V h : n o S N = f 1,h , f 2,h , ..., f N,h ∈ V h . Vector representation of the set: n o S N = f 1 , f 2 , ..., f N ∈ Rd . Consider also
n o T N = x1 , x2 , ..., xN ∈ Rd
with xi = B T f i .
F. De Vuyst
Design, optimization and reduced-order models
21 / 110
Scalar products
From function-vector correspondence properties, we have (f i,h , f j,h )V = hf i , f j iM = hxi , xj i = (xj )T xi . We have also kf i,h − f j,h k2V = kf i − f j k2M = kxi − xj k2 .
F. De Vuyst
Design, optimization and reduced-order models
22 / 110
PCA in vectors (xi )i Let us apply the SVD decomposition on the set T N : considering the matrix X = [x1 , x2 , ..., xN ], we have the SVD decomposition of X: X = U ΣV T. Consider the orthogonal projection over the vector space E K = span(u1 , u2 , ..., uK ): ΠK x =
K X
hx, ui i ui .
i=1
F. De Vuyst
Design, optimization and reduced-order models
23 / 110
Projection for the (f i )i, i = 1, ..., N Consider the vectors Φi defined by Φi = B −T ui . We have the orthogonality property hΦi , Φj iM = hB −T ui , B −T uj iM = hui , uj i = δij One can define the projection formula ΠK f =
K X hf , Φi iM Φi . i=1
F. De Vuyst
Design, optimization and reduced-order models
24 / 110
Projection for the f i,h From the definition of ΠK f , we can finally define a projection operator acting on FE functions: K h
Π f (x) =
K X
(f h , ϕi,h )V ϕi,h (x)
i=1
where i,h
ϕ (x) =
d X
(Φi )j ωj (x).
j=1
Proper Orthogonal Decomposition modes The functions ϕi,h (x) are called the Proper Orthogonal Decomposition modes (or POD modes).
F. De Vuyst
Design, optimization and reduced-order models
25 / 110
Proper Orthogonal Decomposition
The POD modes have the orthogonality property in V : (ϕi,h , ϕj,h )V = hΦi , Φj iM = δij .
F. De Vuyst
Design, optimization and reduced-order models
26 / 110
POD projection error Since h
kf i,h − ΠK f i kV = kf i − ΠK f j kM = kxi − ΠK xi k and similarly kf i,h kV = kxi k from the PCA error control K = K(ε) such that N X
kxi − ΠK xi k2
i=1 N X
≤ ε, kxi k2
i=1
we have the same projection error estimate for the FE functions. F. De Vuyst
Design, optimization and reduced-order models
27 / 110
POD projection error (2)
As a summary, N X
kf i,h − ΠK f i,h k2V
i=1 N X
≤ ε, kf i,h k2V
i=1
F. De Vuyst
Design, optimization and reduced-order models
28 / 110
Practical algorithm Practically, one can skip the Choleski factorization of the matrix M . Indeed, remember that xi = B T f i , so that X = [x1 , x2 , ..., xN ] = [B T f 1 , B T f 2 , ..., B T f N ] := B T F. Consider the correlation matrix S = X T X: Sij = hxi , xj i = hB T f i , B T f j i = hf i , f j iM . From S, we compute the eigenvalues λj and the eigenvectors v j .
F. De Vuyst
Design, optimization and reduced-order models
29 / 110
Practical algorithm (2)
Moreover, it is possible to reconstruct the eigenvectors Φj without the need of B. Indeed, recall that 1 uj = p Xv j , λj then
Φi = B −T ui ,
X = B T F,
1 Φj = p F v j . λj
F. De Vuyst
Design, optimization and reduced-order models
30 / 110
Final algorithm 1. Compute the snapshot matrix F = f 1 , f 2 , ..., f N ; 2. Compute the correlation matrix S = FT MF and the associated eigenvalues λj and eigenvectors v j ; 3. Compute the dual eigenvectors Φj such that 1 Φj = p F v j . λj 4. Compute the truncation rank K = K(ε) according to the projection error formula. F. De Vuyst
Design, optimization and reduced-order models
31 / 110
Final algorithm (2)
5. The K first POD modes ϕi,h ∈ V h , i = 1, ..., K are given by the formula K X i,h (Φi )j ωj (x). ϕ (x) = j=1
F. De Vuyst
Design, optimization and reduced-order models
32 / 110
Computation of POD coefficients For f h ∈ V h , we have ΠK f h (x) =
K X (f h , ϕk,h )V ϕk,h (x) k=1
or equivalently (vector representation) K
Π f=
K X
hf , Φk iM Φk .
k=1
So the POD projection coefficients ak (f ) for f are ak (f ) = hf , Φk iM = (Φk )T M f . ⇒ Does it really need the knowledge of M for computation ? F. De Vuyst
Design, optimization and reduced-order models
33 / 110
Computation of POD coefficients : TRICK Actually, it is sufficient to know the correlation matrix S = F T M F . Remember that 1 Φj = p F v j . λj Let us denote Φr = [Φ1 , ..., ΦK ], V r = [v 1 , ..., v K ], Λr = diag(λ1 , ..., λK ). Then Φr = F V r (Λr )−1/2 and [a1 , a2 , ..., aN ] = (Φr )T M F = (Λr )−1/2 (V r )T F T M F = (Λr )−1/2 (V r )T S. F. De Vuyst
Design, optimization and reduced-order models
34 / 110
Summary The matrix of reduced snapshot POD coefficients is given by [a1 , a2 , ..., aN ] = (Λr )−1/2 (V r )T S. (important formula). NB : computation of the POD coefficients of complexity O(KN 2 ), which is far reasonable for N = O(100) and K = O(10). Reconstruction in the physical (high-dimensional) space: f˜i = Φr ai ,
i = 1, ..., N
(requires high-dimensional operations).
F. De Vuyst
Design, optimization and reduced-order models
35 / 110
Application to partial differential parametrized problems
F. De Vuyst
Design, optimization and reduced-order models
36 / 110
Problems of interest
ξ : design parameter vector, ξ ∈ X ⊂ Rp u(.; ξ) ∈ V : function, solution of a (nonlinear) partial differential problem: N (u(.; ξ)) = f (.; ξ). Quantities of interest: fi (ξ) = `i (u(.; ξ)).
F. De Vuyst
Design, optimization and reduced-order models
37 / 110
Design of Computer Expreriment (DoCE)
1. Consider a sampling {ξi }i=1,...,N of the design set X ; 2. Compute each solution ui,h (x) = uh (x; ξi ) from a Finite Element solver (offline phase, computationally expensive). Vector representation: ui ∈ Rd ; 3. Create a database X = u1 , u2 , ..., uN ∈ MdN (R). 4. Compute the POD modes ϕi,h (x) associated to X.
F. De Vuyst
Design, optimization and reduced-order models
38 / 110
Model order reduction From the POD modes, one can define a low-order approximation u ˜h (x; ξ) of uh (x; ξ) by h
u ˜ (x; ξ) =
K X
ak (ξ) ϕk,h (x).
k=1
Vector-based representation of the same formula: u ˜h (x; ξ) = [ϕ1,h(x) , ϕ2,h (x), ..., ϕN,h (x)] a(ξ) with a(ξ) = [a1 (ξ), a2 (ξ), ..., aK (ξ)]T ∈ RK vector of coefficients.
F. De Vuyst
Design, optimization and reduced-order models
39 / 110
Determination of the coefficients
Because the POD modes ϕk,h are orthonormal, we have ak (ξ) = (uh (.; ξ), ϕk,h )V .
(1)
Online phase: from a new evaluation at parameter vector ξ, we want to get an approximation u ˜h (x; ξ). But ak (ξ) cannot be computed from (1) because we do not know uh (.; ξ). ⇒ Compute a metamodel a ˜k (ξ) of ak (ξ). Q: how to do ?
F. De Vuyst
Design, optimization and reduced-order models
40 / 110
Back to be offline stage During the offline stage, the solutions ui,h = uh (.; ξi ) have been computed. So one can compute ak (ξi ) = (ui,h , ϕk,h )V = hui , Φk iM and form the vectors ai = (ak (ξi ))k ∈ RK ,
∀ i = 1, ..., N
So summarize, we obtain a cloud of points (ξi , ai ) ∈ Rp × RK , i ∈ {1, 2, ..., N } . ⇒ Find the manifold mapping that interpolates (or approximates) the points (ξi , ai ).
F. De Vuyst
Design, optimization and reduced-order models
41 / 110
Kernel-based interpolation One can once again use kernel-based interpolation to compute the nonlinear mapping: ˜ (ξ) = a
N X
wj k(ξ, ξj ).
j=1
where wj ∈ RK for all j = 1, ..., N . Interpolation property: we want ˜ (ξi ) = a(ξ) ∀i = 1, ..., N. a This leads to the matrix identity A=KW
⇒
W = K −1 A
where A = [a(ξ1 ), ...a(ξN )], K = (k(ξi , ξj ))ij is the spd kernel matrix and W is the matrix of unknown vector coefficients. F. De Vuyst
Design, optimization and reduced-order models
42 / 110
Final reduced-order model
We obtain the reduced-order model u ˜h (x; ξ) =
K X
˜ (ξ) ϕk,h (x) a
k=1
where ˜ (ξ) = a
N X
wj k(ξ, ξj )
j=1
with the matrix of vector coefficients W = K −1 A,
A = [a(ξ1 ), ...a(ξN )].
F. De Vuyst
Design, optimization and reduced-order models
43 / 110
Metamodels for the objective functions
Recall that each objective function fi (ξ) is a linear or nonlinear function of uh (.; ξ): fi (ξ) = `i (uh (.; ξ)). Few examples: fi (ξ) = min uh (x; ξ) x∈Ωh
or
1 fi (ξ) = h |Ω |
Z
(non linear)
uh (x; ξ) dx
(linear).
Ωh
F. De Vuyst
Design, optimization and reduced-order models
44 / 110
Case of a linear functional
In the case of linear functional, fi (ξ) can be approximated by f˜i (ξ) = `i (˜ uh (.; ξ)) = `i
K X
! a ˜k (ξ)ϕk,h (.)
k=1
=
K X k=1
a ˜k (ξ) `i (ϕk,h (.x)) {z } |
F. De Vuyst
to compute offline
Design, optimization and reduced-order models
45 / 110
Case of a nonlinear functional
In the nonlinear case, unfortunately, the evaluation of ! K X k,h f˜i (ξ) = `i a ˜k (ξ)ϕ (.) k=1
requires high-dimensional operations and offline pre-computations are irrevelant in this case. ⇒ Requires the design of a new (nonlinear) metamodel ˜ (ξ) ∈ RK −→ f˜i (ξ) ∈ Rm . ξ ∈ Rp −→ a
F. De Vuyst
Design, optimization and reduced-order models
46 / 110
PRACTICAL WORK (Freefem++ and Matlab)
F. De Vuyst
Design, optimization and reduced-order models
47 / 110
Practical Work
Software environment: 1. Finite Element solver : Freefem++ 2. SVD, PCA, visualization : Matlab + PDE Toolbox 3. Freefem++-to-Matlab interface (by Julien Dambrine)
F. De Vuyst
Design, optimization and reduced-order models
48 / 110
Freefem++ to Matlab interface
See : http://www.tobias-rienmueller.de/post/freefem2matlab.html
F. De Vuyst
Design, optimization and reduced-order models
49 / 110
Step 1 – First experiment Run the Freefem++ script freefem-example.edp. 1
3
5
7
9
// s o l v e P o i s s o n ( u , v , s o l v e r=LU) = i n t 2 d ( Th ) ( dx ( u ) ∗ dx ( v ) + dy ( u ) ∗ dy ( v ) ) − i n t 2 d ( Th ) ( s o ∗v ) + on ( a , b , c , d , e , f , u=0) ; p l o t ( Th , u ) ; s a v e m e s h ( Th , ” G i l g a m e s h . msh” ) ; // f r e e f e m { o f s t r e a m f i l e ( ” Heat . bb ” ) ; f i l e 0. Vector form: x(t) = (x(t), y(t)), x˙ = f (x),
t>0
NB: for µ λ, we have x(t) = exp(−λt)x0 and y(t) ≈ (x(t))2 .
F. De Vuyst
Design, optimization and reduced-order models
80 / 110
Nonlinear case: example NB: for µ λ, we have x(t) = exp(−λt)x0 and y(t) ≈ (x(t))2 . Consider τ > 0 and xk = x(kτ ). Then xk = exp(−λkτ )x0 ,
y k ≈ (xk )2
and xk+1 = exp(−λτ )xk ,
y k+1 ≈ (xk+1 )2 = exp(−2λτ )(xk )2 .
A linear model in the form k+1 k x x =A y k+1 yk is not suitable for such a linear system. BUT ... F. De Vuyst
Design, optimization and reduced-order models
81 / 110
Nonlinear case: example (2) BUT ... including the new observable z k = (xk )2 , we observe that xk+1 = exp(−λτ )xk , z k+1 = exp(−2λτ )z k , z k+1 = exp(−2λτ )z k , that can be written in matrix-vector form k k+1 x x exp(−λτ ) 0 0 y k+1 = 0 0 exp(−2λτ ) yk k+1 0 0 exp(−2λτ ) zk z Conclusion: by variable augmentation, it has been able to transform the linear system into a linear one.
F. De Vuyst
Design, optimization and reduced-order models
82 / 110
Another example (continuous in time) Consider the next example (λ > 0) x˙ = −λx2 x0 = x0 > 0. Introducing x2 = x2 , we have x˙ = −λx2 ,
(x˙2 ) = −2λx3 .
Introducing x3 = x3 , we have (x˙2 ) = −2λx3 ,
(x˙3 ) = −3λx4 ,
etc...
F. De Vuyst
Design, optimization and reduced-order models
83 / 110
Infinite dimensional system
Actually we get an infinite-dimensional system 0 −λ 0 x 0 0 −2λ x d 2 = 0 dt x3 0 0 .. .. .. .. . . . .
but linear differential
0 0 −3λ .. .
x ... x2 . . . . . . x3 .. .. . .
Rem: x2 = x2 , x3 = x3 ,... are called the features in Data Science or in Artificial Intelligence (AI).
F. De Vuyst
Design, optimization and reduced-order models
84 / 110
Another example (continuous in time) (3)
Remark: consider the n-th augmented variable xn = xn with n big enough. We have the differential equation n+1 (x˙n ) = −nλxn+1 = −nλ (xn ) n
then
1 (x˙n ) = −nλ (xn )1+ n
which is a weakly nonlinear differential equation. Then we can expect that DMD gives reasonable results in this case.
F. De Vuyst
Design, optimization and reduced-order models
85 / 110
Open problem
Up to today’s knowledge, for a general nonlinear system, there is no algorithm able to automatically select the optimal nonlinear observables (features) to transform (or approximate) the problem into a linear one of minimal size. Any idea ?
F. De Vuyst
Design, optimization and reduced-order models
86 / 110
Mixing POD and DMD ...
F. De Vuyst
Design, optimization and reduced-order models
87 / 110
Framework
Consider the following partial differential problem ∂t u − κ∆u =
L X
v` (t)ψ` (x)
in Ω × (0, T ],
`=1
dv = Bv(t), t ∈ (0, T ], dt u(., t) = 0 on ∂Ω, u(., t = 0) = u0 (.)
in Ω,
v(0) = v 0 . with v(t) = (v1 (t), v2 (t), ..., vL (t))T .
F. De Vuyst
Design, optimization and reduced-order models
88 / 110
Semi-discretization in space Using Finite Element spatial discretization, suppose that the resulting dynamical system reads du = Au + Ψv, t ∈ (0, T ], dt dv = Bv, dt u(0) = u0 , v(0) = v 0 where u(t) = (u1 (t), u2 (t), ..., ud (t))T . Rem: functional correspondence h
u (x, t) =
d X
ui (t) ωi (x).
i=1
F. De Vuyst
Design, optimization and reduced-order models
89 / 110
Vector form
d dt Initial condition:
u A Ψ u = v 0 B v
0 u u (t = 0) = . v v0
We have a linear differential problem of high dimension (d + L).
F. De Vuyst
Design, optimization and reduced-order models
90 / 110
Step 1: POD on the heat equation Using different snapshots of the FE solution (uh (., ti ))i=1,...,N , one can find a POD basis made of K POD modes ϕ1,h , ϕ2,h , ... ϕK,h . Vector correspondence : Φ1 , Φ2 , ..., ΦK ∈ Rd . POD matrix: Φ = Φ1 , Φ2 , ..., ΦK ∈ Md×K
(ΦT Φ = I).
Reduced-order approximate solution: we look for a solution in the form L X ˜ = u(t) ak (t)Φk = Φa(t). k=1
˜ Rem: we also have a(t) = ΦT u(t). F. De Vuyst
Design, optimization and reduced-order models
91 / 110
Reduced-order system
Considering x(t) = (a(t), v(t))T ∈ RK+L (small size), we look for a matrix A such that x˙ = Ax. Initial condition: x(0) = ΦT u0 , v 0
T
.
⇒ The matrix A can be identified from snaphot data matrices X and Y following the DMD methodology.
F. De Vuyst
Design, optimization and reduced-order models
92 / 110
Whole algorithm 1. Choose a sampling time τ > 0. 2. Compute K spatial POD modes Φk from snaphosts computed by the fine solver 3. Compute snapshots in the reduced-order space: ak = a(τ k), k = 1, ..., N . 4. Compute also v k = v(τ k), k = 1, ..., N . 5. Consider the variables xk = (ak , v k )T , k = 1, ..., N . 6. Assemble two snapshots matrices X = [x0 , x1 , ..., xN −1 ],
Y = [x1 , x2 , ..., xN ].
7. Compute A according to the DMD formula: A = Y X †. 8. We get a dynamical ROM: ˜ k+1 = A˜ ˜ k+1 = Φ˜ x ak , xk+1 = (ak+1 , v k+1 )T , u ak+1 . F. De Vuyst
Design, optimization and reduced-order models
93 / 110
Example Example: consider the ODE-PDE harmonic oscillator + 1d heat equation system with boundary condition coupling: 2 ∂t u − κ∂xx u=0
in (0, 1) × (0, T ],
v˙ = w, w˙ = −v, u(0, t) = 0,
u(1, t) = v(t) t ∈ [0, T ],
u(x, t = 0) = 0
in (0, 1)
v(0) = 0, w(0) = 1. Rem: we have v(t) = sin(t), w(t) = cos(t), but we don’t know analytical solutions for u.
F. De Vuyst
Design, optimization and reduced-order models
94 / 110
Semi-discretization in space Consider centered finite differences for spatial discretization: ui (t) ≈ u(xi , t), xi = ih, h =
1 . N +1
We have u0 (t) = 0 (left boundary condition), dui (t) κ + 2 (−ui−1 (t) + 2ui (t) − ui+1 (t)) = 0, (t) h and
i = 1, ..., N − 1,
duN (t) κ κ + 2 (−uN −1 (t) + 2uN (t)) = 2 v(t). dt h h
Vector form : let us introduce u(t) = (u1 (t), ..., uN (t))T ∈ RN .
F. De Vuyst
Design, optimization and reduced-order models
95 / 110
Semi-discretization in space (2) Then by considering the state vector u(t) u(t) x(t) = , a(t) = , a(t) v(t) we have the following linear differential system of size (N + 2): d u(t) −A B u(t) = [0] C a(t) dt a(t) with κ A = 2 tridiag(−1, 2, −1), h and
C=
0 1 −1 0
T 0 0 ... 0 κ/h2 B= . 0 0 ... 0 0 F. De Vuyst
Design, optimization and reduced-order models
96 / 110
Matlab code
2
4
6
8
% edoedp .m % ( Heat e q u a t i o n + h a r m o n i c o s c i l l a t o r ) N = 200; M = 15; dt = 0 . 1 ; D = 0 . 0 5 ; % Thermal c o n d u c t i v i t y h = 1 / (N+1) ; % ...
F. De Vuyst
Design, optimization and reduced-order models
97 / 110
Matlab code (2)
34
36
38
40
42
44
% ... w h i l e ( t < T) % t i m e l o o p k = k + 1; t = k∗ dt ; F (N+2 ,1) = s i n ( t ) ; % r i g h t hand s i d e u = A \ ( ( C−B) ∗u + F ) ; % l i n e a r s y s t e m t o s o l v e ( h e a t ) s n a p p d e = [ snappde , u ] ; % g e t s n a p s h o t s o f h e a t s o l s n a p o d e = [ snapode , [ s i n ( t ) ; c o s ( t ) ] ] ; % g e t s n a p s h o t s % of the o s c i l l a t o r p l o t ( x , u , ’ .− ’ ) ; a x i s ( [ 0 1 −1 1 ] ) ; g r i d ; drawnow ; end ; % ...
F. De Vuyst
Design, optimization and reduced-order models
98 / 110
Matlab code (3)
46
48
50
52
% POD + b u i l d d a t a m a t r i c e s f o r DMD [ U , S , V ] = s v d ( snappde , 0 ) ; P s i = U ( : , 1 :M) ; % T a i l l e N∗M a = P s i ’ ∗ s n a p p d e ; % Reduced v a r i a b l e s , r e d u c e d m a t r i x % snaps = [ a ; snapode ] ; % Concatenation X = s n a p s ( : , 1 : end −1) ; % e n t r i e s Y = s n a p s ( : , 2 : end ) ; % o u t p u t s A = Y∗ p i n v (X) ; % DMD f o r m u l a
F. De Vuyst
Design, optimization and reduced-order models
99 / 110
Matlab code (4)
60
62
64
66
68
70
72
% Then p l a y t h e d y n a m i c a l s o l u t i o n d i s p ( ” Reduced o r d e r model . . . ” ) % I n i t i a l state a0 = [ a ( : , 1 ) ; 0 ; 1 ] ; ak = a0 ; clf ; f o r k =1:1200 % t i m e l o o p ( s i m u l a t i o n ) ak = A∗ ak ; % Time a d v a n c e apde = ak ( 1 :M, 1 ) ; % g e t POD c o e f f i c i e n t s u = P s i ∗ apde ; % P l o t h e a t s o l u t i o n (ROM) p l o t ( x , u , ’ .− ’ ) ; a x i s ( [ 0 1 −1 1 ] ) ; g r i d ; drawnow ; end ; % f o r k %
F. De Vuyst
Design, optimization and reduced-order models 100 / 110
Modulus of the eigenvalues of A
>> abs(eig(A))’ ans = Columns 1 through 8 0.9518
0.8204
0.6366
0.4339
0.2339
0.0322
0.1864
0.4074
0.8573
0.9229
0.9921
0.9612
0.9820
1.0000
Columns 9 through 16 0.6025
0.7532
Column 17 1.0000
F. De Vuyst
Design, optimization and reduced-order models 101 / 110
Case of inhomogeneous systems
Suppose that the dynamics is given by the (linear) inhomogeneous system of equations du + Au = f (t), dt u(0) = u0 At time t = τ , the solution is given by Z τ 0 u(τ ) = exp(−Aτ ) u + exp(−A(τ − s))f (s) ds . | {z } 0 | {z } =A unpredictable !
F. De Vuyst
Design, optimization and reduced-order models 102 / 110
Case of a constant source term In case of a constant f (independent of time), i.e., du + Au = f , dt the solution at time t = τ is 0
u(τ ) = exp(−Aτ ) u + | {z } =A
Z |0
τ
exp(−A(τ − s))) ds f . {z } b
We get the discrete dynamical system uk+1 = Auk + b. We can try to identify both matrix A and vector b from data.
F. De Vuyst
Design, optimization and reduced-order models 103 / 110
Extended DMD approach for inhomogeneous equations Consider the extended vector k u k x = ∈ Rd+1 , 1 then the snapshot matrices X = [x0 , ..., xN −1 ],
Y = [u1 , ..., uN ].
Then find AE ∈ Md,d+1 (R) that minimizes kAE X − Y k2F . The solution is again AE = Y X † . NB: the (d + 1)-th column of AE gives b and AE = (A|b). F. De Vuyst
Design, optimization and reduced-order models 104 / 110
Applications of the inhomogeneous model
Possible applications: linear heat equation with heat source f being constant in time or piecewise constant in time, e.g. f (x, t) = f1 (x) 1tt0 (t). ⇒ Requires the derivation of a DMD model for each constant component of f . NB: This framework can be used for the project on switched control heating system.
F. De Vuyst
Design, optimization and reduced-order models 105 / 110
HOMEWORK on DMD
F. De Vuyst
Design, optimization and reduced-order models 106 / 110
Homework Exercise 1. - Consider the two mass-spring coupled system x˙1 = u1 , m1 u˙1 = −k1 x1 + k2 (x2 − x1 ), x˙2 = u2 , m2 u˙2 = −k2 (x2 − x1 ) − k3 x2 , x1 (0) = 0,
x2 (0) = 0,
F. De Vuyst
u1 (0) = 1,
u2 (0) = 0.
Design, optimization and reduced-order models 107 / 110
Mass-spring system (2) Setting x = (x1 , x2 , u1 , u2 )T , we have 0 0 1 0 0 0 0 1 0 0 0 0 0 0 m1 0 x˙ = −(k1 + k2 ) k2 k2 −(k2 + k3 ) 0 0 0 m2 | {z =A
1 0 0 0
0 1 x, 0 0 }
and x(0) = (0, 0, 1, 0T ). Rem: the total energy E of the system 1 1 1 1 1 E = k1 x21 + k3 x22 + k2 (x2 − x1 )2 + m1 u21 + m2 u22 2 2 2 2 2 is conserved. F. De Vuyst
Design, optimization and reduced-order models 108 / 110
Exercise 1. Compute the eigenvalues of A 2. Numerical parameters: m1 = 1, m2 = 1/2, k1 = k2 = 1, k3 = 1/2, x0 = (0, 0, 1, 0)T ; 3. Use ode45() from Matlab to solve the system. Use a sample time τ = 0.05 and generate 1000 sample states xk 4. Apply DMD methodology to compute a DMD matrix A such that xk+1 ≈ Axk . 5. Use the DMD model to simulate the system and compare the results to the solution given by ode45(). 6. Check the value of the total energy E during time iterations using the DMD model. 7. Do the real time visualization of the mass-spring dynamics F. De Vuyst
Design, optimization and reduced-order models 109 / 110
Solutions given by the DMD model
NB: if the fine solver preserves the total energy, then the DMD model keeps the property (for noiseless data). F. De Vuyst
Design, optimization and reduced-order models 110 / 110