- - - -
# 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  

- - - -

## Finite Element Method
- - - -
This a collection of notes, examples and boilerplate code to understand fem. 


[Finite Element Method](#Finite-Element-Method)
* [solids FEM example](#FEM-Example-1)  

- - - -

## 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



```python
import os ; os.chdir('..')  # change to root from the examples folder
from mechpy.fem import cst_fem
```

## Finite-Element-Method
[index](#Mechpy) 

The element connectivty is used to assemble the global stiffness matrix, the nodal force matrix, and the displacement matrix

The minimization of the potentail energy is used to solve the global equation once the boundary conditions are applied to prevent rigid body motion

$ \{F\} = [K]\{U\} $

where  

$ \{F\}=nodal\ force\ matrix $  
$ [K] = global\ stiffness\ matrix $  
$ \{U\} = nodal\ displacement\ matrix $  

Once the displacements, U are computed, the strain, $\bar{\varepsilon}$ is calcualted 

with $\{\varepsilon\}=[B]\{U\}$

where

$[B]=strain-displacement\ matrix$

and stresses, $\bar{\sigma}$ are determined via Hookes Law and 

$\{\sigma\}=[C]\{\varepsilon\}$

where  

$[C] = compliance\ matrix$


### FEM-Example-1


```python
cst_fem(structure='9node')
```

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