3.1.3.F
Gegeben: \(g = 9{,}81 \, \tfrac{\mathrm m}{\mathrm{s}^2}\) sowie \(v, h, \alpha.\)
Untersuchen Sie verschiedene Kombinationen von \(v, h, \alpha\), z.B.:
Berechnen Sie verschiedene Größen, und vergleichen Sie:
Berechnen Sie (gerundet auf \(0{,}01\) in SI-Einheiten):
\(t_R\)
\(R\)
\(t_H\)
\(H\)
Machen Sie eine Wertetabelle, und zeichnen Sie \(y(x)\) und \(y(t)\).
Source Code eines Programms dazu: Programm ausführen? Dazu: Copy: Source Code in die Zwischenablage kopieren. Paste: Source Code ins Eingabefeld hinter Play: Knopf SymPy
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
from sympy.physics.units import kg, m, s
from numpy import linspace
from sympy import pi, S, var, cos, sin, tan, sqrt, pprint
# Units:
N = kg*m/s**2
k, M, G = 10**3, 10**6, 10**9
kN = k*N
Pa = N/m**2
MPa, GPa = M*Pa, G*Pa
deg = pi/180
half = S(1)/2
# Rounding:
def iso_round(x, pv):
try:
x = float(x)
tmp = round(x, pv)
except TypeError:
from functools import partial
func = partial(round, ndigits = pv)
tmp = x.applyfunc(func)
return tmp
# ---
g = var("g")
v = var("v")
h = var("h")
alpha = var("alpha")
# Given Quantities:
this_g = S(981)/100 * m/s**2
this_v = 12 * m/s
this_h = 0 *m
this_alpha = 70 * deg
sub_list=[
( g , this_g ),
( v , this_v ),
( h , this_h ),
( alpha , this_alpha ),
]
# Output Precision:
prec = 2
# Shortcuts:
v2 = v*v
h2 = h*h
ca, sa, ta = cos(alpha), sin(alpha), tan(alpha)
ca2 = ca**2
sa2 = sa**2
c1 = 2*h*g / v2
c2 = v2 / g
pprint("\ntR / s:")
xi = sa2 + c1
tR = v/g * (sa + sqrt(xi))
tmp = tR.subs(sub_list)
tmp /= s
tR_float = float(tmp)
tmp = iso_round(tmp, prec)
pprint(tmp)
pprint("\nR / m:")
R = v*ca*tR
tmp = R
tmp = tmp.subs(sub_list)
tmp /= m
R_float = float(tmp)
tmp = iso_round(tmp, prec)
pprint(tmp)
pprint("\ntH / s:")
tH = v/g * sa
tmp = tH.subs(sub_list)
tmp /= s
tmp = iso_round(tmp, prec)
pprint(tmp)
pprint("\nH / m:")
H = c2/2 * xi
tmp = H
tmp = tmp.subs(sub_list)
tmp /= m
H_float = float(tmp)
tmp = iso_round(tmp, prec)
pprint(tmp)
# Plotting y(x):
x = var("x")
y = - g / (2*v2*ca2)*x**2 + ta*x + h
y = y.subs(sub_list)
xia = linspace(float(0), R_float, endpoint=True)
yia = []
for xi in xia:
yi = y.subs(x, xi*m)
yi /= m
yi = float(yi)
yia.append(yi)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_xlim(0, R_float)
ax1.set_ylim(0, H_float)
ax2 = ax1.twiny()
locs, labels = plt.xticks()
ax1.plot(xia,yia, "r--")
ax1.set_xlabel(r"$x \,\, / \,\, \mathrm{m}$")
ax2.set_xlabel(r"$t \,\, / \,\, \mathrm{s}$")
ax1.set_ylabel(r"$y \,\, / \,\, \mathrm{m}$")
new_tick_locations = linspace(0, R_float, 6)
scale = float(this_v / (m/s) * cos(this_alpha))
def tick_function(x):
t = x/scale
return ["%.2f" % ti for ti in t]
ax2.set_xlim(ax1.get_xlim())
ax2.set_xticks(new_tick_locations)
ax1.set_xticks(new_tick_locations)
ax2.set_xticklabels(tick_function(new_tick_locations))
ax1.set_xticklabels(tick_function(new_tick_locations))
ax1.xaxis.set_major_formatter(FormatStrFormatter('%.2f'))
plt.grid()
plt.savefig("plot.svg")
plt.show()
[ ]: einfügen.▶ drücken.