CL4

.pdf

School

University of Illinois, Urbana Champaign *

*We aren’t endorsed by this school

Course

257

Subject

Aerospace Engineering

Date

Apr 3, 2024

Type

pdf

Pages

6

Uploaded by CoachGuanaco4012

Report
12/13/22, 12:01 AM Slinky - Part1 https://www.prairielearn.org/pl/workspace/512909 1/6 Matplotlib created a temporary config/cache directory at /tmp/matplotlib-3e84p244 becaus e the default path (/tmp/cache/matplotlib) is not a writable directory; it is highly rec ommended to set the MPLCONFIGDIR environment variable to a writable directory, in partic ular to speed up the import of Matplotlib and to better support multiprocessing. # Lesson 4: Linear Systems **You learned about spring systems during lecture. We will now use this knowledge to understand how a Slinky changes its shape due to gravity!** ![Figure] (slinky1.jpg) Try taking a slinky and suspend it from one side. What happens to its shape? Today we will model the deformation (change of shape) of a slinky under the effects of gravitational forces. We will break down the slinky into many small springs, creating a mass-spring system as illustrated below: where in the general case, $f_i$ is the applied force and $u_i$ is the corresponding displacement (movement) at mass $m_i$. For this example, the applied force $f_i$ correspond to the gravitational force. We want to determine the equilibrium condition of this system, such that the balance of the internal forces (resulting from the spring getting deformed) and external forces (applied forces at the masses) is equal to zero. To accomplish this we will follow Hooke's law, which states the spring force needed to deform a spring by an amount $\Delta L$ is given as $−k \Delta L$, where $k$ is the spring's stiffness. Consider the two springs below: The force that spring $k_i$ exerts on mass $m_i$ is given by $-k_i(u_i - u_{i- 1})$. In a similar way, the force that spring $k_{i+1}$ exerts on mass $m_i$ is $k_{i+1}(u_{i+1} - u_{i})$. We can combine these two spring forces and the applied force at $m_i$ to obtain the following equation: $$f_i - k_i(u_i - u_{i-1}) + k_{i+1}(u_{i+1} - u_{i}) = 0 $$ If we apply the equilibrium equation to all $N$ masses of the spring system, we get the following system of equations: $$ \begin{equation} f_1 - k_1(u_1 - u_{0}) + k_{2}(u_{2} - u_{1}) = 0 \\ f_2 - k_2(u_2 - u_{1}) + k_{3}(u_{3} - u_{2}) = 0 \\ f_3 - k_3(u_3 - u_{2}) + k_{4}(u_{4} - u_{3}) = 0 \\ f_4 - k_4(u_4 - u_{3}) + k_{5}(u_{5} - u_{4}) = 0 \\ f_5 - k_5(u_5 - u_{4}) = 0 \\ \end{equation} $$ We can assume that $u_0 = 0$, indicating that one end of the slinky is held in place. The above equations can be re-written in matrix form: $$ \begin{eqnarray} \begin{bmatrix} k_1+k_2 & -k_2 & 0 & 0 & 0 \\ - k_2 & k_2+k_3 & -k_3 & 0 & 0 \\ 0 & -k_3 & k_3+k_4 & -k_4 & 0 \\ 0 & 0 & -k_4 & k_4 + k_5 & - k_5 \\ 0 & 0 & 0 & -k_5 & k_5 \\ \end{bmatrix} \begin{bmatrix} u_1\\ u_2 \\ u_3 \\ u_4 \\ u_5 \end{bmatrix} = \begin{bmatrix} f_1\\ f_2 \\ f_3 \\ f_4 \\ f_5 \end{bmatrix} \end{eqnarray} $$ which we can solve for the unknown displacements $u_i$ by solving $${\bf K}{\bf u} = {\bf f}$$ where we will denote ${\bf K}$ the stiffness matrix, ${\bf u}$ the displacement vector and ${\bf f}$ the force vector. **We are done! We can now analyze the slinky model.** Problem definition - Input variables: The overall slinky has mass $M$, length $L_s$ and stiffness $K_s$ (a parameter that depends on the material and the dimensions of the slinky). We will use the parameters below for the metal slinky: In [2]: import numpy as np import numpy.linalg as la import matplotlib.pyplot as plt % matplotlib inline
12/13/22, 12:01 AM Slinky - Part1 https://www.prairielearn.org/pl/workspace/512909 2/6 Our model assumes that the mass $M$ is split into a series of $(N+1)$ smaller equal masses $m = M/(N+1)$ which are connected by $N$ massless ideal springs. Hence, the slinky is divided into smaller but stiffer springs, with $l = L_s/N$ and $k = K_s\cdot N$ (in this example, all springs have the same stiffness, since the slinky is made of one material). In other words, we will discretize our model into $N$-many springs. We will start by using $N = 5$. You will later use a finer discretization by increasing the value of $N$. 28.333333333333332 For the spring system above, all the springs will have the same spring stiffness $k$, since we are assuming the entire slinky is made of the same material. But in general, we could combine two slinkies of different materials. For that reason, we will define the array k_array which contains each individual spring stiffness: $$ \textrm{k_array} = [k_1, k_2, k_3, ... , k_N ] $$ Obtaining the stiffness matrix In order to create the stiffness matrix in a programatically way, so that we can later add many more springs (or use different material) without having to change our code, we will take advantage of the pattern of this matrix. Here is the stiffness matrix for the 5 spring system: $$ \begin{eqnarray} {\bf K} = \begin{bmatrix} k_1+k_2 & -k_2 & 0 & 0 & 0 \\ -k_2 & k_2+k_3 & -k_3 & 0 & 0 \\ 0 & -k_3 & k_3+k_4 & -k_4 & 0 \\ 0 & 0 & -k_4 & k_4 + k_5 & -k_5 \\ 0 & 0 & 0 & -k_5 & k_5 \\ \end{bmatrix} \end{eqnarray} $$ Can you see a pattern? Note that each spring contributes to the stiffness matrix with the following sub-matrix: $$ \begin{eqnarray} \begin{bmatrix} k_i & -k_i \\ -k_i & k_i\\ \end{bmatrix} \end{eqnarray} $$ with the exception of $k_1$. Once you can recognize the pattern, you will need to: In [3]: Ls = 10 # (cm) Length of the slinky Ks = 700 # (N/cm) Stiffness M = 170 # (grams) Total mass In [4]: # Number of springs N = 5 In [5]: m = M / ( N + 1 ) # each individual mass k = Ks * N # each individiual spring stiffness l = Ls / N # each individual spring length m Out[5]: In [6]: k_array = k * np . ones ( N )
12/13/22, 12:01 AM Slinky - Part1 https://www.prairielearn.org/pl/workspace/512909 3/6 1) add this sub-matrix in the correct location of the bigger stiffness matrix ${\bf K}$ 2) adjust the first line of the stiffness matrix ${\bf K}$, that follows a different pattern due to the boundary conditions To help you with 1), you could use the following method to insert the sub-matrix Asub in the matrix A given the position of the entry Asub[0,0] . This is not a requirement, there are other ways to accomplish the same thing :-) [[0. 1. 1. 0. 0.] [0. 1. 1. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.]] [[0. 1. 1. 0. 0.] [1. 2. 1. 0. 0.] [1. 1. 0. 0. 0.] [0. 0. 0. 0. 0.] [0. 0. 0. 0. 0.]] Check your answers! Create the stiffness matrix Define the function get_stiffness that takes the array k_array with each spring stiffness, and returns the stiffness matrix ${\bf K}$. You can refer back to the definition of the stiffness matrix above. Now you can get the stiffness matrix K given k_array : In [7]: A = np . zeros (( 5 , 5 )) Asub = np . ones (( 2 , 2 )) # Use Python slicing # Insert by overriding a sub-matrix A [ 0 : 2 , 1 : 3 ] = Asub print ( A ) # Insert by adding a sub-matrix A [ 1 : 3 , 0 : 2 ] += Asub print ( A ) In [16]: #grade (enter your code in this cell - DO NOT DELETE THIS LINE) def get_stiffness ( k_array ): # k_array: 1d numpy array with all the stiffness spring values # number of springs N = len ( k_array ) # create and return an N x N stiffness matrix K = np . zeros (( N , N )) for i in range ( 1 , N ): ki = k_array [ i ] ke = np . array ([[ ki , - ki ],[ - ki , ki ]]) K [ i - 1 : i + 1 , i - 1 : i + 1 ] += ke K [ 0 , 0 ] += k_array [ 0 ] return K
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help