# Semi-Monocoque Theory: corrective solutions


```python
from pint import UnitRegistry
import sympy
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import sys
%matplotlib inline
from IPython.display import display
```

Import **Section** class, which contains all calculations


```python
from Section import Section
```

Initialization of **sympy** symbolic tool and **pint** for dimension analysis (not really implemented rn as not directly compatible with sympy)


```python
ureg = UnitRegistry()
sympy.init_printing()
```

Define **sympy** parameters used for geometric description of sections


```python
A, A0, t, t0, a, b, h, L, E, G = sympy.symbols('A A_0 t t_0 a b h L E G', positive=True)
```

We also define numerical values for each **symbol** in order to plot scaled section and perform calculations


```python
values = [(A, 150 * ureg.millimeter**2),(A0, 250  * ureg.millimeter**2),(a, 80 * ureg.millimeter), \
          (b, 20 * ureg.millimeter),(h, 35 * ureg.millimeter),(L, 2000 * ureg.millimeter), \
          (t, 0.8 *ureg.millimeter),(E, 72e3 * ureg.MPa), (G, 27e3 * ureg.MPa)]
datav = [(v[0],v[1].magnitude) for v in values]
```

# Second example: Rectangular section with 6 nodes and 2 loops

Define graph describing the section:

1) **stringers** are **nodes** with parameters:
- **x** coordinate
- **y** coordinate
- **Area**

2) **panels** are **oriented edges** with parameters:
- **thickness**
- **lenght** which is automatically calculated


```python
stringers = {1:[(2*a,h),A],
             2:[(a,h),A],
             3:[(sympy.Integer(0),h),A],
             4:[(sympy.Integer(0),sympy.Integer(0)),A],
             5:[(a,sympy.Integer(0)),A],
             6:[(2*a,sympy.Integer(0)),A]}

panels = {(1,2):t,
          (2,3):t,
          (3,4):t,
          (4,5):t,
          (5,6):t,
          (6,1):t,
          (5,2):t}
```

Define section and perform first calculations


```python
S1 = Section(stringers, panels)
```


```python
S1.cycles
```

## Plot of **S1** section in original reference frame

Define a dictionary of coordinates used by **Networkx** to plot section as a Directed graph.
Note that arrows are actually just thicker stubs


```python
start_pos={ii: [float(S1.g.node[ii]['ip'][i].subs(datav)) for i in range(2)] for ii in S1.g.nodes() }
```


```python
plt.figure(figsize=(12,8),dpi=300)
nx.draw(S1.g,with_labels=True, arrows= True, pos=start_pos)
plt.arrow(0,0,20,0)
plt.arrow(0,0,0,20)
#plt.text(0,0, 'CG', fontsize=24)
plt.axis('equal')
plt.title("Section in starting reference Frame",fontsize=16);
```

## Plot of **S1** section in inertial reference Frame

Section is plotted wrt **center of gravity** and rotated (if necessary) so that *x* and *y* are principal axes.
**Center of Gravity** and **Shear Center** are drawn


```python
positions={ii: [float(S1.g.node[ii]['pos'][i].subs(datav)) for i in range(2)] for ii in S1.g.nodes() }
```


```python
x_ct, y_ct = S1.ct.subs(datav)

plt.figure(figsize=(12,8),dpi=300)
nx.draw(S1.g,with_labels=True, pos=positions)
plt.plot([0],[0],'o',ms=12,label='CG')
plt.plot([x_ct],[y_ct],'^',ms=12, label='SC')
#plt.text(0,0, 'CG', fontsize=24)
#plt.text(x_ct,y_ct, 'SC', fontsize=24)
plt.legend(loc='lower right', shadow=True)
plt.axis('equal')
plt.title("Section in pricipal reference Frame",fontsize=16);
```

Expression of **inertial properties** in *principal reference frame*


```python
sympy.simplify(S1.Ixx), sympy.simplify(S1.Iyy), sympy.simplify(S1.Ixy), sympy.simplify(S1.θ)
```


```python
S1.symmetry
```




    [{'edges': [((1, 2), (2, 3)), ((3, 4), (6, 1)), ((4, 5), (5, 6)), (5, 2)],
      'nodes': [(1, 3), (2, 2), (4, 6), (5, 5)]},
     {'edges': [((1, 2), (5, 6)), ((2, 3), (4, 5)), (3, 4), (5, 2), (6, 1)],
      'nodes': [(1, 6), (2, 5), (3, 4)]}]



Compute **L** matrix: with 6 nodes we expect 3 **dofs**, two with _symmetric load_ and one with _antisymmetric load_


```python
S1.compute_L()
```


```python
S1.L
```

Compute **H** matrix


```python
S1.compute_H()
```


```python
S1.H.subs(datav)
```

Compute $\tilde{K}$ and $\tilde{M}$


```python
S1.compute_KM(A,h,t)
```


```python
S1.Ktilde
```


```python
S1.Mtilde.subs(datav)
```

Compute **eigenvalues** and **eigenvectors**: results are in the form:
- eigenvalue
- multiplicity
- eigenvector


```python
sol_data = (S1.Ktilde.inv()*(S1.Mtilde.subs(datav))).eigenvects()
sol_data
```

Extract eigenvalues


```python
β2 = [sol[0] for sol in sol_data]
β2
```

Extract and normalize eigenvectors


```python
X = [sol[2][0]/sol[2][0].norm() for sol in sol_data]
X
```

Compute numerical value of $\lambda$


```python
λ = [sympy.N(sympy.sqrt(E*A*h/(G*t)*βi).subs(datav)) for βi in β2]
λ
```


```python

```

4aa79975220dd9ccac0fc6a17b87d674d08c6afc
ipynb
Jupyter Notebook
05_CorrectiveSolutions-6nodes-2loops.ipynb
Ccaccia73/semimonocoque
b67fc1a7f64f4ded85821b4ece779521724d5d55
MIT
05_CorrectiveSolutions-6nodes-2loops.ipynb
Ccaccia73/semimonocoque
b67fc1a7f64f4ded85821b4ece779521724d5d55
MIT
05_CorrectiveSolutions-6nodes-2loops.ipynb
Ccaccia73/semimonocoque
b67fc1a7f64f4ded85821b4ece779521724d5d55
MIT
Qwen/Qwen-72B
1. YES
2. YES