<jupyter_start><jupyter_text>Kinematika togega telesaProf. dr. <NAME>, Univerza v Ljubljani, Fakulteta za strojništvo Vrtilna količina - vektorski izračun<jupyter_code>import sympy as sym
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
sym.init_printing()<jupyter_output><empty_output><jupyter_text>Če uporabite Google Colab, potem odkomentirajte (odstranite ) spodnje vrstice in jih sprožite:<jupyter_code>#def custom_latex_printer(exp,**options):
#    from google.colab.output._publish import javascript
#    url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=default"
#    javascript(url=url)
#    return sym.printing.latex(exp,**options)
#sym.init_printing(use_latex="mathjax",latex_printer=custom_latex_printer)<jupyter_output><empty_output><jupyter_text>Definirajmo simbole:<jupyter_code>ωx, ωy, ωz, m = sym.symbols("omega_x, omega_y, omega_z m")
x = sym.Function('x')(m)
y = sym.Function('y')(m)
z = sym.Function('z')(m)<jupyter_output><empty_output><jupyter_text>in vektorje:<jupyter_code>r = sym.Matrix([[x], [y], [z]])
ω = sym.Matrix([[ωx], [ωy], [ωz]])
r
ω<jupyter_output><empty_output><jupyter_text>Želimo izračunati:$$\boldsymbol{L}=\int_m \boldsymbol{r}\times\boldsymbol{\omega}\times\boldsymbol{r}\,\,\textrm{d}m$$Izračunajmo podintegralsko funkcijo<jupyter_code>B = r.cross(ω.cross(r))
B<jupyter_output><empty_output><jupyter_text>Ker je kotna hitrost $\boldsymbol{\omega}$ konstantna za vse masne delce, jo lahko izpostavimo. Poglejmo si najprej za prvo vrstico $B$:<jupyter_code>B[0]
B[0].expand().coeff(ωx)
B[0].expand().coeff(ωy)
B[0].expand().coeff(ωz)<jupyter_output><empty_output><jupyter_text>In sedaj posplošimo:<jupyter_code>L = sym.Matrix([[w*sym.integrate(b.expand().coeff(w),m) for w in ω] for b in B])
L<jupyter_output><empty_output><jupyter_text>Iz zapisa je jasno, da je smiselno zapisati masni vztrajnostni tenzor (pri togem telesu je konstanta) kot:  Masni vztrajnostni moment trikotne plošče(V mapi `\ostalo\` se nahaja SolidWorks datoteka obravnavane plošče; preverite MVM v modelu!)  Simboli<jupyter_code>a, b, h, x, y, ρ, m = sym.symbols('\
a, b, h, x, y, rho, m')<jupyter_output><empty_output><jupyter_text>Podatki<jupyter_code>podatki = {a: 1, b:2, h: 0.01, ρ: 2700}<jupyter_output><empty_output><jupyter_text>Funkcija stranica:<jupyter_code>fx = a - a/b*y<jupyter_output><empty_output><jupyter_text>Priprava numeričnih podatkov:<jupyter_code>fxp = sym.lambdify(y, fx.subs(podatki), 'numpy')
y_n = np.linspace(0, podatki[b], 10)
x_n = fxp(y_n)
y_n = np.append(y_n, 0.) # zaradi prikaza dodamo 0 na koncu
x_n = np.append(x_n, 0.) # zaradi prikaza dodamo 0 na koncu<jupyter_output><empty_output><jupyter_text>Prikažimo trikotnik<jupyter_code>ax = plt.subplot(111)
plt.fill(x_n[::-1], y_n[::-1], alpha=0.3, closed=True)
ax.axis('equal')
plt.grid(True)
plt.xlim(-.1, podatki[a]+0.1)
plt.ylim(-.1, podatki[b]+0.1)
plt.show()<jupyter_output><empty_output><jupyter_text>Masni vztrajnostni momenti (integriramo: $y^2 \, f(x)\,\rho\,h$)<jupyter_code>J_xx = sym.integrate(y**2 * fx * ρ * h, (y, 0, b))
J_xx<jupyter_output><empty_output><jupyter_text>Vpeljemo maso $m$:<jupyter_code>J_xx = J_xx.subs(h*r*a*b/2, m)
J_xx<jupyter_output><empty_output><jupyter_text>Na podlagi rezultata $J_{xx}$, definiramo še $J_{yy}$ in nato $J_{zz}$:<jupyter_code>J_yy = J_xx.subs(b,a)
J_zz = J_xx + J_yy<jupyter_output><empty_output><jupyter_text>Izvedemo še integral za deviacijske MVM, najprej $J_{xy}=\int_0^{b}\left(\int_0^{f(x)} x\,y\,h\,\rho\, \textrm{d}x\right)\textrm{d}y$:<jupyter_code>J_xy = sym.integrate( sym.integrate(x*y * h * r, (x, 0, fx)), (y, 0, b)).subs(h*r*a*b/2, m)
J_xy<jupyter_output><empty_output><jupyter_text>Ker je telo simetrično glede na ravnini $xz$ in $yz$, sta naslednja MVM enaka nič:<jupyter_code>J_xz = 0
J_yz = 0<jupyter_output><empty_output><jupyter_text>Matrika MVM torej je:<jupyter_code>J = sym.Matrix([[+J_xx, -J_xy, -J_xz],
                [-J_xy, +J_yy, -J_yz],
                [-J_xz, -J_yz, +J_zz]])
J<jupyter_output><empty_output><jupyter_text>Numerične vrednosti:<jupyter_code>Jnum = np.array(J.subs(m, h*r*a*b/2).evalf(subs=podatki), dtype=float)
Jnum<jupyter_output><empty_output><jupyter_text>Sedaj lahko izračunamo glavne MVM:<jupyter_code>eig = J.eigenvects()
eig<jupyter_output><empty_output><jupyter_text>Ali v numerični obliki:<jupyter_code>eig = np.linalg.eig(Jnum)
eig<jupyter_output><empty_output><jupyter_text>Glavni MVM v numerični obliki so:<jupyter_code>eig[0]<jupyter_output><empty_output><jupyter_text>In pripadajoči lastni vektorji (stolpci):<jupyter_code>eig[1]
ax = plt.subplot(111)
plt.fill(x_n[::-1], y_n[::-1], alpha=0.3, closed=True)
ax.axis('equal')
plt.grid(True)
plt.xlim(-1.1, podatki[a]+1.1)
plt.ylim(-1.1, podatki[b]+1.1)
ax.quiver(0,0,eig[1][0,0], eig[1][0,1],angles='xy',scale_units='xy',scale=1)#prvi vektor
ax.quiver(0,0,eig[1][1,0], eig[1][1,1],angles='xy',scale_units='xy',scale=1)#drugi vektor
plt.show()
eig[0]
eig[1][1]<jupyter_output><empty_output><jupyter_text>Zvrnitev osi - izpeljava Izpeljava zvrnitve osi; definirajmo najprej simbole:<jupyter_code>Lx, Ly, Lz, x, y, z = sym.symbols("lambda_x, lambda_y, lambda_z, x, y, z")<jupyter_output><empty_output><jupyter_text>Vektor lege $\mathbf{r}$ in vektor zvrnjene osi: $\mathbf{\lambda}$:<jupyter_code>r = sym.Matrix([[x], [y], [z]])
L = sym.Matrix([[Lx], [Ly], [Lz]])
r
L<jupyter_output><empty_output><jupyter_text>Podintegralska funkcija je:<jupyter_code>tmp1 = r.cross(L).dot(r.cross(L))
tmp1
tmp2 = tmp1.expand()
tmp2<jupyter_output><empty_output><jupyter_text>Opzimo, da konstantne člene $\lambda$ lahko izpostavimo in ostanejo členi, ki definirajo MVM:<jupyter_code>tmp2.coeff(-2*Lx*Ly)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17199790246460409, 'fraction_numerical': 0.016255899318300997, 'mean_word_length': 7.816640986132511, 'pattern_counts': {'":': 0, '<': 110, '<?xml version=': 0, '>': 110, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '27', 'dir': 'jupyter-structured-clean-dedup', 'id': '451629', 'license': 'MIT', 'n_tokens_mistral': 2751, 'n_tokens_neox': 2696, 'n_words': 397, 'path': '02 - Kinetika togega telesa.ipynb', 'repo_name': 'jankoslavic/TM2', 'size': '5727'}