R Codes for an Assemblage of Bars in 3D space

##Example 2.1, (pp 95-98 of Logan , the static analysis of a 3D truss)

Objective: To perform the static analysis of the above space truss. The space truss is endowed with 3 members and 4 nodes. The coordinate of each node (1-4) is contained in the n-tuple placed beside it.

AE1=0.302*1.2*10^6;AE2=0.729*1.2*10^6;AE3=0.187*1.2*10^6;
Sub_stiffness_Matrix1=Sub_stiffness_Matrix(AE1,c(72,0,0),c(0,36,0));
Sub_stiffness_Matrix2=Sub_stiffness_Matrix(AE2,c(72,0,0),c(0,36,72));
Sub_stiffness_Matrix3=Sub_stiffness_Matrix(AE3,c(72,0,0),c(0,0,-48));
Elem1_Stiffness_Matrix=Element_Matrix_Space_Bar(Sub_stiffness_Matrix1);
Elem2_Stiffness_Matrix=Element_Matrix_Space_Bar(Sub_stiffness_Matrix2);
Elem3_Stiffness_Matrix=Element_Matrix_Space_Bar(Sub_stiffness_Matrix3);
Elem1_Expanded=Expanded_Element_Matrix_Inc(12,Elem1_Stiffness_Matrix,1,2);
Elem2_Expanded=Expanded_Element_Matrix_Inc(12,Elem2_Stiffness_Matrix,1,3);
Elem3_Expanded=Expanded_Element_Matrix_Inc(12,Elem3_Stiffness_Matrix,1,4);
Global_Stiffness=Elem1_Expanded+Elem2_Expanded+Elem3_Expanded;Global_Stiffness
ReducedK=Global_Stiffness[c(1,3),c(1,3)];ReducedK
ReducedForce=matrix(c(0,-1000),ncol=1,byrow=F);
disp_of_nodes_1x1z=(solve(ReducedK,ReducedForce));disp_of_nodes_1x1z
Global_disp=c(disp_of_nodes_1x1z[1],disp_of_nodes_1x1z[2],rep(0,7));Global_disp
Elem1_disp=c(disp_of_nodes_1x1z[1],0,disp_of_nodes_1x1z[2],rep(0,3));Elem1_disp
Elem2_disp=c(disp_of_nodes_1x1z[1],0,disp_of_nodes_1x1z[2],rep(0,3));Elem2_disp
Elem3_disp=c(disp_of_nodes_1x1z[1],0,disp_of_nodes_1x1z[2],rep(0,3));Elem3_disp
Axial_Stress1=Axial_Stress_3D(1.2*10^6,c(72,0,0),c(0,36,0),Elem1_disp);
Axial_Stress2=Axial_Stress_3D(1.2*10^6,c(72,0,0),c(0,36,72),Elem2_disp);
Axial_Stress3=Axial_Stress_3D(1.2*10^6,c(72,0,0),c(0,0,-48),Elem3_disp);
tuple_of_stress=cbind(c(Axial_Stress1,Axial_Stress2,Axial_Stress3));tuple_of_stress

Comments

The code above relies on a series of subroutines (not uploaded for brevity sake). The above lines of code yield the unknown displacements (in inches) through the variable disp_of_nodes_1x1z as:

[1,] -0.07111436; [2,] -0.26623909.

The stresses (of unit psi) in elements 1-3 are found respectively as:

[1,] -948.1914; [2,] 1445.3684; [3,] -2868.5433.

The stresses are gotten through the variable tuple_of_stress.