Topic: | Math@UNC environment |
Post date: | May 25, 2020 |
Due date: | May 28, 2020 |
Many systems consist of point interactions. The iconic Eiffel Tower can be modeled through the trusses linking two points with coordinates . The unit vector along direction from point to point is
Suppose that structure deformation changes the coordinates to , . The most important structural response is that on point a force is exerted that can be approximated as
in appropriate physical units. An opposite force acts on point . Note the projector along the truss direction . Adding forces on a point from all trusses leads to the linear relation
(1) |
with , , the number of dimensions, the number of points, and , the number of degrees of freedom of the structure. 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 equally applicable to physical chemistry, sociology, biology or business management.
|
|||
Load the Eiffel Tower data.
octave] |
cd /home/student/courses/MATH547ML/data/EiffelTower; load EiffelPoints; X=Expression1; [NX,ndims]=size(X); load EiffelLines; L=Expression1; [NL,nseg]=size(L); |
octave] |
m=3*NX; disp([NX NX^2 NL m]) |
26464 700343296 31463 79392
octave] |
Of the possible linkages between points in the structure, only are present. It is wasteful, and often impossible, to store the entire matrix of couplings between points (), but storing only the nonzero elements corresponding to the interacting can be carried out through a sparse matrix. After allocating space with spalloc, the matrix is initialized with zeros along the truss directions.
octave] |
K=spalloc(m,m,3*NL); for k=1:NL i = L(k,1); j = L(k,2); p = 3*(i-1)+1; q = 3*(j-1)+1; for id=1:3 for jd=1:3 K(i+id,j+jd) = 0; end; end; end |
octave] |
The matrix can be formed by loops over the trusses. The following computation takes a few minutes. The matrix has been pre-computed, and can be loaded from a disk file when answering the questions below, rather than executing the following loops.
octave] |
for k=1:NL i = L(k,1); j = L(k,2); lij = (X(j,:)-X(i,:))'; Pij = lij*lij'; p = 3*(i-1)+1; q = 3*(j-1)+1; for id=1:3 for jd=1:3 K(i+id,j+jd) = K(i+id,j+jd) + Pij(id,jd); end; end; end |
octave] |
save "K.mat" K |
octave] |
Provide a proof or counter-example for these true or false questions.
If is an upper-triangular matrix, its singular values are the same as the diagonal values .
octave] |
R=[1 1;0 1] |
R =
1 1
0 1
octave] |
svd(R) |
ans =
1.61803
0.61803
octave] |
If , the singular values of are the same as its eigenvalues.
octave] |
A=[1 0;0 -1] |
A =
1 0
0 -1
octave] |
[svd(A) eig(A)] |
ans =
1 -1
1 1
octave] |
If is of full rank, and have the same singular values.
octave] |
A=[1 2;0 1]; T=[0 2; 1 0]; T1=inv(T); B=T1*A*T; disp([A B]) |
1 2 1 0
0 1 1 1
octave] |
[svd(A) svd(B)] |
ans =
2.41421 1.61803
0.41421 0.61803
octave] |
For , the matrices and have the same eigenvalues.
Set , and obtain
the same eigenvalue as for .
Load data, and define functions to draw the deformed structure.
octave] |
cd /home/student/courses/MATH547ML/data/EiffelTower; load EiffelPoints; X=Expression1; [NX,ndims]=size(X); load EiffelLines; L=Expression1; [NL,nseg]=size(L); m=3*NX; load K; |
octave] |
function drawXu(X,u,L,is) clf; view(-30,45); [NX,nd]=size(X); [nL,nseg]=size(L); x=[]; y=[]; z=[]; U=reshape(u,3,NX)'; for k=1:is:nL x=[x X(L(k,1),1)+U(L(k,1),1) X(L(k,2),1)+U(L(k,2),1)]; y=[y X(L(k,1),2)+U(L(k,1),2) X(L(k,2),2)+U(L(k,2),2)]; z=[z X(L(k,1),3)+U(L(k,1),3) X(L(k,2),3)+U(L(k,2),3)]; end; plot3(x,y,z); end |
octave] |
drawXu(X,zeros(m,1),L,20) |
octave] |
function drawXU(X,U,L,is) clf; view(-30,45); [NX,nd]=size(X); [nL,nseg]=size(L); x=[]; y=[]; z=[]; for k=1:is:nL x=[x X(L(k,1),1)+U(L(k,1),1) X(L(k,2),1)+U(L(k,2),1)]; y=[y X(L(k,1),2)+U(L(k,1),2) X(L(k,2),2)+U(L(k,2),2)]; z=[z X(L(k,1),3)+U(L(k,1),3) X(L(k,2),3)+U(L(k,2),3)]; end; plot3(x,y,z); end |
octave] |
drawXU(X,zeros(NX,3),L,20) |
octave] |
The following questions only require a few Octave lines to solve correctly. Be careful to not request output of the large vectors and matrices that arise. Use visualization with the draw function to represent results, and concentrate on the mathematical formulation. For example, imposing displacement at each node, i.e., a horizontal displacement along the direction proportional to the coordinate is accomplished by:
octave] |
U=zeros(NX,3); U(1:NX,1)=X(1:NX,3); |
octave] |
drawXU(X,U,L,20) |
octave] |
Find the linear combination of the first 10 singular modes that best approximates a force on the structure. Randomly choose . Show the first 3 singular modes and the linear combination you find.
octave] |
theta=rand()*2*pi; F=zeros(NX,3); F(1:NX,1)=X(1:NX,3)*cos(theta); F(1:NX,2)=X(1:NX,3)*sin(theta); f=reshape(F',m,1); nN=2000; i0=3*(nN-1); disp([F(nN,:)]) |
-18.53273 49.60776 0.00000
octave] |
From the singular value decomposition , denote by the matrices formed by the first columns of . The matrix is a basis for the codomain, and the matrix is a basis for the domain of the linear mapping represented by the matrix . The matrices are therefore bases for subspaces within the codomain, domain, respectively. From the full model , obtain a reduced model
with the reduced system matrix defined by
(Note: choosing the same reduced basis for approximation, e.g., , of both forces and displacements is acceptable but not optimal)
Solution of the reduced model gives an approximation of the solution to the full model
If given a force on the full model, the approximation of the force on the reduced model is obtained as the solution of the least squares problem
Since has normalized, orthogonal columns, the solution to the least squares problem is . Carry out the above steps, through the following five Octave instructions.
octave] |
[Yk,Sigmak,Zk]=svds(K,10); |
octave] |
y=Yk'*f; R=Yk'*K*Zk; x=R\y; s=Zk*x; |
octave] |
Display the requested singular vectors and the approximate solution obtained from the reduced model. The displacements can be scaled to obtain a more comprehensible visualization.
octave] |
cd /home/student/courses/MATH547ML/homework; mkdir hw04; cd hw04 |
octave] |
figure(1); drawXu(X,0*Zk(:,1),L,20); print -depsc Fig1a.eps; figure(2); |
octave] |
drawXu(X,250*Zk(:,1),L,20); print -depsc Fig1b.eps |
octave] |
drawXu(X,250*Zk(:,2),L,20); print -depsc Fig1c.eps |
octave] |
drawXu(X,250*Zk(:,3),L,20); print -depsc Fig1d.eps |
octave] |
drawXu(X,5000*s,L,20); print -depsc Fig1e.eps |
octave] |
Find the linear combination of the first 10 eigenmodes that best approximates a force on the structure. Show the first 3 eigenmodes and the linear combination you find.
octave] |
[Vk,Lambdak]=eigs(K,10); [Rk,Tk]=qr(Vk,0); |
octave] |
y=Rk'*f; R=Rk'*K*Rk; x=R\y; t=Rk*x; |
octave] |
Display the requested eigenvectors and the approximate solution obtained from the reduced model. Again, the displacements are scaled to obtain a more comprehensible visualization.
octave] |
cd /home/student/courses/MATH547ML/homework; mkdir hw04; cd hw04 |
octave] |
figure(1); drawXu(X,0*Rk(:,1),L,20); print -depsc Fig2a.eps; figure(2); |
octave] |
drawXu(X,250*Rk(:,1),L,20); print -depsc Fig2b.eps |
octave] |
drawXu(X,250*Rk(:,2),L,20); print -depsc Fig2c.eps |
octave] |
drawXu(X,250*Rk(:,3),L,20); print -depsc Fig2d.eps |
octave] |
drawXu(X,5000*t,L,20); print -depsc Fig2e.eps |
octave] |
|
||||||||
Figure 3. Representation of deformation of the
Eiffel Tower. Top row contains first 3 eigenvectors, again showing
“squeezing” of the structure along different spatial
directions, and the approximation given by the reduced model
solution for a force . Note that the eigenmode reduced
solution is very different from that obtained from the singular
vector model reduction.
|
Replace singular modes or eigenmodes by orthogonal , with (known as Krylov modes). Find the linear combination of the first 10 Krylov modes that best approximates a force on the structure. Show the first 3 Krylov modes and the linear combination you find.
octave] |
k=10; Kk = [f]; for i=2:k Kk = [Kk K*Kk(:,i-1)]; end; [Wk,Tk]=qr(Kk,0); |
octave] |
y=Wk'*f; R=Wk'*K*Wk; x=R\y; w=Wk*x; |
octave] |
Display the requested eigenvectors and the approximate solution obtained from the reduced model. Again, the displacements are scaled to obtain a more comprehensible visualization.
octave] |
cd /home/student/courses/MATH547ML/homework; mkdir hw04; cd hw04 |
octave] |
figure(1); drawXu(X,0*Wk(:,1),L,20); print -depsc Fig3a.eps; figure(2); |
octave] |
drawXu(X,250*Wk(:,1),L,20); print -depsc Fig3b.eps |
octave] |
drawXu(X,250*Wk(:,2),L,20); print -depsc Fig3c.eps |
octave] |
drawXu(X,250*Wk(:,3),L,20); print -depsc Fig3d.eps |
octave] |
drawXu(X,250*w,L,20); print -depsc Fig3e.eps |
octave] |
|
||||||||
Figure 4. Representation of deformation of the
Eiffel Tower. Top row contains first 3 Krylov modes, and the
approximation given by the reduced model solution for a force
. Note that the Krylov reduced
solution does not seem realistic.
|
|
|||||||||
Figure 5. Comparison of the first 3 singular
modes (top row), eigenmodes (middle row), Krylov modes (bottom
row).
|
From the SVD construct an approximate matrix
and compare the force with , from question 1.3.1.
with .
octave] |
c=diag(Sigmak).*Zk'*s; |
octave] |
ftilde=Yk*c; |
octave] |
norm(f-ftilde)/norm(f) |
ans = 0.99999
octave] |
From the eigendecomposition construct an approximate matrix
and compare the force with , from question 1.3.2.
with .
octave] |
d=diag(Lambdak).*Rk'*t; |
octave] |
ftilde=Rk*d; |
octave] |
norm(f-ftilde)/norm(f) |
ans = 0.99997
octave] |
Choose one of the reduced models from 1.3.1 to 1.3.4. Repeat the calculations for 15,20,25 modes, and comment on whether the solutions converge.
octave] |
function ferr=SVDreduced(K,f,k) [Yk,Sigmak,Zk]=svds(K,k); y=Yk'*f; R=Yk'*K*Zk; x=R\y; s=Zk*x; c=diag(Sigmak).*Zk'*s; ftilde=Yk*c; ferr=norm(f-ftilde)/norm(f); end |
octave] |
ferr10=SVDreduced(K,f,10); |
octave] |
ferr15=SVDreduced(K,f,15); |
octave] |
ferr20=SVDreduced(K,f,20); |
octave] |
ferr25=SVDreduced(K,f,25); |
octave] |
disp([ferr10 ferr15 ferr20 ferr25]) |
0.99999 0.99997 0.99996 0.99995
octave] |
Notice that the relative error
is decreasing, albeit slowly. Computation of a larger number of singular values (takes a few minutes to complete) leads to a plot from that indicates
octave] |
sig=svds(K,100); |
octave] |
plot(log10(sig),'o'); print -depsc Fig6a.eps |
octave] |
SVDreduced(K,f,40) |
ans = 0.99992
octave] |