import matplotlib
if not hasattr(matplotlib.RcParams, "_get"):
matplotlib.RcParams._get = dict.get
Opgave 4#
Gegeven is de volgende constructie:
Fig. 226 #
Vind de verplaatsing in \(\rm{C}\) en halverwege \(\rm{AB}\).
Opgave
Maak de opdracht in WebLab. Heb je nog geen toegang? Schrijf je dan eerst hier in voor dit vak op WebLab.
Je kan je antwoord op de vragen in de volgende opgaves invoeren. Maar om je code te checken klik je op ‘Check’ in WebLab.
Opgave
Wat is zijn de verplaatsingen in \(\rm{mm}\)?
Uitwerking
import sympy as sym
sym.init_printing(use_latex='mathjax')
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display as ipy_display, Math
%config InlineBackend.figure_formats = ['svg']
def display(*objs):
for obj in objs:
if isinstance(obj, dict):
lines = [f"{sym.latex(k)} &= {sym.latex(obj[k])}" for k in sorted(obj, key=lambda s: str(s))]
ipy_display(Math(r"\begin{aligned}" + r"\\ ".join(lines) + r"\end{aligned}"))
else:
ipy_display(obj)
def plot(w_list, x_range_list,ylabel):
fig = plt.figure(facecolor='none')
for i, w in enumerate(w_list):
# check if x is the only symbol in the expression
if len(w.free_symbols) > 1:
raise ValueError('The expression must be a function of x only.')
w_numpy = sym.lambdify(x, w)
x_vals = np.linspace(x_range_list[i][0], x_range_list[i][1], 100)
# if the expression is a constant, we need to make sure that it is broadcasted correctly
if isinstance(w_numpy(x_vals),float) or isinstance(w_numpy(x_vals),int):
w_numpy = np.vectorize(w_numpy)
plt.plot(x_vals,w_numpy(x_vals))
plt.xlabel('$x$')
plt.ylabel(ylabel)
ax = plt.gca()
ax.set_facecolor('none')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.spines['bottom'].set_position('zero')
ax.spines['left'].set_position('zero')
ax.invert_yaxis()
import sympy as sym
sym.var('x')
sym.var('C1, C2, C3, C4');
q1 = -8
q2 = 0
N1 = sym.integrate(-q1,x)+C1
epsilon1 = N1 / 20000
u1 = sym.integrate(epsilon1,x)+C2
N2 = sym.integrate(-q2,x)+C3
epsilon2 = N2 / 20000
u2 = sym.integrate(epsilon2,x)+C4
Eq1 = sym.Eq( u1.subs(x, 0), 0)
Eq2 = sym.Eq( u1.subs(x, 4), 0)
Eq3 = sym.Eq( u2.subs(x, 4), 0)
Eq4 = sym.Eq( N2.subs(x, 9), 20)
sol = sym.solve((Eq1, Eq2, Eq3, Eq4), (C1, C2, C3, C4))
display(sol)
\[\begin{split}\displaystyle \begin{aligned}C_{1} &= -16\\ C_{2} &= 0\\ C_{3} &= 20\\ C_{4} &= - \frac{1}{250}\end{aligned}\end{split}\]
u1_oplossing = u1.subs(sol)
u2_oplossing = u2.subs(sol)
plot([u1_oplossing,u2_oplossing], [(0, 4),[4,9]], 'u(x)')
u_2 = u1_oplossing.subs(x, 2)*1000 # mm
u_9 = u2_oplossing.subs(x, 9)*1000 # mm
display(u_2)
display(u_2.evalf())
display(u_9)
\[\displaystyle - \frac{4}{5}\]
\[\displaystyle -0.8\]
\[\displaystyle 5\]