Page 4 - Demo
P. 4
Planar Truss Example for Comrel Add-on RCP Consult, 2022-2025 Page 4fc(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);for e = 1:nfe N(e) = k(e)*[-1 0 1 0]*T{e}*a(LM{e});end// Return value of script (function)lsfval = a(8); // vertical deflection at bottom center (N04)//! Visualizationif StrurelPlot then // begin of plot block if(StrurelMode == 0 || StrurelMode == 2) then // X and Y coordinates in m XY = [0 0; 4 0; 8 0; 12 0; 16 0; 20 0; 24 0; 22 2; 18 2; 14 2; 10 2; 6 2; 2 2]; // deflection vector b=matrix(a,[2,nnp])'; // forces with scale factor 0.0005 fc = zeros(ndof,1); fc(16:2:26) = P; d=matrix(fc,[2,nnp])'*0.00005; // deformed coordinates with scale factor 2. DEF = XY + b*2 // resolution of screen pxl = get(0, \_px\ select StrurelMode case int32(0) tit='Planar Truss - Deterministic Solution'; // 0 - initial deterministic solution nf=0; case int32(2) tit='Planar Truss - Stochastic Solution'; // 2 - final stochastic solution nf=1; end //! Create 3 plots for f = 1:3 nf=f+nf; switch(f) case 1 // plot for initial and deformed states scf(nf); figure(nf,'Name',tit,'position',[pxl(3)/4 pxl(4)/4 pxl(3)/2 pxl(4)/2]); // plot frame replot([-2 -2 26 10]); mtlb_axis('equal'); xgrid(2); // set a main subtitle of plot xstring(8.0,8.0,'$\\textcolor{blue}{Initial}\\textcolor{black}\\,and\\,\\textcolor{red}{deformed}\\textcolor{black}\\,{states}