MATH661 Project 1
Large system factorization and model reduction

Posted: 10/02/23

Due: 10/16/21, 11:55PM (first draft, comments will be returned, revision due on 10/30)

This project presents a typical medium-size problem involving the concepts from approximation using linear combinations: transformation of coordinates, least squares, different types of basis sets.

1Introduction

1.1Modeling binary interaction in science and engineering

Many systems consist of point interactions. The iconic Eiffel Tower can be modeled through the trusses linking two points with coordinates ๐’™i,๐’™jโˆˆโ„3. The unit vector along direction from point i to point j is

๐’iโกj=๐’™j-๐’™i||๐’™j-๐’™i||โก.

Suppose that structure deformation changes the coordinates to ๐’™i+๐’–i, ๐’™j+๐’–j. The most important structural response is a force ๐’‡iโก exerted on point i that can be approximated as

๐’‡iโก=๐’iโกjโก๐’iโกjTโก(๐’–j-๐’–i),

in appropriate physical units. An opposite force ๐’‡jโก=-๐’‡iโก acts on point j by principle of action and reaction. Note the projector along the truss direction ๐‘ทiโกj=๐’iโกjโก๐’iโกjTโก, allowing computation of nodal forces as

๐’‡i=๐‘ทiโกjโก๐’–j-๐‘ทiโกjโก๐’–i
๐’‡j=-๐‘ทiโกjโก๐’–j+๐‘ทiโกjโก๐’–i

Adding forces on a point from all trusses leads to the linear relation

๐’‡=๐‘ฒโก๐’– (1)

with ๐’‡,๐’–โˆˆโ„m the forces and displacements, ๐‘ฒโˆˆโ„mร—m the stiffness matrix, d=3 the number of dimensions, N the number of points, and m=dโกN, the number of degrees of freedom of the structure. This is a simple example of a finite element method. The vectors ๐’‡,๐’– contain the forces, displacements at all nodes, e.g.,

๐’–=[ ๐’–1 ๐’–2 โ‹ฎ ๐’–m ],

with each ๐’–iโˆˆโ„d. Assembly of the stiffness matrix ๐‘ฒ is carried out by adding contributions from each truss

[ โ‹ฎ ๐’‡i โ‹ฎ ๐’‡j โ‹ฎ ]=[ โ‹ฑ โ‹ฎ โ€ฆ โ‹ฎ -๐‘ทiโกj โ€ฆ ๐‘ทiโกj โ‹ฎ โ‹ฑ โ‹ฎ ๐‘ทiโกj โ€ฆ -๐‘ทiโกj โ‹ฎ โ€ฆ โ‹ฎ โ‹ฑ ][ โ‹ฎ ๐’–i โ‹ฎ ๐’–j โ‹ฎ ].

Such point interactions arise in molecular or social interactions, cellular motility, and economic exchange much in the same form (1). The techniques in this homework are thus equally applicable to physical chemistry, sociology, biology or business management.

Figure 1. (Left) Eiffel Tower model. (Center) Model nodes. (Right) Model edges.

1.2Problem data

Problem setup is carried through the following steps.

โˆ˜Add required Julia packages.

โ€ขLoad the data.

The following are typical instructions: open a file, load data, close the file.

โˆด 
ddir = homedir()*"/courses/MATH661/data/EiffelTower";
โˆด 
using MAT
โˆด 

Load the model point coordinates, display the first 3 node coordinates

โˆด 
dfile = matopen(ddir*"/EiffelPoints.mat");
โˆด 
X=read(dfile,"Expression1");
โˆด 
close(dfile);
โˆด 
NX,ndims=size(X);
โˆด 
X[1:3,:]

[ 12.563704490661621 -12.563704490661621 37.89190673828125 -12.563704490661621 -12.563704490661621 37.89190673828125 -14.107048034667969 -14.107048034667969 37.89190673828125 ] (2)

โˆด 

Load the model edges (links between the nodes) as floating point numbers (Matlab .mat file format)

โˆด 
dfile = matopen(ddir*"/EiffelLines.mat");
โˆด 
flL=read(dfile,"Expression1");
โˆด 
close(dfile);
โˆด 

Display model size

โˆด 
NL,nseg=size(flL); [NX ndims NL nseg]

[ 26464 3 31463 2 ] (3)

โˆด 

The model contains NX=26464 nodes (points) each with d=3 coordinates and NL edges (links) between node pairs. Transform the links to integers and display the first 4 edges.

โˆด 
L=zeros(Int64,NL,nseg);
โˆด 
for l=1:NL
  L[l,:] = floor.(Int64,flL[l,:])
end
โˆด 
L[1:4,:]

[ 519 520 520 521 521 519 540 541 ] (4)

โˆด 

The above states the first edge is from node i=519 to node j=520.

โ€ขDefine the system matrix ๐‘ฒ.

Figure 2. Structure of ๐‘ฒ at various magnification factors

The data contains NX points in โ„d, d=3, and NL line segments defined by 2 endpoints. The total number of degrees of freedom is m=dโกNX. Of the possible NX2โ‰…7ร—108 linkages between points in the structure, only NL=31463 are present.

โˆด 
m=3*NX; [NX NX^2 NL m m^2]

[ 26464 700343296 31463 79392 6303089664 ] (5)

โˆด 

The matrix ๐‘ฒ can be formed by loops over the trusses as shown in the algorithm below.

Algorithm ๐‘ฒ assembly

for k=1 to NL

i=Lk,1; j=Lk,2

๐’=๐‘ฟj-๐‘ฟi; ๐’=๐’/||๐’||; ๐‘ท=๐’โก๐’T

p=d(i-1); q=d(j-1)

for id=1 to d

for jd=1 to d

๐‘ฒ[p+id,p+jd]=๐‘ฒ[p+id,p+jd]-๐‘ท[id,jd]

๐‘ฒ[p+id,q+jd]=๐‘ฒ[p+id,q+jd]+๐‘ท[id,jd]

๐‘ฒ[q+id,p+jd]=๐‘ฒ[q+id,p+jd]+๐‘ท[id,jd]

๐‘ฒ[q+id,q+jd]=๐‘ฒ[q+id,q+jd]-๐‘ท[id,jd]

end

end

end

[ โ‹ฎ ๐’‡i โ‹ฎ ๐’‡j โ‹ฎ ]=[ โ‹ฎ โ€ฆ โ‹ฎ -๐‘ทiโกj โ€ฆ ๐‘ทiโกj โ‹ฎ โ‹ฑ โ‹ฎ ๐‘ทiโกj โ€ฆ -๐‘ทiโกj โ‹ฎ โ€ฆ โ‹ฎ ][ โ‹ฎ ๐’–i โ‹ฎ ๐’–j โ‹ฎ ].

Define a function to carry out the assembly process in d dimensions that returns a full matrix ๐‘ฒ.

โˆด 
function assembleK(d,L,X)
  NL = size(L)[1]; n=maximum(L); m=d*n; K=zeros(m,m)
  for k=1:NL
    i=L[k,1]; j=L[k,2]
    l=X[j,1:d]-X[i,1:d]; l=l/norm(l)
    p=d*(i-1); q=d*(j-1); P=l*l'
    for id=1:d
      for jd=1:d
        K[p+id,p+jd] = K[p+id,p+jd] - P[id,jd]
        K[p+id,q+jd] = K[p+id,q+jd] + P[id,jd]
        K[q+id,p+jd] = K[q+id,p+jd] + P[id,jd]
        K[q+id,q+jd] = K[q+id,q+jd] - P[id,jd]
      end
    end
  end
  return K
end;
โˆด 
XB

[ 0 1 ] (6)

โˆด 
LB

[ 1 2 ] (7)

โˆด 
assembleK(1,LB,XB)

[ -1.0 1.0 1.0 -1.0 ] (8)

โˆด 
size(LB)

[ 1 2 ] (9)

โˆด 

The above has been precomputed for the Eiffel Tower model. It is wasteful, and often impossible due to memory constraints, to store the entire matrix of possible couplings between points ๐‘ฒโˆˆโ„mร—m (m2โ‰…6.3ร—109) since most of the matrix would consist of zero entries. Rather, only the nonzero elements corresponding to the linked nodes are stored through what is known as a sparse matrix. There are various techniques to store sparse matrices, one of which is the coordinate format defined by a vector of row indices i, a vector of column indices j and a vector of values v such that the (i,j) element of the matrix ๐‘ฒ is

kiโกj=K(i(k),j(k))=v(k).

The following instructions load the sparse representation of ๐‘ฒ.

โˆด 
dfile = matopen(ddir*"/KCOO.mat");
โˆด 
flrows=read(dfile,"rows");
โˆด 
flcols=read(dfile,"cols");
โˆด 
vals=read(dfile,"vals");
โˆด 
close(dfile);
โˆด 
nz=size(flrows)[1]

370621

โˆด 
rows=zeros(Int64,nz,1); cols=zeros(Int64,nz,1);
โˆด 
for l=1:nz
  rows[l] = floor(Int64,flrows[l])
  cols[l] = floor(Int64,flcols[l])
end
โˆด 
[minimum(rows) maximum(rows) minimum(cols) maximum(cols)]

[ 1 79392 1 79392 ] (10)

โˆด 
using SparseArrays
โˆด 
K=sparse(rows[:,1],cols[:,1],vals[:,1]);
โˆด 
size(K)

[ 79392 79392 ] (11)

1.3Utility routines

โˆ˜Draw the deformed structure in figure nf, given node coordinates ๐‘ฟโˆˆโ„NXร—d, displacements ๐’–โˆˆโ„m, m=dโกNX, skipping ks nodes (to reduce drawing time).

โˆ˜Draw the deformed structure in figure nf, given node coordinates ๐‘ฟโˆˆโ„NXร—d, displacements ๐‘ผโˆˆโ„NXร—d, m=dโกNX, skipping ks nodes.

1.4Simplified โ€œAโ€ model

The full Eiffel Tower model is quite complex. It is convenient to build familiarity with modeling binary interactions using the much simpler two-dimensional (d=2) 8-node model shown in Fig. 3

Figure 3. โ€œAโ€ model of Eiffel tower

โ€ขDefine the data for this model and compute ๐‘ฒ.

โˆด 
x5 = (2.0/3.0)*2; x7 = (1.0/3.0)*2; [x5 x7]

[ 1.3333333333333333 0.6666666666666666 ] (12)

โˆด 
X=[-2 0; 2 0; -x5 2; 0 2; x5 2; -x7 4; x7 4; 0 6]

[ -2.0 0.0 2.0 0.0 -1.3333333333333333 2.0 0.0 2.0 1.3333333333333333 2.0 -0.6666666666666666 4.0 0.6666666666666666 4.0 0.0 6.0 ] (13)

โˆด 
L=[ 1 3; 3 6; 6 8; 8 7; 7 5; 5 2; 6 7; 3 4; 4 5; 6 4; 4 7]

[ 1 3 3 6 6 8 8 7 7 5 5 2 6 7 3 4 4 5 6 4 4 7 ] (14)

โˆด 
KA=assembleK(2,L,X);
โˆด 

1.5Enforcing boundary conditions

โˆ˜When structures are attached to their environment, boundary conditions have to be enforced in the linear system ๐’‡=๐‘ฒโก๐’–. A common technique is set the diagonal element of ๐‘ฒ for the node i subjected to boundary conditions to a large value B such that it effectively decouples from the system, and set fi=Bโกgi where gi is the desired boundary value.

2Track 1 and 2 common problems

  1. Construct ๐‘ฟA,๐‘ณA,๐‘ฒA (node coordinates, edges, stiffness matrix) for the โ€œAโ€ model. For this small model a sparse representation of ๐‘ฒA is not required.

  2. Start your investigation of the system by finding the n=10 largest singular values and eigenvalues of ๐‘ฒ,๐‘ฒA. Plot the first p=3 singular modes and eigenmodes.

  3. Find the linear combination ๐’” of the first n=10 singular modes that best approximates a force ๐’‡=(zโกcosโกฮธ,zโกsinโกฮธ,0) on the structure by solving the problem

    min๐’”โˆˆโ„n||๐’‡-๐‘ผ๐’”||

    Randomly choose ฮธ. This is the response of the structure to wind along direction ฮธ. Form and solve the analogous problem for the โ€œAโ€ model first.

  4. Find the linear combination ๐’” of the first n=10 eigenmodes modes that best approximates a force ๐’‡=(zโกcosโกฮธ,zโกsinโกฮธ,0) on the structures. Form and solve the analogous problem for the โ€œAโ€ model first.

  5. Replace singular modes or eigenmodes by orthogonal ๐‘ธ, with ๐‘ธโก๐‘น=[ ๐’‡ ๐‘ฒโก๐’‡ ๐‘ฒ2โก๐’‡ โ€ฆ ๐‘ฒ9โก๐’‡ ] (known as Krylov modes). Find the linear combination ๐’˜ of the first 10 Krylov modes that best approximates a force ๐’‡=(zโกcosโกฮธ,zโกsinโกฮธ,0) on the structure. Form and solve the analogous problem for the โ€œAโ€ model first.

3Track 2 task

Carry out a bibliographic search for review papers on reduced order modeling. Choose a paper you find appealing and draft a two-paragraph summary. Compare the approach you find in the literature to problems 3 to 5 above.