a mechanical engineering toolbox
source code - https://github.com/nagordon/mechpy
documentation - https://nagordon.github.io/mechpy/web/
Neal Gordon
2017-02-20
# 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
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} $$
import os ; os.chdir('..') # change to root from the examples folder
from mechpy.statics import simple_support, moment_calc
simple_support()
$ \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} $
moment_calc()
$ 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} $$x = sp.var('x')
w = 60*x**2# N/m
sp.plot(w, (x,0,2));
w.subs(x,2)
sp.Integral(w,(x,0,2))
sp.integrate(w)
sp.integrate(w,(x,0,2))
sp.Integral(x*w,(x,0,2))
sp.integrate(w*x)
sp.integrate(x*w,(x,0,2))
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)
#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] ))