Implementation#
Attention
This page shows a preview of the assignment. Please fork and clone the assignment to work on it locally from GitHub
After the workshop, the solution will be added to this preview and to the GitHub-repository
In this notebook you will continue to implement the matrix method and check it with some sanity checks.
Exercise (0)
Check whether your implementation of last week was correct using the provided solution
import matplotlib as plt
import numpy as np
sys.path.insert(1, '/matrixmethod_solution')
import matrixmethod_solution as mm
%config InlineBackend.figure_formats = ['svg']
import numpy as np
import matplotlib as plt
import matrixmethod as mm
%config InlineBackend.figure_formats = ['svg']
%load_ext autoreload
%autoreload 2
1. The Node class#
The Node
class from last week is unchanged and complete
2. The Element class#
The implementation is incomplete:
The function
add_distributed_load
should compute the equivalent load vector for a constant load \(q\) and moves those loads to the nodes belonging to the element. Remember to use theadd_load
function of theNode
class to store the equivalent loads (remember we have two nodes per element). Also keep local/global transformations in mind and storeself.q = q
for later use;The function
bending_moments
receives the nodal displacements of the element in the global coordinate system (u_global
) and uses it to compute the value of the bending moment atnum_points
equally-spaced points along the element length. Keep local/global transformations in mind and use the ODE approach in SymPy / Maple / pen and paper to compute an expression for \(M\). Do the same for for \(w\) in the functionfull_displacement
.
Exercise (2.1)
Add the missing pieces to the code, before you perform the checks below.
Having made your implementations, it is now time to verify the first addition of your code with a simple sanity check. We would like to solve the following simply-supported beam:
Choose appropriate values yourself.
Exercise (2.2)
Use the code blocks below to set up this problem. After you’ve added the load, print the element using print(YOUR ELEMENT)
. Do the shown values for the nodal loads correspond with what you’d expect?
#YOUR CODE HERE
print(#YOUR ELEMENT HERE
Exercise (2.3)
Now solve the nodal displacements. Once you are done, compare the rotation at the right end of the beam. Does it match a solution you already know?
#YOUR CODE HERE
Exercise (2.4)
Calculate the bending moment at midspan and plot the moment distribution using plot_moment_diagram
. Do the values and shape match with what you’d expect?
u_elem = con.full_disp(#YOUR CODE HERE)
#YOUR CODE HERE
Exercise (2.5)
Calculate the deflection at midspan and plot the deflected structure using plot_displaced
. Do the values and shape match with what you’d expect?
#YOUR CODE HERE
3. The Constrainer class#
We’re going to expand our Constrainer class, but the implementation is incomplete:
The constrainer class should be able to handle non-zero boundary conditions too.
constrain
should be adapted to do so + the docstring of the class itself. Furthermore, the assert statement offix_dof
should be removed.The function
support_reactions
is incomplete. Since the constrainer is always first going to getconstrain
called, here we already have access toself.free_dofs
. Together withself.cons_dofs
, you should have all you need to compute reactions. Note thatf
is also passed as argument. Make sure you take into account the contribution of equivalent element loads that go directly into the supports without deforming the structure.
Exercise (3.1)
Add the missing pieces to the code and docstring, before you perform the checks below.
We’re going to verify our implementation. Therefore, we’re going to solve an extension bar, supported at both ends, with a load \(q\).
Choose appropriate values yourself.
Exercise (3.2)
Can you say on beforehand what will be the displacements? And what will be the support reactions?
Use the code blocks below to set up and solve this problem and check the required quantities to make sure your implementation is correct.
#YOUR CODE HERE
Again, we’re going to verify our implementation. Therefore, we’re going solve a beam, with a load \(F\) and support displacement \(\bar w\) for the right support.
Choose appropriate values yourself.
Exercise (3.3)
Use the code blocks below to set up and solve this problem and check the required quantities to make sure your implementation is correct.
#YOUR CODE HERE