-
Notifications
You must be signed in to change notification settings - Fork 195
/
DynamicBarElement.R
98 lines (82 loc) · 2.64 KB
/
DynamicBarElement.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
#' Element stiffness matrix (Dynamic bar)
#'
#' This function generates the 2 by 2 stiffness matrix of a bar element.
#'
#' @param DOF Degree of freedom.
#' @param YoungMod Young's modulus.
#' @param Area Cross-sectional area
#' @param Length Length.
#'
#' @return Stiffness matrix of a dynamic bar element.
#' @export
DynamicBar_StiffnessMatrix=function(DOF=2,YoungMod,Area,Length)
{
stiffbar=YoungMod*Area/Length
ematrix=stiffbar*matrix(c(1,-1,-1,1),nrow=DOF,byrow=T);
return (ematrix)
}
#' Element mass matrix (Dynamic bar)
#'
#' This function generates the 2 by 2 consistent
#' mass matrix of a beam element.
#'
#' @param DOF Degree of freedom.
#' @param Density Material density.
#' @param Area Cross-sectional area.
#' @param Length Length.
#'
#' @return Stiffness matrix of a dynamic bar element.
#' @export
DynamicBar_MassMatrix=function(DOF=2,Density,Area,Length)
{
massmatrix=(Density*Area*Length/6)*matrix(c(2,1,1,2),nrow=DOF,byrow=T);
return (massmatrix)
}
#' Expanded element matrix (dynamic bar)
#'
#' This function returns the expanded
#' stiffness/mass matrix of a dynamic bar element.
#'
#' @param TDOF Total degree of freedom in a connected system of bars.
#' @param eMatrix The 2 by 2 stiffness or mass matrix of a
#' specific bar element.
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return The expanded matrix of a bar element.
#' @export
DynamicBar_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)
}
ReducedK=function(bigKmatrix,knownforcenodes)
{
reducedK=bigKmatrix[c(knownforcenodes),(knownforcenodes)];
return(reducedK)
}
ReducedM=function(bigMmatrix,knownforcenodes)
{
reducedM=bigMmatrix[c(knownforcenodes),(knownforcenodes)];
return(reducedM)
}
#' Natural frequencies (bar element)
#'
#' This function computes the natural frequencies, in radians per seconds.
#'
#' @param reducedM Reduced mass matrix obtained by applying
#' boundary condition on the global mass matrix
#' @param reducedK Reduced mass matrix obtained by applying
#' boundary condition on the global stiffness matrix
#'
#' @return Natural frequencies in radian/s
#' @export
DynamicBar_NaturalFrequencies=function(reducedM,reducedK)
{
massinv=solve(reducedM);
productMK=massinv%*%reducedK
syseigen=eigen(productMK)
sortedfreq=sort(syseigen$values)
return(sqrt(sortedfreq))
}