# Slope Deflection Example - Frame 1
Illustrates the solution of simple, statically-indeterminate framed structures
using the method of **slope-deflection** and symbolic algebra.
This version uses an improved version of 'sdutil' that computes end shears as well as moments.


```python
from sympy import *                 # use symbolic algebra
init_printing(use_latex='mathjax')  # print nice math (use_latex arg is workaround for FormatterWarning messages)
from IPython import display
```


```python
from sdutil2 import SD, FEF
```

Analyze the following frame using the method of **slope-deflection**.


```python
display.SVG('frame1.svg')
```




    

    



This frame has 5 independant joint displacements - rotations at the four
joints *a*, 
*b*, 
*c*, 
and 
*d*, 
and a lateral displacement of joints 
*b*
and 
*c* 
together.  Actually, we know that joint *d* does not rotate, but we
will pretend it does for now, and will handle that as a displacement constraint
later.

So now we write the slope deflection equations.  These express the end moments
as functions of the five unknown displacements.  Note also that we do not treat the
pin-ended member *ab* specially -- it is not necessary to do so.

We use a very simple utility function *SD()* to compute the end moments and shears of a segment,
as a function of the end displacements:


```python
help(SD)
```

    Help on function SD in module sdutil2:
    
    SD(L, EI, t0, t1, d01=0)
        Return the end moments and shears of a segment as computed by the slope 
        deflection equations.
           L = length, 
           EI = stiffness, 
           t0 = rotation at end 0 (left), 
           t1 = rotation at end 1, 
           d01 = relative lateral displacment end 0 to end 1.  
        SD sign convention: moments and rotation are +ive CW, 
        relative displacement d01 is +ive for CW rotation of chord.
    



```python
# Slope deflection equations:
# theta_a,b,c,d - rotations of joints
# Delta_ab - horizontal displacement of joint b (and c) relative to a (and d)
var('EI theta_a theta_b theta_c theta_d Delta_ab')
Mab,Mba,Vab,Vba = SD(3,EI,theta_a,theta_b,Delta_ab)
Mbc,Mcb,Vbc,Vcb = SD(6,2*EI,theta_b,theta_c,0) + FEF.udl(6,36)
Mcd,Mdc,Vcd,Vdc = SD(2,EI,theta_c,theta_d,Delta_ab)
```

Display just one of the end moments to see what the values look like.  They are indeed algebraic expressions.


```python
Mbc
```




$$\frac{EI}{3} \left(4 \theta_{b} + 2 \theta_{c}\right) - 108.0$$



Now we write five linear equations to solve for the five unknown displacements.
Three are equilibrium equations and involve moments at three of the joints: $Mab = 0$, $Mba+Mbc=0$, and $Mcb+Mcd=0$.
One equation involves the equilibrium of the column shears with the horizontal applied
load: $Vab+Vdc-60=0$.  The fifth equation is just the known rotation at joint *d*: $\theta_d=0$.

In sympy, we build a list of the five equations, all expressed as $f(..,..) = 0$ and giving only the left side of each (the right side always being 0 is not given).  We then call the solver and give it a list of variables to solve for:


```python
eqns = [Mab, Mba+Mbc, Mcb+Mcd, Vab+Vdc-60, theta_d]
soln = solve(eqns,[theta_a,theta_b,theta_c,theta_d,Delta_ab])
soln
```




$$\left \{ \Delta_{ab} : \frac{14.2834008097166}{EI}, \quad \theta_{a} : - \frac{22.4210526315789}{EI}, \quad \theta_{b} : \frac{59.1255060728745}{EI}, \quad \theta_{c} : - \frac{37.7975708502024}{EI}, \quad \theta_{d} : 0.0\right \}$$



The above solution is returned as a Python dictionary, making it easy to substitute for those
variables in other equations.

In fact, that is done now, substituting the displacement solutions into each
of the slope-deflection equations.  The result is a list of the member end moments (and shears).

The '.n(4)' method forces a numerical answer with 4 significant figures.


```python
{v:eval(v).subs(soln).n(4) for v in 'Mab,Mba,Mbc,Mcb,Mcd,Mdc,Vab,Vdc'.split(',')}
```




    {'Mab': -4.737e-15,
     'Mba': 54.36,
     'Mbc': -54.36,
     'Mcb': 97.02,
     'Mcd': -97.02,
     'Mdc': -59.22,
     'Vab': -18.12,
     'Vdc': 78.12}



And now - the reactions at supports *a* and *d*:


```python
Ra = Vbc
Rd = -Vcb
Ha = -Vab
Hd = -Vdc
Md = Mdc
[v.subs(soln).n(4) for v in [Ra,Ha,Rd,Hd,Md]]
```




$$\left [ 100.9, \quad 18.12, \quad 115.1, \quad -78.12, \quad -59.22\right ]$$



#### Equilibrium checks:


```python
# sum horizontal forces
(Ha + Hd + 60).subs(soln)
```




$$0$$




```python
# sum vertical forces
(Ra + Rd - 36*6).subs(soln)
```




$$0$$




```python
# sum moments about a
(60*3 + 36*6*3 + Hd*1 + Md - Rd*6).subs(soln)
```




$$0$$



### Plots
Plot bending moment in *bc* as a function of distance *x* from left end, *b*:


```python
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
```


```python
var('x')
Mbcx = (Ra*x + Vab*3 - 36*x*x/2).subs(soln)  # M as a function of x
fn = lambdify((x),Mbcx)   # convert moment expression to a function of one argument
z = np.linspace(0,6)
plt.plot(z,fn(z),[0,6],[0,0])
plt.fill_between(z,fn(z),color='lightgrey')
##plt.show()
```

Find the locations along span *bc* of zero moment:


```python
[r.n(4) for r in solve(Mbcx)]
```




$$\left [ 0.6039, \quad 5.001\right ]$$



Find point of maximum moment and the maximum moment in the span:


```python
xs = solve([Mbcx.diff(x)])
xs
```




$$\left \{ x : 2.80251911830858\right \}$$




```python
xs[x].n(4), Mbcx.subs(xs).n(4)
```




$$\left ( 2.803, \quad 87.01\right )$$




```python

```

aa1c7ef2ac17605095b75f605204336befe10445
ipynb
Jupyter Notebook
slope-deflection/Slope-Deflection-Frame-1-Version-2.ipynb
nholtz/structural-analysis
246d6358355bd9768e30075d1f6af282ceb995be
CC0-1.0
2016-05-26T07:01:51.000Z
2019-05-31T23:48:11.000Z
slope-deflection/Slope-Deflection-Frame-1-Version-2.ipynb
nholtz/structural-analysis
246d6358355bd9768e30075d1f6af282ceb995be
CC0-1.0
slope-deflection/Slope-Deflection-Frame-1-Version-2.ipynb
nholtz/structural-analysis
246d6358355bd9768e30075d1f6af282ceb995be
CC0-1.0
2016-08-30T06:08:03.000Z
2016-08-30T06:08:03.000Z
Qwen/Qwen-72B
1. YES
2. YES