0% found this document useful (0 votes)
32 views4 pages

EulerBeams2DLin JL

Uploaded by

ticonzero2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views4 pages

EulerBeams2DLin JL

Uploaded by

ticonzero2010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

EulerBeams2DLin.

jl
1 module EulerBeams2DLin
2
3 # using JLD, Formatting
4 using Geometry2D
5 using Geometry2D: Segment, norm, -, +, segments2beams, fixRVE!, fragment!, xings
6
7 import Base: copy
8
9 # types
10 type BeamModel
11 nodes::Array{Float64,2}
12 beams::Vector{Vector{Int64}}
13 E::Float64
14 A::Float64
15 Iyy::Float64
16 # const nDoF = 2
17
18 BeamModel(;
19 nodes = [0.0, 1.0],
20 beams = [[1, 2]],
21 E = 70e3,
22 A = π/1.0,
23 Iyy = π/4.0) = new(nodes, beams, E, A, Iyy)
24 BeamModel(nodes::Array{Float64,2},
25 beams::Vector{Vector{Int64}};
26 E = 70e3,
27 A = π/1.0,
28 Iyy = π/4.0 ) = new(nodes, beams,
29 E, A, Iyy)
30 #
31 end
32 ## meshgrid
33 meshgrid(v::AbstractVector) = meshgrid(v, v)
34 function meshgrid(vx::AbstractVector{T}, vy::AbstractVector{T}) where T
35 m, n = length(vy), length(vx)
36 vx = reshape(vx, 1, n)
37 vy = reshape(vy, m, 1)
38 (repmat(vx, m, 1), repmat(vy, 1, n))
39 end
40 ## makeModelKt
41 function makeModelKt(model::BeamModel)
42
43 const nDoF = 3
44 const nNodes = size(model.nodes)[1]
45 const nDoFtot = nNodes*nDoF
46 Kt = zeros(Float64, nDoFtot, nDoFtot)
47 # I = Vector{Int64}(0)
48 # J = Vector{Int64}(0)
49 # V = Vector{Float64}(0)
50
51 for beam ∈ model.beams
52
53 idx = vcat(beam[1]*nDoF+[-2,-1,0],
54 beam[2]*nDoF+[-2,-1,0] )
55 beamKt = makeBeamKt(model.nodes[beam,:],
56 model.A,
57 model.Iyy,
58 model.E)
59
60 Kt[idx, idx] += beamKt
61 # (ii,jj) = meshgrid(idx)
62 # append!(I, ii)
63 # append!(J, jj)
64 # append!(V, beamKt[:])
65 end
66
67 # Kt = sparse(I, J, V, nDoFtot, nDoFtot)
68
69 return (Kt)
70 end
71 ## GetModelEngy
1
EulerBeams2DLin.jl
72 function GetModelEngy(model::BeamModel,
73 s::Vector{Float64})
74
75 GetModelEngy(model.nodes, model.beams, s,
76 E = model.E,
77 A = model.A,
78 Iyy = model.Iyy)
79 end
80 function GetModelEngy(model::BeamModel,
81 s::Array{Float64, 2})
82
83 GetModelEngy(model.nodes, model.beams, s,
84 E = model.E,
85 A = model.A,
86 Iyy = model.Iyy)
87
88 end
89 function GetModelEngy(nodes::Array{Float64, 2},
90 beams::Vector{Vector{Int64}},
91 s::Array{Float64, 2};
92 E = 70e3,
93 A = π/1.0,
94 Iyy = π/4.0)
95
96
97 const nDoFs = 3
98
99 nBeams = length(beams)
100 nNodes = size(nodes)[1]
101 nModes = size(s)[2]
102
103 str_engy = Array{Float64,2}(nBeams, nModes)
104 bnd_engy = Array{Float64,2}(nBeams, nModes)
105
106 for ii ∈ 1:nModes
107 (str_engy[:,ii],
108 bnd_engy[:,ii]) = GetModelEngy(nodes, beams, s[:,ii];
109 E = E,
110 A = A,
111 Iyy = Iyy)
112 end
113
114 return(str_engy, bnd_engy)
115 end
116 function GetModelEngy(nodes::Array{Float64, 2},
117 beams::Vector{Vector{Int64}},
118 s::Vector{Float64};
119 E = 70e3,
120 A = π/1.0,
121 Iyy = π/4.0)
122
123 # this function evaluates the banding and the stretching contribution
124 # to strain energy for each beam
125 #
126 const nDoFs = 3
127
128 nBeams = length(beams)
129 nNodes = size(nodes)[1]
130 nDoFtot = nDoFs*nNodes
131
132 str_engy = Vector{Float64}(nBeams)
133 bnd_engy = Vector{Float64}(nBeams)
134
135 # assemble the RVE unconstrained stiffness matrix
136 for (ii, beam) ∈ enumerate(beams)
137 idxii = vcat(beam[1]*nDoFs-[2, 1, 0],
138 beam[2]*nDoFs-[2, 1, 0] )
139 ∆r = nodes[beam[2], :] - nodes[beam[1], :]
140
141 (str_engy[ii],
142 bnd_engy[ii]) = getBeamEngy(∆r, s[idxii],
2
EulerBeams2DLin.jl
143 A, Iyy, E)
144 end
145
146 return(str_engy, bnd_engy)
147 end
148 ## solve!
149 function solve!(model::BeamModel,
150 s::Vector{Float64},
151 f::Vector{Float64})
152 end
153 ## makeBeamKt
154 function makeBeamKt(nodes::Array{Float64, 2},
155 A::Float64,
156 I::Float64,
157 E::Float64)
158
159 ∆r = nodes[2,:] - nodes[1,:]
160
161 makeBeamKt(∆r, A, I, E)
162 end
163 ##
164 function makeT₀L₀(∆r::Vector{Float64})
165
166 L₀ = norm(∆r)
167 T₀ = [∆r[1]/L₀ ∆r[2]/L₀ 0.0;
168 -∆r[2]/L₀ ∆r[1]/L₀ 0.0;
169 0.0 0.0 1.0];
170 (T₀, L₀)
171 end
172 ## makeBeamKt
173 function makeBeamKt(∆r::Vector{Float64},
174 A::Float64,
175 I::Float64,
176 E::Float64)
177
178 (T₀, L₀) = makeT₀L₀(∆r)
179 const idxn = [1, 4] # axial modes
180 const idxb = [2, 3, 5, 6] # bending modes
181
182 Kel = zeros(Float64, (6, 6))
183 Kel[idxn,idxn] = makeBeamKN₀(E, A, L₀)
184 Kel[idxb,idxb] = makeBeamKB₀(E, I, L₀)
185
186 # Kel = zeros(Float64, 6,6)
187 Kel[1:3,1:3] = T₀'*(Kel[1:3,1:3]*T₀)
188 Kel[4:6,1:3] = T₀'*(Kel[4:6,1:3]*T₀)
189 Kel[1:3,4:6] = T₀'*(Kel[1:3,4:6]*T₀)
190 Kel[4:6,4:6] = T₀'*(Kel[4:6,4:6]*T₀)
191
192 return(Kel)
193 end
194 function makeBeamKN₀(E::Float64, A::Float64, L₀::Float64)
195
196 KN = [1 -1;
197 -1 1]*E*A/L₀
198 end
199 function makeBeamKB₀(E::Float64, I::Float64, L₀::Float64)
200
201 KB = [12/L₀^3 6/L₀^2 -12/L₀^3 6/L₀^2;
202 6/L₀^2 4/L₀ -6/L₀^2 2/L₀;
203 -12/L₀^3 -6/L₀^2 12/L₀^3 -6/L₀^2;
204 6/L₀^2 2/L₀ -6/L₀^2 4/L₀] * E*I
205 end
206 ## getBeamEngy
207 function getBeamEngy(∆r::Vector{Float64},
208 s::Vector{Float64},
209 A::Float64,
210 I::Float64,
211 E::Float64)
212
213 const idxn = [1, 4] # axial modes
3
EulerBeams2DLin.jl
214 const idxb = [2, 3, 5, 6] # bending modes
215
216 (T₀, L₀) = makeT₀L₀(∆r)
217 s₀ = zeros(Float64, 6)
218 s₀[1:3] = T₀*s[1:3]
219 s₀[4:6] = T₀*s[4:6]
220
221 KN = makeBeamKN₀(E, A, L₀)
222 KB = makeBeamKB₀(E, I, L₀)
223
224 str_engy = s₀[idxn].'*(KN*s₀[idxn])
225 bnd_engy = s₀[idxb].'*(KB*s₀[idxb])
226
227 (str_engy, bnd_engy)
228
229 end
230 #
231 end
232 #
233

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy