import numpy as np import matplotlib.pyplot as plt import scipy.stats as ss import scipy.optimize as scp import puk as puk # fig, ax = plt.subplots(figsize = (16,8)) puk1 = puk.Puk(['Uelastisk/KastetCenter', 'Uelastisk/KastetSide'], 0.0569, 0.0435) puk2 = puk.Puk(['Uelastisk/StilleCenter', 'Uelastisk/StilleSide'], 0.0285, 0.0432) def findColUelastisk(puk1, puk2): ts = puk1.get_center(0) xs1 = puk1.get_center(1) ys1 = puk1.get_center(2) xs2 = puk2.get_center(1) ys2 = puk2.get_center(2) t_point = 0 i = 0 #Tjek om de to radier er tæt nok på hinanden til at de har kollideret, hvor efter t-værdiens #index retuneres for t in ts: r1 = np.array(xs1[i], ys1[i]) r2 = np.array(xs2[i], ys2[i]) if (np.linalg.norm(r2 - r1) <= puk1.get_r() + puk2.get_r()): t_point = i else: i += 1 return t_point
import puk as puk import matplotlib.pyplot as plt from matplotlib import animation, rc fig, ax = plt.subplots(figsize=(8, 8)) Rota_Kastet = puk.Puk(['Rota/KastetCenter', 'Rota/KastetSide'], 1, 1) Rota_Stille = puk.Puk(['Rota/StilleCenter', 'Rota/StilleSide'], 1, 1) Rota_Kastet = puk.Puk(['Elastisk/KastetCenter', 'Elastisk/KastetSide'], 1, 1) Rota_Stille = puk.Puk(['Elastisk/StilleCenter', 'Elastisk/StilleSide'], 1, 1) puks = [Rota_Kastet, Rota_Stille] def pukanim(puks, ax): N = len(puks[0].get_center(0)) color = ['bo', 'ro', 'ko', 'ko'] puk11 = ax.plot(puks[0].get_center(1)[0], puks[0].get_center(2)[0], color[0], label='Puk distance', ms=18)[0] puk21 = ax.plot(puks[1].get_center(1)[0], puks[1].get_center(2)[0], color[1], label='Puk distance', ms=18)[0] puk12 = ax.plot(puks[0].get_edge(1)[0], puks[0].get_edge(2)[0],
import numpy as np import matplotlib.pyplot as plt import puk as puk import fejlpropagering as fejl import chi_sq as chi fig, ax = plt.subplots(figsize = (30,15)) strings = ['Data0', 'Data2', 'Data4'] trials = [] trials.append([puk.Puk(['Rota/KastetCenter', 'Rota/KastetSide'], 0.0278, 0.0807), puk.Puk(['Rota/StilleCenter', 'Rota/StilleSide'], 0.0278, 0.0807)]) colors = ['r', 'b', 'g', 'k--'] a = [] a.append(puk.plot_Puks_angular_momentum(trials[0], ax, colors, alpha = 0.6)) ax.set_xlabel('t/s', fontsize = 20) ax.set_ylabel('L', fontsize = 20) ax.set_title('Impulsmoment over tid', fontsize = 24) ax.legend() plt.show() fig.savefig('rota_impuls')
import numpy as np import matplotlib.pyplot as plt import puk as puk import fejlpropagering as fejl import chi_sq as chi fig, ax = plt.subplots(figsize=(30, 15)) strings = ['Data0', 'Data2', 'Data4'] trials = [] trials.append([ puk.Puk(['Rota/KastetCenter', 'Rota/KastetSide'], 0.0278, 0.0807), puk.Puk(['Rota/StilleCenter', 'Rota/StilleSide'], 0.0278, 0.0807) ]) colors = ['r', 'b', 'g', 'k--'] a = [] a.append(puk.plot_Puks_energy(trials[0], ax, colors, alpha=0.6)) ax.set_xlabel('t/s', fontsize=20) ax.set_ylabel('E', fontsize=20) ax.set_title('Energi_over tid', fontsize=24) ax.legend() plt.show() fig.savefig('rota_energi')
import numpy as np import puk as puk import matplotlib.pyplot as plt import scipy.optimize as scp fig, ax = plt.subplots() puk1 = puk.Puk(['Elastisk/StilleCenter', 'Elastisk/StilleSide'], 0.0278, 0.0807) puk2 = puk.Puk(['Elastisk/KastetCenter', 'Elastisk/KastetSide'], 0.0278, 0.0807) puk3 = puk.Puk(['Rota/KastetCenter', 'Rota/KastetSide'], 0.0278, 0.0807) puk4 = puk.Puk(['Rota/StilleCenter', 'Rota/StilleSide'], 0.0278, 0.0807) def linear(t, a, b): return a * t + b def findcol(Puk): xs = Puk.center[:, 1] ts = Puk.center[:, 0] ax.scatter(ts, xs) curve1 = [ts[:8], xs[:8]] inte = len(xs) - 8 curve2 = [ts[inte:], xs[inte:]] popt1, cov1 = scp.curve_fit(linear, curve1[0], curve1[1], absolute_sigma=True) popt2, cov2 = scp.curve_fit(linear, curve2[0], curve2[1],
import numpy as np import puk as puk Rota_Kastet = puk.Puk(['Data/Data0/KastetCenter', 'Data/Data0/KastetSide'], 1, 1) Rota_Stille = puk.Puk(['Data/Data0/StilleCenter', 'Data/Data0/StilleSide'], 1, 1) puks = [Rota_Kastet, Rota_Stille] def b_vardi(puks): angle = np.arctan2(puks[0].y_velocity()[0], puks[0].x_velocity()[0]) puk1 = np.array(puks[0].get_center(2) * np.cos(angle) - puks[0].get_center(1) * np.sin(angle)) puk2 = np.array(puks[1].get_center(2) * np.cos(angle) - puks[1].get_center(1) * np.sin(angle)) t = puks[0].col_t() b = sum(puk1[:t]) / t - sum(puk2[:t]) / t print(len(puk1[:t]), t) print(puk1[:t]) return b print(b_vardi(puks))
import numpy as np import matplotlib.pyplot as plt import puk as puk import fejlpropagering as fejl import chi_sq as chi fig, ax = plt.subplots(2, 2, figsize=(30, 15)) ax = ax.ravel() strings = ['Data0', 'Data2', 'Data4'] trials = [] for s in strings: trials.append([ puk.Puk(['Data/' + s + '/KastetCenter', 'Data/' + s + '/KastetSide'], 0.0278, 0.0807), puk.Puk(['Data/' + s + '/StilleCenter', 'Data/' + s + '/StilleSide'], 0.0278, 0.0807) ]) colors = ['r', 'b', 'g', 'k--'] a = [] for t, ax in zip(trials, ax): a.append(puk.plot_Puks_energy(t, ax, colors, alpha=0.6)) def tot_angu_err(Puks): return np.sqrt(Puks[0].angu_err()**2 + Puks[1].angu_err()**2)
import numpy as np import matplotlib.pyplot as plt import scipy.stats as ss import scipy.optimize as scp from matplotlib import animation, rc import puk as puk from scipy.integrate import solve_ivp rc('animation', html='jshtml') fig, ax = plt.subplots() puk2 = puk.Puk(['Rota/KastetCenter', 'Rota/KastetSide'], 0.0278, 0.04035) puk1 = puk.Puk(['Rota/StilleCenter', 'Rota/StilleSide'], 0.0278, 0.04035) r02 = [puk2.get_center(1)[0], puk2.get_center(2)[0]] r01 = [puk1.get_center(1)[0], puk1.get_center(2)[0]] I = 1 / 2 * 0.0278 * 0.04035**2 R = 0.04035 m = 0.0278 def findv0(puk): xs = puk.get_center(1)[:5] ys = puk.get_center(2)[:5] ts = puk.get_center(0)[:5] angs = puk.angle()[:5] f = lambda x, a, b: a * x + b popt1, cov1 = scp.curve_fit(f, ts, xs, absolute_sigma=True) popt2, cov2 = scp.curve_fit(f, ts, ys, absolute_sigma=True) popt3, cov3 = scp.curve_fit(f, ts, angs, absolute_sigma=True) return [popt1[0], popt2[0], popt3[0]] v01 = findv0(puk1)