Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
555 views
from sympy.physics.units import * from sympy import * from sympy import N as Num import matplotlib.pyplot as plt from numpy import linspace, full_like, array, arange f22 = S(2)/2 f32 = S(3)/2 f42 = S(4)/2 # helper function: def fill_array(f,x,xia): if f.is_constant(x): res = full_like(xia,f) else: res = lambdify(x,f,"numpy") res = array(res(xia)) return res # symbols: a, MB, EI = var('a, MB, EI') print("\n--- a: --------------------------------") x, B_v = var("x, B_v") M = (a - x) * B_v + MB print("\n--- b: --------------------------------") # integrating M to get w: C1, C2 = var('C1, C2') unknowns = [C1, C2] wpp = - 1/EI * M wp = integrate(wpp,x) + 1/EI*C1 w = integrate(wp,x) + 1/EI*C2 pprint(w) w = expand(w) w = collect(w,B_v) w = w.simplify() pprint(w*EI) pprint(latex(w*EI)) print("\n--- c: --------------------------------") # 1: w(0) = 0 # 2: w'(0) = 0 bc1 = Eq(w.subs(x,0), 0) bc2 = Eq(wp.subs(x,0), 0) eqns = [bc1, bc2] sol = solve(eqns, unknowns) sC1 = sol[C1] sC2 = sol[C2] for s in [sC1, sC2]: pprint(latex(s)) w = w.subs({C1: sC1, C2: sC2}) w = w.expand() w = collect(w,B_v) w = w.simplify() pprint(w*EI) pprint(latex(w*EI)) print("\n--- d: --------------------------------") (Bv0, Bv1, Bv2) = (-f22*MB/a, -f32*MB/a, -f42*MB/a) w0 = w.subs(B_v, Bv0) w1 = w.subs(B_v, Bv1) w2 = w.subs(B_v, Bv2) # normalized deflections: wn0 = w0 / ( MB*a*a / EI ) wn1 = w1 / ( MB*a*a / EI ) wn2 = w2 / ( MB*a*a / EI ) for wn in [wn0,wn1,wn2]: wn = wn.expand() wn = wn.simplify() # pprint(latex(wn)) xi = var('xi') f0 = wn0.expand().subs(x/a,xi) f1 = wn1.expand().subs(x/a,xi) f2 = wn2.expand().subs(x/a,xi) # Make array for plotting: xia = linspace(float(0),float(1)) f0 = fill_array(f0,xi,xia) f1 = fill_array(f1,xi,xia) f2 = fill_array(f2,xi,xia) # plot functions: tmp = plt.plot(xia, f0, "b-", label="$w^- \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.plot(xia, f1, "r--", label="$w \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.plot(xia, f2, "g-.", label="$w^+ \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.grid() tmp = plt.axhline(0, color='black') tmp = plt.xlabel("$x / a$") tmp = plt.legend(loc='best') plt.gca().invert_yaxis() plt.savefig("2.4.2.F_w1.svg", transparent=True) plt.show() plt.clf() print("\n--- e: --------------------------------") print("\n--- f: --------------------------------") x2 = xia**2 x3 = xia**3 wBn = 3*x2/4 - x3/4 wMn = -1*x2/2 w = wBn + wMn # plot functions: tmp = plt.plot(xia, wBn, "b-", label="$w_B \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.plot(xia, wMn, "g-.", label="$w_M \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.plot(xia, w, "r--", label="$w \\, / \\, \\frac{M^{\\mathsf{B}} a^2}{EI}$") tmp = plt.grid() tmp = plt.axhline(0, color='black') tmp = plt.xlabel("$x / a$") tmp = plt.legend(loc='best') plt.gca().invert_yaxis() plt.savefig("2.4.2.F_w2.svg", transparent=True) plt.show()
--- a: -------------------------------- --- b: -------------------------------- 3 2 B_v*x C1*x C2 x *(-B_v*a - MB) ------ + ---- + -- + ---------------- 6*EI EI EI 2*EI 2 2 B_v*x *(3*a - x) MB*x - ---------------- + C1*x + C2 - ----- 6 2 - \frac{B_{v} x^{2}}{6} \left(3 a - x\right) + C_{1} x + C_{2} - \frac{MB x^{2 }}{2} --- c: -------------------------------- 0 0 2 -x *(B_v*(3*a - x) + 3*MB) --------------------------- 6 - \frac{x^{2}}{6} \left(B_{v} \left(3 a - x\right) + 3 MB\right) --- d: --------------------------------
--- e: -------------------------------- --- f: --------------------------------