Page 4 - Demo
P. 4
Planar Truss Examplefor ComrelAdd-onRCPConsult, 2021-2025Page 4%% Boundary conditions% Applied loadsfc =zeros(ndof,1);fc(16:226)=P;% negative vertical forces [N]% Supports and free nodesc =[1214];% fixed dofs d =setdiff(1:ndof,c);% free dofs % Remove supports from force vectorfc(c)=[];% f = equivalent nodal force vector% q = equilibrium nodal force vector% a = displacements%| qd | | Kcc Kcd || ac | | fd |%| | = | || | | |%| qc | | Kdc Kdd || ad | | fc |%% Solve the system of equationsKcc =K(c,c);Kcd =K(c,d);Kdc =K(d,c);Kdd =K(d,d);ac =[0;0;0];% displacements for c are 0ad =Kdd\\(fc-Kdc*ac);% = linsolve(Kdd, fc-Kdc*ac)qd =Kcc*ac +Kcd*ad;%% Final displacementsa =zeros(ndof,1);q =zeros(ndof,1);a(c)=ac;q(c)=qd;a(d)=ad;% q(d) = qc = 0%% Axial loads in barsN =zeros(nfe,1);fore =1nfeN(e)=k(e)*[-1010]*T{e}*a(LM{e});end%% Return value of script (function)uout =a(8);% vertical deflection at bottom center (N04)%% VisualisationifStrurelPlot% begin of plot block%% Global variables to manage plot facilitiesglobalStrurelPlotNameStrurelPlotTypeStrurelPlotModeStrurelPlotCountStrurelPlotName='PlanarTruss_';StrurelPlotType='.png';StrurelPlotMode=3;% Internal values defined in Strurel to use in plotglobalStrurelNameStrurelModeStrurelModuleStrurelVersionStrurelEngineglobalStrurelIMETStrurelIOPTStrurelBetaStrurelPfStrurelRunswitch(StrurelMode)case{0,2}% X and Y coordinates in mXY =[00;40;80;120;160;200;240;222;182;142;102;62;22];% Deflection vectorb =reshape(a,[2,nnp])';% Forces with scale factor 0.000025fc =zeros(ndof,1);fc(16226)=P;d =reshape(fc,[2,nnp])'*0.000025;% Deformed coordinates with scale factor 2.DEF =XY +b*2;% Get screen resolutionpxl =get(0,'screensize');switch(StrurelMode)case0tit='Planar Truss -Deterministic Solution';% 0 initial deterministic solutioncase2tit='Planar Truss Stochastic Solution';% 2 final stochastic solutionend%% Create 3 plotsforf =1:3switch(f)case1% Center plot for initial and deformed statesff(1)=figure('Name',tit,'NumberTitle','off','Position',[pxl(3)/4pxl(4)/4pxl(3)/2pxl(4)/2]);figure(ff(1))holdonboxonview(2)% Plot frameaxisequalaxis([226210])gridminor% Set a main subtitle of plottext(12.0,8.0,'\\fontsize{16}\\color{blue}Initial \\color{black}and \\color{red}deformed \\color{black}states','FontSize',16,'HorizontalAlignment','center');% Plot initial and deformed states of trussfore =1:nfeplot(XY(IEN(e,:),1),XY(IEN(e,:),2),'b);% blue color for initial stateplot(DEF(IEN(e,:),1),DEF(IEN(e,:),2),'r-);% red color for deformed statex=(XY(IEN(e,1),1)+XY(IEN(e,2),1))/2;y=(XY(IEN(e,1),2)+XY(IEN(e,2),2))/2;text(x,y,strcat('R',num2str(e')),'FontSize',8);% rod number in the middle of rod lengthend