Mechpy Tutorials

a mechanical engineering toolbox

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


Neal Gordon
2017-02-20


Composites

This a collection of sample codes for various calcuations useful for composites mechanics

Python Initilaization with module imports

In [1]:
cd ..
Y:\github\mechpy
In [11]:
# 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

mechpy Composite Mechanics

In [12]:
from mechpy.math import T3rot, T6rot
from mechpy.composites import my_laminate_with_loading, material_plots, laminate_gen, \
plot_single_max_failure_loads
In [13]:
import importlib
importlib.reload
Out[13]:
<function importlib.reload>
In [14]:
from mechpy.math import T2rot
T2rot(45)
Out[14]:
array([[ 0.525, -0.851],
       [ 0.851,  0.525]])
In [15]:
print(T6rot(45,45,45))
[[ 0.25   0.25   0.5   -0.354 -0.354  0.25 ]
 [ 0.021  0.729  0.25   0.427 -0.073 -0.125]
 [ 0.729  0.021  0.25  -0.073  0.427 -0.125]
 [-0.25  -0.25   0.5    0.354  0.354  0.75 ]
 [ 0.854 -0.146 -0.707  0.354 -0.354  0.354]
 [-0.146  0.854 -0.707 -0.354  0.354  0.354]]
In [16]:
help(laminate_gen)
Help on function laminate_gen in module mechpy.composites:

laminate_gen(lamthk=1.5, symang=[45, 0, 90], plyratio=2.0, matrixlayers=False, balancedsymmetric=True)
    ## function created to quickly create laminates based on given parameters
    lamthk=1.5    # total #thickness of laminate
    symang = [45,0,90, 30]  #symmertic ply angle
    plyratio=2.0  # lamina/matrix ratio
    matrixlayers=False  # add matrix layers between lamina plys
    nonsym=False    # symmetric
    mat = material type, as in different plies, matrix layer, uni tapes, etc
    #ply ratio can be used to vary the ratio of thickness between a matrix ply
         and lamina ply. if the same thickness is desired, plyratio = 1,
         if lamina is 2x as thick as matrix plyratio = 2

In [17]:
%matplotlib inline
In [18]:
material_plots()
In [19]:
my_laminate_with_loading()
--------------- laminate1 Stress analysis of fibers----------
(z-) plyangles (z+)
[60, 0, -60]
(z-) plymatindex (z+)
[0, 0, 0]
ply layers
[-0.022 -0.007  0.007  0.022]
lamiante thickness, H = 0.0450
Applied Loads
[50, 0, 0, 0, 0, 0]
ABD=
[[  1.392e+05   3.750e+04   0.000e+00   0.000e+00   0.000e+00   1.653e+02]
 [  3.750e+04   1.392e+05   0.000e+00   0.000e+00   0.000e+00  -1.850e+02]
 [  0.000e+00   0.000e+00   5.082e+04   1.653e+02  -1.850e+02   0.000e+00]
 [  0.000e+00   0.000e+00   1.653e+02   2.179e+01   7.846e+00   0.000e+00]
 [  0.000e+00   0.000e+00  -1.850e+02   7.846e+00   2.214e+01   0.000e+00]
 [  1.653e+02  -1.850e+02   0.000e+00   0.000e+00   0.000e+00   1.009e+01]]
Ex=   2763160.75
Ey=   2749303.19
nuxy= 0.30
Gxy=  1032764.64
epsilon_laminate
[[ 0.   ]
 [-0.   ]
 [ 0.   ]
 [ 0.   ]
 [ 0.   ]
 [-0.009]]
sigma_laminate
[[  1.111e+03]
 [ -7.895e-14]
 [  0.000e+00]
 [  0.000e+00]
 [  0.000e+00]
 [  0.000e+00]]
sigma_principal_laminate
[  1.111e+03  -7.895e-14   0.000e+00]
principal_angle = 0.00 deg
NMbarapp
[[50]
 [ 0]
 [ 0]
 [ 0]
 [ 0]
 [ 0]]
sigma
[[  416.558   233.488  1398.393  1398.393   233.488   416.558]
 [  686.155   863.451  -264.712  -264.712   863.451   686.155]
 [ -374.715  -329.91     44.805   -44.805   329.91    374.715]]

Max Stress Percent Margin of Safety, failure < 0, minimum = 15.2790
[[  74.38    74.38    21.454   21.454  133.482  133.482]
 [  39.078   39.078   90.798   90.798   30.849   30.849]
 [  15.279   15.279  135.144  135.144   17.49    17.49 ]]

Tsai-Wu Percent Margin of Safety, failure < 0, minimum = 14.8606
[ 14.861  18.423  15.833]

maximum failure index = 0.0614
[[ 0.013  0.013  0.045  0.045  0.007  0.007]
 [ 0.025  0.025  0.011  0.011  0.031  0.031]
 [ 0.061  0.061  0.007  0.007  0.054  0.054]]

Buckling MS for Nxy only for clamped edges = 10000000000000000.0000

buckling combined loads and simple support MS = 10000000000000000.0000

Mx_midspan = 0.00
My_midspan = 0.00
Mxy_midspan = -0.00
w0_simplesupport =    0.000000
w0_clamped =          0.000000
w0_clamped_isotropic= 0.000000
C:\Users\neal\Anaconda3\lib\site-packages\matplotlib\figure.py:397: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
  "matplotlib is currently using a non-GUI backend, "
In [20]:
plot_single_max_failure_loads(mymat='E-Glass Epoxy fabric M10E-3783', mylayup=[0,45,45,0] )
------------- enveloped loads for [0, 45, 45, 0] E-Glass Epoxy fabric M10E-3783 -----------------
Nx = 2447.1 , -2447.1
Ny = 2415.8 , -2415.8
Nxy = 1215.7 , -1215.7
Mx = 31.7 , -36.2
My = 28.1 , -31.8
Mxy = 8.5 , -8.5
q0 = 5.6 , -6.4
Out[20]:
['Nx = 2447.1 , -2447.1',
 'Ny = 2415.8 , -2415.8',
 'Nxy = 1215.7 , -1215.7',
 'Mx = 31.7 , -36.2',
 'My = 28.1 , -31.8',
 'Mxy = 8.5 , -8.5',
 'q0 = 5.6 , -6.4']
In [ ]:
 
In [ ]:
 
In [ ]: