CS计算机代考程序代写 python Advanced Structural Analysis and Dynamics 5 – ENG5274
Advanced Structural Analysis and Dynamics 5 – ENG5274
Course Work 1 – Euler–Bernoulli Beam Theory February 10 2021 Andrew McBride
Overview
In this report, you will develop and validate a nite element code written in Python for solving Euler–Bernoulli beam theory. The code will extend the one you developed for a linear elastic bar in 1D.
The report is to be uploaded to Moodle by 8 March 2020 (by 15:00).
Submission requirements
Report
The main report document should clearly and logically address all the tasks. Marks will be deducted for poor presentation. The report is to be submitted on-line via Moodle – hard-copies will not be marked.
You are to write the report in the Jupyter Notebook format (IPython) using Markdown for the written report. You can use Google Colab, Jupyter Notebook or your favourite IPython le editor.
For more information on Markdown see https://guides.github.com/pdfs/markdown-cheatsheet- online.pdf. You need to submit:
the main_EB.ipynb containing the write up and code. No other documents will be accepted. Code
Your code needs to be commented and documented.
You must include the validation examples in your submission.
Primary functions
import numpy as np
import matplotlib.pyplot as plt
import math
Primary functions to compute the element stiffness matrix , the element force vector due to distributed loading and the local to global degree of freedom map.
Validation problems
Consider a 12 m beam with Nm. Ensure that your code is indeed producing the correct results by comparing the computed de ection and possibly rotation with the analytical solution for the following loading conditions:
1. An end-loaded cantilever beam with point load of N acting at m. The beam is fully xed at . Compare the computed tip de ection and rotation with the analytical solution.
2. A cantilever beam with a distributed load of N/m acting over the length of the beam. The beam is fully xed at . Compare the computed tip de ection and rotation with the analytical solution.
3. An off-center-loaded simple beam with a point load of N acting at m. De ections are 0 at and . Ensure that the load acts at a node. You only need
def get_Ke(le, EIe):
”’Return element stiffness matrix
Parameters
———-
le : double
Length of element
EIe : double
Product of Young’s modulus and moment of inertia
”’
return
def get_fe_omega(le, fe):
”’Return force vector due to distributed loading
Parameters
———-
le : double
Length of element
fe : double
Average distributed load on element
”’
return
def get_dof_index(e):
”’Return the global dof associated with an element
Parameters
———-
e : int
Element ID
”’
return
3 = 𝑥
01− = 𝑃
21 = 𝑥
01− = 𝑃
𝑒𝐊
𝑒Ω𝐟
0=𝑥 1− = 𝑓
𝐿=𝑥 0=𝑥
4𝑒1 = 𝐼𝐸
0=𝑥
to compare your solution to the analytical solution for the position of, and de ection at, the
point of maximum displacement.
4. A uniformly-loaded simple beam with a distributed load of N/m acting over the
length of the beam. De ections are 0 at and . You only need to compare the de ection along the length of the beam to the analytical solution.
Where possible, you should test your code for one element and for multiple elements.
Consult https://en.wikipedia.org/wiki/De ection_(engineering) for analytical solutions and descriptions of the loading.
Validation – Cantilever with point load
# properties of EB theory
dof_per_node = 2
# domain data
L = 12.
# material and load data
P = -10.
P_x = L
f_e = 0.
EI = 1e4
# mesh data
n_el = 1
n_np = n_el + 1
n_dof = n_np * dof_per_node
x = np.linspace(0, L, n_np)
le = L / n_el
K = np.zeros((n_dof, n_dof))
f = np.zeros((n_dof, 1))
for ee in range(n_el):
dof_index = get_dof_index(ee)
K[np.ix_(dof_index, dof_index)] += get_Ke(le, EI)
f[np.ix_(dof_index)] += get_fe_omega(le, f_e)
node_P = np.where(x == P_x)[0][0]
f[2*node_P] += P
free_dof = np.arange(2,n_dof)
K_free = K[np.ix_(free_dof, free_dof)]
f_free = f[np.ix_(free_dof)]
# solve the linear system
w_free = np.linalg.solve(K_free,f_free)
w = np.zeros((n_dof, 1))
w[2:] = w free
𝐿=𝑥 0=𝑥 1− = 𝑓
[]_
Validation – Cantilever with distributed load
# reaction force
rw = K[0,:].dot(w) – f[0]
rtheta = K[1,:].dot(w) – f[1]
# analytical solution
w_analytical = (P * L**3) / (3*EI)
theta_analytical = (P * L**2) / (2*EI)
print(‘Validation: cantilever with tip load’)
print(‘————————————‘)
print(‘Reaction force: ‘, rw, ‘ Reaction moment: ‘, rtheta)
print(‘Computed tip deflection: ‘, w[-2], ‘ Analytical tip deflection: ‘, w_analy
print(‘Computed tip rotation: ‘, w[-1], ‘ Analytical tip rotation: ‘, theta_analy
plt.plot(x,w[0::2],’k-*’)
plt.xlabel(‘position (x)’)
plt.ylabel(‘deflection (w)’)
plt.show()
plt.plot(x,w[1::2],’k-*’)
plt.xlabel(‘position (x)’)
plt.ylabel(‘rotation (w)’)
plt.show()
# material and load data
P = 0.
f_e = -1.
# mesh data
n_el = 10
n_np = n_el + 1
n_dof = n_np * dof_per_node
x = np.linspace(0, L, n_np)
le = L / n_el
K = np.zeros((n_dof, n_dof))
f = np.zeros((n_dof, 1))
for ee in range(n_el):
dof_index = get_dof_index(ee)
K[np.ix_(dof_index, dof_index)] += get_Ke(le, EI)
f[np.ix_(dof_index)] += get_fe_omega(le, f_e)
free_dof = np.arange(2,n_dof)
K_free = K[np.ix_(free_dof, free_dof)]
f_free = f[np.ix_(free_dof)]
# solve the linear system
w_free = np.linalg.solve(K_free,f_free)
(( df 1))
Validation – Off-center-loaded simple beam
Validation – Simple beam with distributed loading
Problem A: Beam structure with linear loading
w = np.zeros((n_dof, 1))
w[2:] = w_free
# reaction force
rw = K[0,:].dot(w) – f[0]
rtheta = K[1,:].dot(w) – f[1]
# analytical solution
w_analytical = (f_e * L**4) / (8*EI)
theta_analytical = (f_e * L**3) / (6*EI)
print(‘Validation: cantilever with uniformly distributed load’)
print(‘——————————————————‘)
print(‘Reaction force: ‘, rw, ‘ Reaction moment: ‘, rtheta)
print(‘Computed tip deflection: ‘, w[-2], ‘ Analytical tip deflection: ‘, w_analy
print(‘Computed tip rotation: ‘, w[-1], ‘ Analytical tip rotation: ‘, theta_analy
plt.plot(x,w[0::2],’k-*’)
plt.xlabel(‘position (x)’)
plt.ylabel(‘deflection (w)’)
plt.show()
plt.plot(x,w[1::2],’k-*’) plt.xlabel(‘position (x)’)i plt.ylabel(‘rotation (w)’) plt.show()
# material and load data
# material and load data
P = 0.
P_x = 3.
f_e = -1.
EI = 1e4
#
Now consider the distributed load of
N act at
comprised of a traction . The product
m beam shown below. The beam is fully xed at point A N/m acts between points A and B. Point loads
. A N and
Assumptions
m and
m, respectively. Natural boundary conditions are
N and a moment Nm both acting at point C Nm .
The code you develop for this problem should assume that the number of elements is a multiple of 3. This will ensure that the point loads are applied directly at a node (why is this important?).
Outputs
Use your validated code to:
Determine the reaction force and moment at point A (for 12 elements). Use these to con rm that your output is correct.
Plot the de ection over the length of the beam (for 12 elements).
Plot the rotation over the length of the beam (for 12 elements).
Plot the bending moment over the length of the beam (for 12 elements).
Problem B: Beam structure with nonlinear loading Problem B is identical to that considered in Problem A but the distributed load is given by
Furthermore, the material properties are no longer constant and
For meshes of elements, generate plots of
de ection (at m) versus the number of degrees of freedom.
versus the number of degrees of freedom.
01− = 1𝑃 )0 = 𝑥(
1− = )𝑥(𝑓 21 = 𝐿
.2mN )𝑥−31(4𝑒1=𝐼𝐸
. 8 ≤ 𝑥 ≤ 0 rof
)8/𝑥𝜋(nis = )𝑥(𝑓
02 = 𝑀 ⎯⎯⎯⎯⎯⎯
02− = 𝑄
8 = 𝑥 ⎯⎯⎯⎯ 4 = 𝑥
2
4𝑒1 = 𝐼𝐸
)𝐿 = 𝑥( 5 = 2𝑃
𝑀
𝑥𝖽/𝑤𝖽
𝑤
̅𝑥 ̅𝖽 ̅) ̅𝑥 ̅( ̅2 ̅ ̅𝑤 ̅ ̅0 ̅∫ ̅√ l
4=𝑥
43 ,33 ,23 ,3
Explain the method you have used to perform the numerical integration – provide a validation example that shows your method works.
Comment on the convergence of the solution.