In [1]:
    
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
In [2]:
    
from Section import Section
    
Initialization of sympy symbolic tool and pint for dimension analysis (not really implemented rn as not directly compatible with sympy)
In [3]:
    
ureg = UnitRegistry()
sympy.init_printing()
    
Define sympy parameters used for geometric description of sections
In [4]:
    
A, A0, t, t0, a, b, h, L = sympy.symbols('A A_0 t t_0 a b h L', positive=True)
    
We also define numerical values for each symbol in order to plot scaled section and perform calculations
In [5]:
    
values = [(A, 400 * ureg.millimeter**2),(A0, 250  * ureg.millimeter**2),(a, 400 * ureg.millimeter), \
          (b, 300 * ureg.millimeter),(h, 150 * ureg.millimeter),(L, 650 * ureg.millimeter),(t, 3 * ureg.millimeter)]
datav = [(v[0],v[1].magnitude) for v in values]
    
Define graph describing the section:
1) stringers are nodes with parameters:
2) panels are oriented edges with parameters:
In [7]:
    
stringers = {1:[(4*a,2*a),A],
             2:[(a,2*a),A],
             3:[(sympy.Integer(0),a),A],
             4:[(a,sympy.Integer(0)),A],
             5:[(2*a,a),A],
             6:[(4*a,sympy.Integer(0)),A]}
panels = {(1,2):t,
          (2,3):t,
          (3,4):t,
          (4,5):t,
          (5,2):t,
          (4,6):t,
          (6,1):t}
    
Define section and perform first calculations
In [8]:
    
S3 = Section(stringers, panels)
    
As we need to compute $x_{sc}$, we have to perform
$$A \cdot q_{ext} = T$$where:
Expression of A
In [9]:
    
sympy.simplify(S3.A)
    
    Out[9]:
Expression of T
In [10]:
    
sympy.simplify(S3.T)
    
    Out[10]:
Resulting fluxes and coordinate
In [12]:
    
sympy.simplify(S3.tempq)
    
    Out[12]:
In [13]:
    
start_pos={ii: [float(S3.g.node[ii]['ip'][i].subs(datav)) for i in range(2)] for ii in S3.g.nodes() }
    
In [14]:
    
plt.figure(figsize=(12,8),dpi=300)
nx.draw(S3.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);
    
    
Expression of Inertial properties wrt Center of Gravity in with original rotation
In [15]:
    
S3.Ixx0, S3.Iyy0, S3.Ixy0, S3.α0
    
    Out[15]:
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
In [16]:
    
positions={ii: [float(S3.g.node[ii]['pos'][i].subs(datav)) for i in range(2)] for ii in S3.g.nodes() }
    
In [17]:
    
x_ct, y_ct = S3.ct.subs(datav)
plt.figure(figsize=(12,8),dpi=300)
nx.draw(S3.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
In [18]:
    
S3.Ixx, S3.Iyy, S3.Ixy, S3.θ
    
    Out[18]:
In [19]:
    
S3.ct
    
    Out[19]:
In [20]:
    
S3.cycles
    
    Out[20]:
In [22]:
    
Tx, Ty, Nz, Mx, My, Mz, F, ry, ry, mz = sympy.symbols('T_x T_y N_z M_x M_y M_z F r_y r_x m_z')
S3.set_loads(_Tx=0, _Ty=1, _Nz=0, _Mx=Mx, _My=0, _Mz=0)
S3.compute_Jt()
S3.Jt
    
    Out[22]:
In [ ]: