In [1]:
using PtFEM, Plots, DataFrames
In [2]:
l = 1.0 # Length [m]
q = 5.0 # Distributed load [N/m]
EA = 10.0 # [Ns/m];
N = 4 # Number of nodes
els = 3 # Number of elements
ell = [1/els for i in 1:els] # Length of each element;
In [3]:
struct_el = :Rod
fin_el = :Line
Out[3]:
In [4]:
?Rod
Out[4]:
In [5]:
np_types = 1 # A single property type
EA = 1.0e5 # Axial strain stiffness
nip = 1 # Numerical integration will use only a single integration point (explained in future notebooks);
In [6]:
?Line
Out[6]:
In [7]:
nod = 2 # Each line finite element has 2 nodes
nodof = 1 # Each node has a single degree of freedom (deflection in the x direction);
In [8]:
data = Dict(
:struc_el => Rod(els, np_types, nip, Line(nod, nodof)),
:properties => [EA;],
:x_coords => 0.0:l/els:l,
:support => [(N, [0])],
:loaded_nodes => [(i, repeat([0.0], inner=nodof)) for i in 1:N],
:eq_nodal_forces_and_moments => [(i, repeat([0.0], inner=nodof*nod)) for i in 1:els]
);
data[:loaded_nodes][2] = (2, [5.0])
In [9]:
for node in 1:els
data[:eq_nodal_forces_and_moments][node][2][1] = 1/2*q*l/els
data[:eq_nodal_forces_and_moments][node][2][2] = 1/2*q*l/els
end
# Add the equivalent distributed forces and moment to loaded_nodes entry
for node in 1:N-1
data[:loaded_nodes][node][2][1] += data[:eq_nodal_forces_and_moments][node][2][1]
data[:loaded_nodes][node+1][2][1] += data[:eq_nodal_forces_and_moments][node][2][2]
end
In [10]:
F = data[:loaded_nodes]
Out[10]:
In EEM: f = {F[1], F[2], F[3], F[4] + Fs[4]} # where Fs[4] is the unknown support force needed in node 4 to prevent a deflection.
In [11]:
m = FE4_1(data);
In [12]:
m.displacements
Out[12]:
In [13]:
m.actions
Out[13]:
In [14]:
dis_df = DataFrame(
x_translation = m.displacements[:, 1],
)
Out[14]:
In [15]:
fm_df = DataFrame(
normal_force_1 = m.actions[:, 1],
normal_force_2 = m.actions[:, 2],
normal_force_1_corrected = m.actions[:, 1],
normal_force_2_corrected = m.actions[:, 2]
);
In [16]:
if :eq_nodal_forces_and_moments in keys(data)
eqfm = data[:eq_nodal_forces_and_moments]
k = data[:struc_el].fin_el.nod * data[:struc_el].fin_el.nodof
for t in eqfm
for i in 1:k
fm_df[t[1], i+2] = round(fm_df[t[1], i] - t[2][i], 5)
end
end
end
fm_df
Out[16]:
In [17]:
### Plot the results
In [18]:
gr()
Out[18]:
In [19]:
x = 0.0:l/els:l;
u = dis_df[:x_translation]
N = vcat(fm_df[:normal_force_1_corrected][1], fm_df[:normal_force_2_corrected]);
In [20]:
p = Vector{Plots.Plot{Plots.GRBackend}}(2)
titles = ["EEM fig 1.1 u(x)", "EEM fig 1.1 N(x)"];
In [21]:
p[1]=plot(N, x, yflip=true, xflip=true, xlab="Normal force [N]", ylab="x [m]", color=:red,
fill=true, fillalpha=0.1, leg=false, title=titles[2])
for i in 1:els
plot!(p[1], [fm_df[:normal_force_2][i], fm_df[:normal_force_2][i]], [(i-1)*l/els, i*l/els], color=:blue)
end
In [22]:
p[2] = plot(u, x, xlim=(0.0, 0.00004), yflip=true, xlab="Displacement [m]", ylab="x [m]",
fillto=0.0, fillalpha=0.1, leg=false, title=titles[1]);
In [23]:
defl(x) = q/(2*EA).*(l^2 .- x.^2)
x1 = 0.0:0.01:l
plot!(p[2], defl(x1), x1, xlim=(0.0, 0.00004), color=:red);
In [24]:
plot(p..., layout=(1,2))
Out[24]:
In [ ]: