- - - -
# Mechpy Tutorials
a mechanical engineering toolbox

source code - https://github.com/nagordon/mechpy  
documentation - https://nagordon.github.io/mechpy/web/  

- - - -

Neal Gordon  
2017-02-20  

- - - -

## statics

* [Example 1: A simple supported beam with shear-bending plots](#Statics-Example-1)
* [Example 2: Vector calculation method to calculate 3-D moments](#Statics-Example-2)
* [Distributed Loads Calculations](#Distributed-Loads-Calculations)


## Python Initilaization with module imports


```python
# setup 
import numpy as np
import sympy as sp
import scipy
from pprint import pprint
sp.init_printing(use_latex='mathjax')

import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = (12, 8)  # (width, height)
plt.rcParams['font.size'] = 14
plt.rcParams['legend.fontsize'] = 16
from matplotlib import patches

get_ipython().magic('matplotlib')  # seperate window
get_ipython().magic('matplotlib inline') # inline plotting
```

    Using matplotlib backend: Qt4Agg


- - - -
# Statics 
[index](#Mechpy)
- - - -

The sum of the forces is zero
$$
\Sigma F_x =0 , \Sigma F_y =0 , \Sigma F_z =0  
$$
The sum of the moments is zero
$$
\Sigma M_x =0 , \Sigma M_y =0 , \Sigma M_z =0  
$$

Dot Product

$$
\vec{A} \bullet \vec{B} = ABcos\left(\theta\right)= A_xB_x + A_yB_y+A_zB_z
$$

Cross-Product

$$
\vec{C}=\vec{A} \times \vec{B} = 
\begin{vmatrix}
    \widehat{i} & \widehat{j} & \widehat{k}\\
    A_{x} & A_{y} & A_{z}\\
    B_{x} & B_{y} & B_{z}
\end{vmatrix} 
$$

Moment of Force
$$
M_0 = Fd \\
\vec{M_0}=\vec{r}\times \vec{F} = 
\begin{vmatrix}
    \widehat{i} & \widehat{j} & \widehat{k}\\
    r_{x} & r_{y} & r_{z}\\
    F_{x} & F_{y} & F_{z}
\end{vmatrix} 
$$

Moment of Force about a Specified axis
$$
\vec{M_a}=\vec{u}\bullet\vec{r}\times \vec{F} = 
\begin{vmatrix}
    u_{x} & u_{y} & u_{z} \\
    r_{x} & r_{y} & r_{z} \\
    F_{x} & F_{y} & F_{z}
\end{vmatrix} 
$$


### Statics-Example 1
#### A simple supported beam with shear-bending plots


```python
import os ; os.chdir('..')  # change to root from the examples folder
from mechpy.statics import simple_support, moment_calc
```


```python
simple_support()
```

### Statics-Example 2
### Vector calculation method to calculate 3-D moments

$
\vec{M_{R_0}}=\Sigma \left( \vec{r} \times \vec{F} \right) = \vec{r_A}\times\vec{F_1} +\vec{r_A}\times\vec{F_2} + \vec{r_B}\times\vec{F_3}
$


```python
moment_calc()
```

### Distributed Loads Calculations

$
F_R = \Sigma F=\int_L w(x) \,dx  = \int_A dA \,dx  
$

example, hibbler, pg 187

$$
F_R=\int_A dA \, =  \int_{0}^{2} \, 60x^2 \, dx = 160 N
$$

$$
 \overline{x} = \frac{\int_A x \, dA}{\int_A dA} =  \frac{\int_{0}^{2} x60x^2 \, dx}{\int_{0}^{2} \, 60x^2 \, dx} = \frac{240}{160}
$$


```python
x = sp.var('x')
w = 60*x**2# N/m
sp.plot(w, (x,0,2));
```


```python
w.subs(x,2)
```




$$240$$




```python
sp.Integral(w,(x,0,2))
```




$$\int_{0}^{2} 60 x^{2}\, dx$$




```python
sp.integrate(w)
```




$$20 x^{3}$$




```python
sp.integrate(w,(x,0,2))
```




$$160$$




```python
sp.Integral(x*w,(x,0,2))
```




$$\int_{0}^{2} 60 x^{3}\, dx$$




```python
sp.integrate(w*x)
```




$$15 x^{4}$$




```python
sp.integrate(x*w,(x,0,2))
```




$$240$$




```python
FR= float(sp.integrate(w,(x,0,2)))
xbar = float(sp.integrate(x*w,(x,0,2)))/FR
print('center of load of an exponential distributed load is %f' % xbar)
```

    center of load of an exponential distributed load is 1.500000



```python
#hibbler pg 346

import numpy as np

r = np.array([    0, 3 , 5.25])
F = np.array([-13.5, 0 ,6.376])
M = -np.cross(r,F)

# moments 
print('M_x = %f \nM_y = %f \nM_z = %f' % (M[0], M[1], M[2] ))
```

    M_x = -19.128000 
    M_y = 70.875000 
    M_z = -40.500000


7d07ddca3863ce789e61025a65ce7afcb9241bb7
ipynb
Jupyter Notebook
tutorials/statics.ipynb
nagordon/mechpy
aae2315b883f6af7cd90a8451d170744bbf1053a
MIT
2017-01-27T04:40:30.000Z
2021-12-03T03:46:07.000Z
tutorials/statics.ipynb
Lunreth/mechpy
aae2315b883f6af7cd90a8451d170744bbf1053a
MIT
2016-03-01T00:42:38.000Z
2020-03-04T15:45:39.000Z
tutorials/statics.ipynb
Lunreth/mechpy
aae2315b883f6af7cd90a8451d170744bbf1053a
MIT
2016-04-25T14:12:34.000Z
2021-07-07T17:46:35.000Z
Qwen/Qwen-72B
1. YES
2. YES