clear; close all; %{ This code is intended for research purposes. Evangelia Nicolaidou, e.nicolaidou@bristol.ac.uk 2020-10-16 %} %% Load data & pre-processing model_no = 1; modes_ROM = [1,2]; Fs_max = [45,270]; main_dir = fullfile(pwd,sprintf('model %i',model_no)); load(fullfile(main_dir,'static data',['SD_AMF_modes=',sprintf('%i,',modes_ROM),'_Fs=',sprintf('%i,',Fs_max),'_allPerms.mat']),... 'Fs_all','qN_cell','FR_cell','xN_cell','N','NR','L','x_eq','N_inc','Phi','Lam','R_mat') FR_all = cell2mat(FR_cell); qN_all = cell2mat(qN_cell); xN_all = cell2mat(xN_cell); [~,i_el] = max(x_eq); % index of end element i_node = (i_el-1)*6 + 2; % y-coordinate of end element lam = diag(Lam); %% Compute ROM coefficients (ICE and ICE-IC) N_ROM = 3; % order of ROM [f_nl,~,~,r_sym,~,g_exp,L_exp,f_coexp,g,G_sym,b_sym] = generate_ROM(NR,1,N_ROM); % set up different ROMs (different force scaling factors) perc_all = 34:2:100; % force scaling factor for each ROM as a percentage of the maximum values N_perc = length(perc_all); % number of different ROMs b_all = cell(N_perc,1); % to store Lagrangian coefficients for each ROMs G_all = cell(N_perc,1); % to store quasi-static coupling coefficients for each ROMs FR_data = cell(N_perc,1); % to store static data used for each ROM, reduced forcing qN_data = cell(N_perc,1); % to store static data used for each ROM, displacement for perc_ind = 1:N_perc perc_temp = perc_all(perc_ind); % choose load cases n_loads = ceil(size(L_exp,1)/L); % number of loads needed FROM EACH STATIC ANALYSIS ind_temp = linspace(0,N_inc*perc_temp/100,n_loads+1); ind_temp = round(ind_temp(2:end)); FR_temp = []; qN_temp = []; for i = 1:L FR_temp = [FR_temp, FR_cell{i}(:,ind_temp)]; qN_temp = [qN_temp, qN_cell{i}(:,ind_temp)]; end % format static data for fitting sf = 5000; % displacement scaling factor (used just for fitting purposes) r = qN_temp(modes_ROM,:).'; % reduced displacement data u = qN_temp.'; % unmodelled displacement data c = FR_temp.' - lam(modes_ROM).'.*r; c = c(:); % reduced nonlinear forcing data % fit standard ROM coefficients Ai = cell(NR,1); for i = 1:NR exp_temp = permute(f_coexp{i}(:,2:end),[3,2,1]); % exponents (permuted) prods_temp = permute(prod(bsxfun(@power,r*sf,exp_temp),2),[1,3,2]); % products of qr^exp Ai{i} = bsxfun(@times,f_coexp{i}(:,1).',prods_temp); % nonlinear forcing terms end A = vertcat(Ai{:}); b = A\c; b = b.*sf.^(sum(L_exp,2)-1); % re-scale coefficients % fit g coefficients (quasi-static coupling functions) exp_temp = permute(g_exp,[3,2,1]); % exponents (permuted) A = permute(prod(bsxfun(@power,r,exp_temp),2),[1,3,2]); G = A\u; % N.B. no need to re-scale coefficients since both r and u were scale above % store data b_all{perc_ind} = b; G_all{perc_ind} = G; FR_data{perc_ind} = FR_temp; qN_data{perc_ind} = qN_temp; end return %% Save fd = fullfile(main_dir,'ROM data',['modes=',sprintf('%i,',modes_ROM),'_Fs=',sprintf('%i,',Fs_max)],sprintf('N=%i',N_ROM)); mkdir(fd); save([fd,'\RD.mat']);