from sympy import *
from sympy import N as Num
import matplotlib.pyplot as plt
from numpy import linspace, full_like, array, arange
C1, C2 = var('C1, C2')
l, q = var('l, q')
print("--- 1-3: Compute C1, C2 -------------------")
eqns = [
Eq(0, q/24*l**4 + C1/6*l**3 + C2/2*l**2),
Eq(0, q/2*l**2 + C1*l + C2),
]
sol = solve(eqns, [C1, C2])
print sol[C1]
print sol[C2]
print("--- e: find xi with w'(xi)=0 --------------")
xi = var('xi')
def w(xi):
t1 = xi**2/16
t2 =-5*xi**3/48
t3 = xi**4/24
return t1+t2+t3
w_prime = diff(w(xi),xi)
xiw = solve(w_prime)
for Xi in xiw:
print "xi, w(xi): ", Num(Xi,4), Num(w(Xi),3)
print("--- f: ------------------------------------")
q, a, EI = var("q, a, EI")
W = q*a*a*a*a/EI * w(xi)
print "W:"
pprint(W)
W_p = diff(W,xi)/a
W_pp = diff(W_p,xi)/a
W_ppp = diff(W_pp,xi)/a
MA = -EI*W_pp.subs(xi,0)
Av = -EI*W_ppp.subs(xi,0)
Bv = EI*W_ppp.subs(xi,1)
print("--- e: plot -------------------------------")
xi = linspace(float(0),float(1))
tmp = plt.plot(xi,w(xi), label="$w EI / qa^4$")
tmp = plt.xlabel("$x / a$")
tmp = plt.legend()
plt.gca().invert_yaxis()
plt.show()
--- 1-3: Compute C1, C2 -------------------
-5*l*q/8
l**2*q/8
--- e: find xi with w'(xi)=0 --------------
xi, w(xi): 0 0
xi, w(xi): 0.5785 0.00542
xi, w(xi): 1.297 -0.00423
--- f: ------------------------------------
W:
/ 4 3 2\
4 |xi 5*xi xi |
a *q*|--- - ----- + ---|
\ 24 48 16/
------------------------
EI
--- e: plot -------------------------------
/ext/sage/sage-8.0/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
