Stiffness matrix, equivalent force vector and postprocess results of Euler Bernoulli beam

Stiffness matrix, equivalent force vector and postprocess results of Euler Bernoulli beam#

import sympy as sym
sym.init_printing()
EI, q_z, x, L = sym.symbols('EI, q_z, x, L')
w = sym.Function('w')

ODE_bending = sym.Eq(w(x).diff(x, 4) *EI, q_z)
display(ODE_bending)
../_images/219c8da0e5b67a82706d44a475686e1e91a309b689c98f521acbfacdfceef1c3.png
w = sym.dsolve(ODE_bending, w(x)).rhs
display(w)
../_images/0c681b16fa48cef977f079b20d6872a28dbaa9ca6f88cf278fd39580871b57d5.png
phi = -w.diff(x)
kappa = phi.diff(x)
M = EI * kappa
V = M.diff(x)
w_1, w_2, phi_1, phi_2 = sym.symbols('w_1, w_2, phi_1, phi_2')

eq1 = sym.Eq(w.subs(x,0),w_1)
eq2 = sym.Eq(w.subs(x,L),w_2)
eq3 = sym.Eq(phi.subs(x,0),phi_1)
eq4 = sym.Eq(phi.subs(x,L),phi_2)

sol = sym.solve([eq1, eq2, eq3, eq4 ], sym.symbols('C1, C2, C3, C4'))
display(sol)
../_images/ff85c6d596caf2c52dd437ed82687ef3afa27d80b004f6104018e79dcd83d78d.png
F_1_z, F_2_z, T_1_y, T_2_y = sym.symbols('F_1_z, F_2_z, T_1_y, T_2_y')

eq5 = sym.Eq(-V.subs(sol).subs(x,0), F_1_z)
eq6 = sym.Eq(V.subs(sol).subs(x,L), F_2_z)
eq7 = sym.Eq(-M.subs(sol).subs(x,0), T_1_y)
eq8 = sym.Eq(M.subs(sol).subs(x,L), T_2_y)
A, b = sym.linear_eq_to_matrix([eq5,eq7, eq6, eq8], [w_1, phi_1, w_2, phi_2])
display(A)
display(b)
../_images/0616938a661ebcbf4d49405707126608d57b83bde5adb7d58a0b4f0fc705a5bf.png ../_images/ef50d487c200ef5a5b63c291d16211f9cbe90cb2bef61f0d61aaabded100bc3c.png
K = sym.lambdify((L, EI), A)
print(K.__doc__)
print('Example of K with L=5 and EI=1000:\n', K(5,1000))
Created with lambdify. Signature:

func(L, EI)

Expression:

Matrix([[12*EI/L**3, -6*EI/L**2, -12*EI/L**3, -6*EI/L**2], [-6*EI/L**2,...

Source code:

def _lambdifygenerated(L, EI):
    return array([[12*EI/L**3, -6*EI/L**2, -12*EI/L**3, -6*EI/L**2], [-6*EI/L**2, 4*EI/L, 6*EI/L**2, 2*EI/L], [-12*EI/L**3, 6*EI/L**2, 12*EI/L**3, 6*EI/L**2], [-6*EI/L**2, 2*EI/L, 6*EI/L**2, 4*EI/L]])


Imported modules:


Example of K with L=5 and EI=1000:
 [[  96. -240.  -96. -240.]
 [-240.  800.  240.  400.]
 [ -96.  240.   96.  240.]
 [-240.  400.  240.  800.]]
M_postprocess = sym.collect(M.subs(sol).expand(),[w_1,w_2,phi_1,phi_2, q_z])
display(M_postprocess)
../_images/8f0b5bb7a680dc72f9f0071226432cc6b56fcba8c10f90519642c4a2940b6d35.png