Skip to content

Commit

Permalink
Modeselection (#2)
Browse files Browse the repository at this point in the history
* Modeselection

* minor changes #1

* ensuring sparse/full eigenvalue computation in the reduced/full case.

* Commentary

Co-authored-by: gergelybuza <[email protected]>
  • Loading branch information
jain-shobhit and gergelybuza authored Sep 8, 2020
1 parent 12dc06e commit f6704e3
Show file tree
Hide file tree
Showing 30 changed files with 1,104 additions and 15 deletions.
3 changes: 2 additions & 1 deletion @SSR/DF_P.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
D = blkdiag(DSC{:});
BU = blkdiag(BU{:});
end
DF_P = speye( O.nt * O.n ) + BU * get_ConvMtx(O) * D;
DD = BU * get_ConvMtx(O) * D;
DF_P = speye( size(DD) ) + DD;
end
12 changes: 12 additions & 0 deletions @SSR/FRC.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function [om, N] = FRC(O,T_range,ncontsteps)
% function that computes the FRC of S for a given range

[om,cont_sol,~] = O.sequential_continuation(T_range,'ncontsteps',ncontsteps);

N = nan(length(om),1);
for j = 1:length(om)
if ~isempty(cont_sol{j})
N(j) = O.dt*norm(cont_sol{j},'fro');
end
end
end
53 changes: 53 additions & 0 deletions @SSR/SSM2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
function W = SSM2(O,S)
% A faster computation of the leading order term of the SSM

n = length(O.M);
m = O.n;
W = cell(1,n-m);

dim = (2*m)^2;

A = [zeros(m),eye(m);-O.K1,-O.C1]; % linear coefficient of master system
B0 = zeros(dim);

delta = eye(2*m); % kronecker delta

% assembly of the 2D equivalent to tensor B as a part of vectorizing the
% problem (first half that is independent of enslaved mode)
for i = 1:dim
for j = 1:dim
q = floor((j-1)/2/m)+1;
t = floor((i-1)/2/m)+1;
r = j - (q-1) * 2 * m;
s = i - (t-1) * 2 * m;
B0(i,j) = 2 * A(r,s) * A(q,t) +...
A(q,:) * A(:,t) * delta(r,s) +...
A(r,:) * A(:,s) * delta(q,t); % eq. (2.14) in thesis
end
end


% Computing SSM coefficient Wk for each enslaved mode
for k = 1:n-m
B1 = zeros(dim);
Sk = zeros(2*m);
Sk(1:m,1:m) = S{k}; % this is R_k, nonlinear quadratic coeffs in original eq.

% Computing second half of B
for i = 1:dim
for j = 1:dim
q = floor((j-1)/2/m)+1;
t = floor((i-1)/2/m)+1;
r = j - (q-1) * 2 * m;
s = i - (t-1) * 2 * m;
B1(i,j) = 2 * (O.zeta2(k)) * (O.omega2(k)) *...
(A(q,t) * delta(r,s) + A(r,s) * delta(q,t));
end
end

B = B0 + B1 + (O.omega2(k))^2 * eye(dim);
Wk = -B\Sk(:); % quadratic SSM coeffs in vector form
W{k} = reshape(Wk,size(Sk)); % converting SSM coeffs back to matrix form
end

end
15 changes: 15 additions & 0 deletions @SSR/SSMcomps.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function SSMcomps(O)
% computes additional material required for SSM computation
[V1, dd] = eig(full(O.K),full(O.M),'vector');
[~, ind] = sort(dd);
V1 = V1(:,ind);
V2 = V1(:,setdiff(1:length(O.M),O.mode_choice));
mu2 = diag(V2.' * O.M * V2);
U2 = V2 * diag( 1./ sqrt(mu2) );
omega2 = sqrt(diag((U2.' * O.K * U2)));
zeta2 = diag((U2.' * O.C * U2))./ (2*omega2);
O.U2store = U2;
O.omega2store = omega2;
O.zeta2store = zeta2;
O.SSMdone = 1;
end
95 changes: 81 additions & 14 deletions @SSR/SSR.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
classdef SSR < handle
%SSR Summary of this class goes here
% Detailed explanation goes here
%SSR (SteadyStateResponse) class implements the integral equations
%approach to the computation of the steady-state response in
%(quasi)periodically-forced dynamical systems.

% The theory of computation (without model reduction) is decribed in
% the following article:
%

% The theory for model reduction is described in the following article:
% G. Buza, S. Jain, G. Haller, Using Spectral Submanifolds for Optimal
% Mode Selection in Model Reduction, (2020) Preprint available on arXiv.org

properties
M % Mass matrix
Expand Down Expand Up @@ -35,6 +44,8 @@
DLvec % Derivative dLdT
Jvec % Green's function for velocities (calculated over -T:dt:T)
ConvMtx % convolution matrix for displacements
A % reformulated convolution matrix
Lint % precomputed integrals of Green's functions
isupdated % check if different quantitities are updated according to T
weights % Weights vector for higher order integration
nt % number of nodes in the time mesh
Expand All @@ -51,30 +62,80 @@
Evinv % The inverse Fourier transform exponential matrix
Ekron % The Fourier transform exponential matrix kronecker product with Identity
Einvkron % The inverseFourier transform exponential matrix kronecker product with Identity
mode_choice % Selection of modes specified by the user

% required only for the SSM computation in the mode selection
% procedure
zeta % The damping coefficients of the master modes
omega2 % The eigenfrequencies of the enslaved modes
zeta2 % The damping coefficients of the enslaved modes
K1 % Stiffness matrix of the enslaved modes (in modal coordinates)
C1 % Damping matrix of the enslaved modes (in modal coordinates)
U2 % Enslaved eigenmodes
% storage for some of these
U2store
zeta2store
omega2store
SSMdone % Boolean that ensures that the eigenvalues are only computed once
end

methods
function O = SSR(M,C,K)
function O = SSR(M,C,K,varargin)
% Basic system properties
O.M = M;
O.C = C;
O.K = K;
O.n = length(M);
O.K = K;
if nargin == 3
n = length(M);
O.mode_choice = 1:n;
[VV, dd] = eig(full(K),full(M));
else
O.mode_choice = varargin{1};
[VV, dd] = eigs(K,M,max(O.mode_choice),'SM');
end
O.n = length(O.mode_choice);

[V, ~] = eig(full(K),full(M));
dd = diag(dd);
[~, ind] = sort(dd);
VV = VV(:,ind);
V = VV(:,O.mode_choice);
mu = diag(V.' * M * V);
O.U = V * diag( 1./ sqrt(mu) ); % mass normalized VMs
O.omega0 = sqrt(diag((O.U.' * K * O.U)));
zeta = diag((O.U.' * C * O.U))./ (2*O.omega0);
O.o = find(zeta>1);
O.c = find(zeta==1);
O.u = find(zeta<1);
lambda1 = (-zeta + sqrt(zeta.^2 - 1)).* O.omega0;
lambda2 = (-zeta - sqrt(zeta.^2 - 1)).* O.omega0;
O.K1 = O.U.' * K * O.U;
O.zeta = diag((O.U.' * C * O.U))./ (2*O.omega0);
O.C1 = O.U.' * C * O.U;
O.o = find(O.zeta>1);
O.c = find(O.zeta==1);
O.u = find(O.zeta<1);
lambda1 = (-O.zeta + sqrt(O.zeta.^2 - 1)).* O.omega0;
lambda2 = (-O.zeta - sqrt(O.zeta.^2 - 1)).* O.omega0;
O.alpha = real(lambda2);
O.omega = abs(imag(lambda2));
O.beta = lambda1;
O.gamma = lambda2;
O.SSMdone = 0;
end

function U2 = get.U2(O)
if ~O.SSMdone
SSMcomps(O);
end
U2 = O.U2store;
end

function omega2 = get.omega2(O)
if ~O.SSMdone
SSMcomps(O);
end
omega2 = O.omega2store;
end

function zeta2 = get.zeta2(O)
if ~O.SSMdone
SSMcomps(O);
end
zeta2 = O.zeta2store;
end

function set.T(O,T)
Expand Down Expand Up @@ -188,7 +249,7 @@
Jvec = O.Jvec;
end
end

update_Jvec(O)

J = J(O,t,T)
Expand Down Expand Up @@ -224,7 +285,7 @@

DF_Q = DF_Q(O,x)

[x,xd] = LinearResponse(O)
[x, xd] = LinearResponse(O)

[x, xd] = Picard(O,varargin)

Expand All @@ -233,6 +294,12 @@
[x0,tol,maxiter] = parse_iteration_inputs(O,inputs)

[OMEGA, SOL, PICARD] = sequential_continuation(O,range,varargin)

W = SSM2(O,S)

[U2,omega2,zeta2] = SSMcomps(O)

[om, N] = FRC(O,T_range,ncontsteps)
end

methods(Static)
Expand Down
7 changes: 7 additions & 0 deletions examples/ModifiedShawPierrePeriodic.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
% m*x1dd + k(x1-x2) + c(x1d-x2d) + g*x1^3 = f1(t)
% m*x2dd + k(2*x2-x1) + c(2*x2d - x1d) = f2(t)

% This example is described in Section 4.1 (Figures 1,2) of the following
% article
% S. Jain, T. Breunung, G. Haller, Fast Computation of Steady-State
% Response for Nonlinear Vibrations of High-Degree-of-Freedom Systems,
% Nonlinear Dyn (2019) 97: 313. https://doi.org/10.1007/s11071-019-04971-1


clear all
clc; close all

Expand Down
7 changes: 7 additions & 0 deletions examples/ModifiedShawPierreQuasiPeriodic.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
% m*x1dd + k(x1-x2) + c(x1d-x2d) + g*x1^3 = f1(t)
% m*x2dd + k(2*x2-x1) + c(2*x2d - x1d) = f2(t)

% This example is described in Section 4.1.2 (Figure 4) of the following
% article
% S. Jain, T. Breunung, G. Haller, Fast Computation of Steady-State
% Response for Nonlinear Vibrations of High-Degree-of-Freedom Systems,
% Nonlinear Dyn (2019) 97: 313. https://doi.org/10.1007/s11071-019-04971-1


clear all
clc; close all

Expand Down
101 changes: 101 additions & 0 deletions examples/motiv_example.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
%% Mass-spring motivational example for mode selection

% This example is described in Section 4.3 (Figure 2) of the following
% article
% G. Buza, S. Jain, G. Haller, Using Spectral Submanifolds for Optimal
% Mode Selection in Model Reduction, (2020) Preprint available on arXiv.org

clear
clc
close all

%% properties
M = eye(3);
D1 = 0.01;
D2 = 0.02;
D3 = 0.08;
ome1 = 2;
ome2 = 3;
ome3 = 5;
K = diag([ome1^2 ome2^2 ome3^2]);
C = 2*diag([ome1*D1 ome2*D2 ome3*D3]);

% Nonlinearity
S = @(x)SP_nonlinearity3(x,ome1,ome2,ome3);
DS = @(x)SP_nonlinearity_derv3(x,ome1,ome2,ome3);

% Loading
A = 0.02; % loading amplitude
f0 = [1;0;0]; % loading shape
f = @(t,T)A*f0*sin(2*pi*t/T); % loading function

%% Mode selection

SS = SSR(M,C,K,1);

% SSM computation
R = cell(1,2);
R{1} = ome2^2/2;
R{2} = ome3^2/2;
W = SS.SSM2(R);
disp(['norm(W_2)=' num2str(norm(W{1})) ', norm(W_3)=' num2str(norm(W{2}))])
[~, ind] = max([norm(W{1}) norm(W{2})]);

% master mode sets considered
I_1 = [1 2]; % mode selection 1
I_2 = [1 ind+1]; % mode selection 2

%% SSR Package
SSfull = SSR(M,C,K,[1 2 3]); % full system
SSred1 = SSR(M,C,K,I_1); % reduced to I_1
SSred2 = SSR(M,C,K,I_2); % reduced to I_2
SSfull.S = S;
SSfull.DS = DS;
SSfull.f = f;
SSred1 = copyfromfull(SSred1,SSfull);
SSred2 = copyfromfull(SSred2,SSfull);

%% Sequential continuation
omega1 = min(SSfull.omega);
Omega_range = [0.7 1.3]*omega1;
T_range = 2*pi./Omega_range;
ncontsteps = 100;

[Omega_arrayf,Nf] = SSfull.FRC(T_range,ncontsteps);
[Omega_array1,N1] = SSred1.FRC(T_range,ncontsteps);
[Omega_array2,N2] = SSred2.FRC(T_range,ncontsteps);

Nlin = nan(length(Omega_arrayf),1);
for j = 1:length(Omega_arrayf)
SSfull.T = 2*pi/Omega_arrayf(j);
[x_lin, xd_lin] = SSfull.LinearResponse();
LinSol = [x_lin; xd_lin];
Nlin(j) = SSfull.dt*norm(LinSol,'fro');
end

figure(2); semilogy(Omega_arrayf,Nf,'-k','DisplayName', 'Full','linewidth',1); axis tight; grid on; hold on;
xlabel('$$\Omega$$ [rad/s]'); ylabel('$$||q||_2$$')
legend('show')
semilogy(Omega_arrayf,Nlin,'-b', 'DisplayName', 'Linear','linewidth',1);
semilogy(Omega_array1,N1,'--g', 'DisplayName', 'Reduced $$I_1$$','linewidth',2);
semilogy(Omega_array2,N2,'--r','DisplayName', 'Reduced $$I_2$$','linewidth',2);


function f = SP_nonlinearity3(x,o1,o2,o3)
f = [o1^2/2*(3*x(1)^2+x(2)^2+x(3)^2)+o2^2*x(1)*x(2)+o3^2*x(1)*x(3)+(o1^2+o2^2+o3^2)/2*x(1)*(x(1)^2+x(2)^2+x(3)^2);...
o2^2/2*(3*x(2)^2+x(1)^2+x(3)^2)+o1^2*x(1)*x(2)+o3^2*x(2)*x(3)+(o1^2+o2^2+o3^2)/2*x(2)*(x(1)^2+x(2)^2+x(3)^2);...
o3^2/2*(3*x(3)^2+x(2)^2+x(1)^2)+o2^2*x(3)*x(2)+o1^2*x(1)*x(3)+(o1^2+o2^2+o3^2)/2*x(3)*(x(1)^2+x(2)^2+x(3)^2) ];
end

function Df = SP_nonlinearity_derv3(x,o1,o2,o3)
Df = zeros(3);
Df(1,1) = 3*o1^2*x(1)+o2^2*x(2)+o3^2*x(3) + (o1^2+o2^2+o3^2)/2*(3*x(1)^2 + x(2)^2+x(3)^2);
Df(2,2) = 3*o2^2*x(2)+o1^2*x(1)+o3^2*x(3) + (o1^2+o2^2+o3^2)/2*(3*x(2)^2 + x(1)^2+x(3)^2);
Df(3,3) = (3*o3^2*x(3)+o2^2*x(2)+o1^2*x(1) + (o1^2+o2^2+o3^2)/2*(3*x(3)^2 + x(2)^2+x(1)^2));
Df(1,2) = o1^2*x(2)+o2^2*x(1)+(o1^2+o2^2+o3^2)*x(1)*x(2);
Df(1,3) = o1^2*x(3)+o3^2*x(1)+(o1^2+o2^2+o3^2)*x(1)*x(3);
Df(2,3) = o2^2*x(3)+o3^2*x(2)+(o1^2+o2^2+o3^2)*x(2)*x(3);
Df(3,2) = Df(2,3);
Df(2,1) = Df(1,2);
Df(3,1) = Df(1,3);
end
6 changes: 6 additions & 0 deletions examples/ndof_oscillator_chain/OscillatorChain.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
%% Oscillator chain with coupled nonlinearities
% This example is described in Section 4.2 (Figure 6) of the following
% article
% S. Jain, T. Breunung, G. Haller, Fast Computation of Steady-State
% Response for Nonlinear Vibrations of High-Degree-of-Freedom Systems,
% Nonlinear Dyn (2019) 97: 313. https://doi.org/10.1007/s11071-019-04971-1

clear all
clc

Expand Down
7 changes: 7 additions & 0 deletions examples/nonsmooth/NonSmoothOscillator.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
%% 2-DOF oscillator with non smooth nonlinearity
% This example is described in Section 4.1.3 (Figure 5) of the following
% article
% S. Jain, T. Breunung, G. Haller, Fast Computation of Steady-State
% Response for Nonlinear Vibrations of High-Degree-of-Freedom Systems,
% Nonlinear Dyn (2019) 97: 313. https://doi.org/10.1007/s11071-019-04971-1


clear all
clc; close all

Expand Down
Loading

0 comments on commit f6704e3

Please sign in to comment.