-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathLinearBarElement.R
125 lines (109 loc) · 3.52 KB
/
LinearBarElement.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#' Element stiffness matrix (for a linear bar)
#'
#' This function generates the matrix for a linear bar element.
#' The axis of the bar element is assumed to coicide with the global x-axis.
#'
#' @param DOF Degree of freedom for a bar element (2 for a linear bar).
#' @param stiffbar Stiffness of the bar in the form of AE/L.
#'
#' @return The 2 by 2 stiffness matrix.
#' @export
#'
Bar_Element_Matrix=function(DOF=2,stiffbar)
{
ematrix=stiffbar*matrix(c(1,-1,-1,1),nrow=DOF,byrow=T);
return (ematrix)
}
#' Expanded stiffness matrix (for the linear bar)
#'
#' This function generates the expanded matrix for each element in a
#' connected system of bars.
#'
#' @param TDOF Total degree of freedom in a connected system of bars.
#' @param eMatrix The 2 by 2 stiffness matrix of a specific bar element.
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return The expanded matrix (conforming to the total degree of freedom of the system).
#' @export
#'
Bar_ExpandedElement_Matrix = function(TDOF,eMatrix,i,j)
{
bigMatrix = matrix(vector(l = TDOF * TDOF),nrow = TDOF,byrow = T);
bigMatrix[c(i,j),c(i,j)] = eMatrix;
return (bigMatrix)
}
#' Equivalent load vector for a UDL (bar element)
#'
#' Generates the load column matrix for an element with a
#' uniformly distributed load.
#'
#' @param DOF Degree of freedom (2 for a bar).
#' @param LoadMagnitude Magnitude of the UDL, e.g. q in N/m.
#' @param Length Length
#'
#' @return A column matrix of the equivalent nodal loads.
BarUDL_Matrix= function(DOF=2,LoadMagnitude,Length)
{
L=Length;
DistributedLoad=LoadMagnitude*
matrix(c(-L/2,-L/2),nrow=DOF,byrow=T)
return (DistributedLoad)
}
#' Expanded vector of the equivalent load
#'
#' This function generates the expanded
#' vector of the equivalent load (bar).
#'
#' @param TDOF Total degree of freedom.
#' @param LoadColumnMatrix The unexpanded vector of equivalent
#' loads.
#'
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return Expanded vector (a column matrix) of
#' equivalent loads.
#' @export
BarUDL_ExpandedMatirx = function(TDOF,LoadColumnMatrix,i,j)
{
r1=i;r2=j;
bigColumnMatrix=matrix(vector(l=TDOF),nrow=TDOF,byrow=T);
bigColumnMatrix[c(r1,r2)]=LoadColumnMatrix;
return (bigColumnMatrix)
}
#' Local element forces (linear bar)
#'
#'This function generates the local forces at the nodes of a bar element.
#'
#' @param DOF Degree of freedom.
#' @param stiffbar Stiffness of the bar in the form of AE/L.
#' @param vec_globalnodaldisp Vector of global displacements.
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return Local nodal forces (linear bar).
#' @export
#'
Bar_Element_Forces=function(DOF=2,stiffbar,vec_globalnodaldisp,i,j)
{
nodaldisplacment=vec_globalnodaldisp[c(i,j)]
stiffnessmatrix=stiffbar*matrix(c(1,-1,-1,1),nrow=DOF,byrow=T)
nodal_forces=stiffnessmatrix %*% nodaldisplacment
return(nodal_forces)
}
#' Global element forces (linear bar)
#'
#' This function generates the global forces at the nodes of a bar element.
#'
#' @param bigKmatrix Global stiffness matrix.
#' @param vec_globalnodaldisp Vector of global nodal displacements.
#'
#' @return Global nodal forces (linear bar)
#' @export
#'
Bar_Global_Forces = function(bigKmatrix,vec_globalnodaldisp)
{
global_forces = bigKmatrix %*% vec_globalnodaldisp
return(round(global_forces))
}