-
Notifications
You must be signed in to change notification settings - Fork 195
/
ThermalBarElement.R
152 lines (134 loc) · 4.78 KB
/
ThermalBarElement.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#' Element stiffness matrix (Bar element for thermal analysis)
#'
#' This function generates the 2 by 2 stiffness matrix for
#' a thermal analysis involving bar elements.
#'
#' @param DOF Degree of freedom.
#' @param stiffbar Young's modulus.
#'
#' @return Stiffness matrix of a thermal bar element.
#' @export
ThermalBar_Element_Matrix=function(DOF=2,stiffbar)
{
ematrix=stiffbar*matrix(c(1,-1,-1,1),nrow=DOF,byrow=T);
return (ematrix)
}
#' Thermal body force (thermal bar element)
#'
#' This function generates a vector of body force
#' for a bar element in a thermal analysis.
#'
#' @param DOF Degree of freedom.
#' @param YoungMod Young's modulus.
#' @param area Cross section area of a bar element.
#' @param alpha Thermal conductivity.
#' @param tempchange Temperature change.
#'
#' @return A vector of thermal body force for a bar element.
#' @export
ThermalBar_BF= function(DOF=2,YoungMod,area,alpha,tempchange)
{
nodalthermal=area*alpha*tempchange*YoungMod
equivalentbodyload=matrix(c(-nodalthermal,nodalthermal),nrow=DOF,byrow=T)
return (equivalentbodyload)
}
#' Expanded vector of thermal body force (thermal bar element)
#'
#' This function generates the expanded vector of body force
#' for a bar element in a thermal analysis.
#'
#' @param TDOF Total degree of freedom in a connected system of bars.
#' @param LoadColumnMatrix Vector of body force returned by ThermalBar_BF()
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return The expanded vector of a bar element.
#' @export
#'
ThermalBar_ExpandedBF = function(TDOF,LoadColumnMatrix,i,j)
{
bigColumnMatrix=matrix(vector(l=TDOF),nrow=TDOF,byrow=T);
bigColumnMatrix[c(i,j)]=LoadColumnMatrix;
return (bigColumnMatrix)
}
#' Expanded stiffness matrix (thermal bar element)
#'
#' This function generates the expanded stiffness matrix
#' for a bar element.
#'
#' @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 stiffness matrix of a
#' thermal bar element.
#' @export
ThermalBar_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)
}
#' Local nodal forces (thermal bar element)
#'
#' This function generates the nodal forces for a bar element
#' in a thermal analysis.
#'
#' @param DOF Degree of freedom.
#' @param stiffbar Stiffness of a bar element.
#' @param nodaldisp Element nodal displacement
#'
#' @return A vector of the nodal forces for
#' a bar element in a thermal analysis.
#' @export
#'
ThermalBar_Element_Forces=function(DOF=2,stiffbar,nodaldisp)
{
stiffnessmatrix=stiffbar*matrix(c(1,-1,-1,1),nrow=DOF,byrow=T)
nodal_forces=stiffnessmatrix %*% matrix(nodaldisp,ncol=1)
return(nodal_forces)
}
#' Global nodal forces (thermal bar element)
#'
#' This function generates the global nodal forces for a bar element
#' in a thermal analysis.
#'
#' @param bigKmatrix Global stiffness matrix.
#' @param vec_globalnodaldisp Vector of all global nodal displacements.
#'
#' @return Vector of global nodal forces
#' (thermal bar element).
#' @export
#'
ThermalBar_Global_Forces = function(bigKmatrix,vec_globalnodaldisp)
{
global_forces = bigKmatrix %*% vec_globalnodaldisp
return(round(global_forces))
}
#' Axial Stress (thermal bar element)
#'
#' This function generates the axial stress in a bar element
#' in a thermal analysis.
#'
#' @param YoungMod Young's modulus.
#' @param alpha Thermal conductivity.
#' @param tempchange Temperature change.
#' @param Length Length of a bar element.
#' @param vec_globalnodaldisp Vector of all global nodal displacements.
#' @param i Index of the first node.
#' @param j Index of the second node.
#'
#' @return A vector of thermal stress in a bar element.
#' @export
ThermalBar_Stresses = function(YoungMod,alpha,tempchange,Length,vec_globalnodaldisp,i,j)
{
r1=i; r2=j
BMatrix=matrix(c(-1/Length,1/Length),nrow=1,byrow=T);
localstresses=(YoungMod%*%BMatrix%*%vec_globalnodaldisp[c(r1,r2)])-(YoungMod*alpha*tempchange)
return(localstresses)
}