Page 4 - Demo
P. 4
Planar TrussExamplefor ComrelAdd-onRCPConsult, 2022-2025Page 41010,0000};forn (1,nfe,1);// sin and cos of the inclinationco =cos(theta[n]);si =sin(theta[n]);// coordinate transformation matrix for the bar nT =(co ~si ~0~0)(-si ~co ~0~0)(0~0~co ~si)(0~0~-si ~co);// store coordinate transformation matrix for the bar nTb[n,14,14]=T;// local stiffness matrix for the bar nKloc=ke[n]*TD;// global stiffness matrix assemblyK[LM[n,1:cols(LM)],LM[n,1:cols(LM)]]=K[LM[n,1:cols(LM)],LM[n,1:cols(LM)]]+T'*Kloc*T;endfor;//! Boundary conditions// Applied loadsfc =zeros(ndof,1);forn (1,rows(P),1);fc[14+2*n]=P[n];// negative vertical forces [N]endfor;// Supports and free nodesc ={1,2,14};// fixed dofsd =seqa(1,1,ndof);d =reshape(d,1,ndof);d =delcols(d,c);// free dofs // Remove supports from force vectorfc =delrows(fc,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 =(fc-Kdc*ac)/Kdd;// = linsolve(fc-Kdc*ac, Kdd)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 barsNEL =zeros(nfe,1);TT ={1010};forn (1,nfe,1);// get coordinate transformation matrix for the bar nT=Tb[n,1:4,1:4];NEL[n]=ke[n]*TT*T*a[LM[n,1:cols(LM)]];endfor;// Return value of script (function)uout=a[8];//! VisualizationifStrurelPlot==1;// begin of plot blockifStrurelMode==0orStrurelMode==2;librarypgraph;// X and Y coordinates in mXY ={00,40,80,120,160,200,240,222,182,142,102,62,22};//! Create 3 plotsfornf (1,3,1);// Init an graphical environment firstgraphset;ifStrurelMode==0;tit=\Deterministic Solution\// 0 Deterministic Solution_ptek=\else;tit=\Stochastic Solution\// 2 Stochastic Solution_ptek=\endif;deleteFile(_ptek);// Setup a windowbegwind;makewind(9,6.855,0,0,0);xtics(-2,26,1,1);ytics(2,10,1,1);_pmcolor={0,0,0,0,0,0,0,0,15};_pgrid={1,0};fonts(\title(tit);//! Plot a main subtitle of plot -same for all_pmsgctl={1.06.5.100103};_pmsgstr=StrurelName$+\$+\draw;ifStrurelMode==0;// Input data at state of mean values_pmsgctl={-1.06.0.100103};_pmsgstr=\draw;else;// Input data at beta-point_pmsgctl={1.06.0.100103};_pmsgstr=StrurelIMET$+\draw;_pmsgctl={1.05.5.100101};_pmsgstr=sprintf(\StrurelBeta,StrurelPf);draw;endif;// Plot values of input data_pmsgctl={20.06.5.080101};_pmsgstr=sprintf(\A1);draw;_pmsgctl={20.06.1.080101};_pmsgstr=sprintf(\A2);draw;_pmsgctl={20.05.7.080101};_pmsgstr=sprintf(\E1);draw;_pmsgctl={20.05.3.080101};_pmsgstr=sprintf(\E2);draw;ifnf ==1;//! Initial and deformed states