x_fit = dp.x_fit_like(t) y_fit = omega_fit(x_fit, *popt) plt.plot(x_fit, y_fit, color=lines.get_color()) delta, *_ = popt d_delta = sqrt(pcov[0, 0]) t_h = log(2) / delta d_t_h = t_h * d_delta / delta if output: print( dpr.val(delta * cs.day, d_delta * cs.day, name='δ', unit='1/d', prefix=False, exp_to_fix=0)) print( dpr.val(t_h / cs.minute, d_t_h / cs.minute, name='T_H', unit='min', prefix=False, exp_to_fix=0)) if output: fig_folder_path = 'figures/spinning_top' if not os.path.exists(fig_folder_path): os.makedirs(fig_folder_path)
i_U_max = find_peaks_cwt(U, range(1,30), noise_perc=20) i_U_max = i_U_max[U[i_U_max] > 0.0] i_U_max = i_U_max[t[i_U_max] > t_range[0]] i_U_max = i_U_max[t[i_U_max] < t_range[1]] popt, pcov = curve_fit(gauss, t[i_U_max], U[i_U_max], p0=(2.5e-3, 0.015, 0.015)) d_popt = sqrt(np.diag(pcov)) if output: x_fit = dpl.x_fit_like(t[i_U_max]) y_fit = gauss(x_fit, *popt) data_pts, *_ = plt.plot(t[i_U_max], U[i_U_max], marker='o', ls='None') plt.plot(x_fit, y_fit, color=data_pts.get_color()) if output: print(dpr.val(popt[2], d_popt[2], name='Δt', unit='s')) delta_s = v_mov * popt[2] d_delta_s = v_mov * d_popt[2] if output: print(dpr.val(delta_s, d_delta_s, name='Δs', unit='m')) L = 2 * pi * delta_s d_L = L * d_delta_s / delta_s if output: print(dpr.val(L, d_L, name='L', unit='m')) if output: fig_folder_path = 'figures/interferometer'
## Evaluation slope1, d_slope1, itc1, d_itc1 = dp.linreg(V, t, d_t) if output: plt.subplots(num=3) plt.xlabel(r'V / cm$^3$') plt.ylabel(r't / s') lines, *_ = plt.errorbar(*dp.to_units(V, t, d_t, x_unit=cs.centi**3), fmt='o') x_line = dp.x_fit_like(V) y_line, y_uline = dp.linreg_lines(x_line, slope1, d_slope1, itc1, d_itc1) plt.plot(*dp.to_units(x_line, y_line, x_unit=cs.centi**3), label='Fit', color=lines.get_color()) plt.plot(*dp.to_units(x_line, y_uline, x_unit=cs.centi**3), label='Fit uncertainty', color=lines.get_color(), ls='dashed') if output: print(dpr.val(slope1 * cs.centi**3, d_slope1 * cs.centi**3, name='slope1', unit='s / cm^3')) J = 1 / slope1 d_J = J * d_slope1 / slope1 if output: print(dpr.val(J / cs.milli**3, d_J / cs.milli**3, name='J', unit='mm^3 / s')) p_tube = h_mean * rho_peg * g d_p_tube = p_tube * sqrt((d_h_mean / h_mean)**2 + (d_rho_peg / rho_peg)**2 + (d_g / g)**2) if output: print(dpr.val(p_tube, d_p_tube, name='p_tube', unit='Pa')) eta = pi * p_tube * R**4 / (8 * J * L) d_eta = eta * sqrt((d_p_tube / p_tube)**2 + (4 * d_R / R)**2 + (d_J / J)**2 + (d_L / L)**2)
## Data procesing omega_F = 2 * pi * f_F d_omega_F = 2 * pi * d_f_F omega_N = 2 * pi * f_N d_omega_N = 2 * pi * d_f_N ## Evaluation if output: plt.subplots(num=5) plt.xlabel(r'$\omega_N$ / (1/s)') plt.ylabel(r'$\omega_F$ / (1/s)') s, d_s, b, d_b = dpl.linreg(omega_N, omega_F, d_omega_F, d_omega_N) if output: print(dpr.val(s, d_s, name='s')) if output: x_fit = dpl.x_fit_like(omega_N) y_fit, y_u_fit = dpl.linreg_lines(x_fit, s, d_s, b, d_b) dataPts, *_ = plt.errorbar(omega_N, omega_F, d_omega_F, d_omega_F, fmt='o') plt.plot(x_fit, y_fit, label='Fit', color=dataPts.get_color()) plt.plot(x_fit, y_u_fit, label='Fit uncertainty', color=dataPts.get_color(), ls='dashed') plt.legend() I_x = I_z_ * s d_I_x = I_x * sqrt((d_I_z_ / I_z_)**2 + (d_s / s)**2) if output: print(dpr.val(I_x / (cs.gram * cs.centi**2), d_I_x / (cs.gram * cs.centi**2), name='I_x', unit='g cm^2'))
lda_W = 335.0 / cs.gram V = 1.0 * cs.milli * cs.liter t1 = 335.0 d_t1 = 5.0 t2 = 565.0 d_t2 = 5.0 ## Evaluation delta_t = t2 - t1 d_delta_t = sqrt(d_t1**2 + d_t2**2) Q2 = rho_W * V * lda_W WM = UM * IM * delta_t d_WM = Q2 * sqrt((d_UM / UM)**2 + (d_IM / IM)**2 + (d_delta_t / delta_t)**2) eta_ = Q2 / WM d_eta_ = eta_ * d_WM / WM if output: print(dpr.val(delta_t, d_delta_t, name='Δt', unit='s')) print() print(dpr.val(Q2, name='Q2', unit='J')) print(dpr.val(WM, d_WM, name='WM', unit='J')) print() print(dpr.val(eta, d_eta, name='η', exp_to_fix=0)) print(dpr.val(eta_, d_eta_, name='η\'', exp_to_fix=0)) print(dpr.dev(eta, d_eta, eta_, d_eta_, name='η, η\''))
## Data processing omega_F = 2 * pi * f d_omega_F = omega_F * d_f / f Omega = 2 * pi / t d_Omega = Omega * d_t / t ## Evaluation if output: plt.subplots(num=4) plt.xlabel(r'$\Omega$ / (1/s)') plt.ylabel(r'$\omega_F$ / (1/s)') s, d_s, b, d_b = dpl.linreg(Omega, omega_F, d_omega_F, d_Omega) if output: print(dpr.val(s, d_s, name='s')) if output: x_fit = dpl.x_fit_like(Omega) y_fit, y_u_fit = dpl.linreg_lines(x_fit, s, d_s, b, d_b) dataPts, *_ = plt.errorbar(Omega, omega_F, d_omega_F, d_Omega, fmt='o') plt.plot(x_fit, y_fit, color=dataPts.get_color(), label='Fit') plt.plot(x_fit, y_u_fit, color=dataPts.get_color(), label='Fit uncertainty', ls='dashed') plt.legend() delta_I = I_z_ / (s - 1) d_delta_I = delta_I * sqrt((d_I_z_ / I_z_)**2 + (d_s / (s - 1))**2)
import datproc.print as dpr import stokes as st import hagen_poiseuille as hp print(dpr.val(st.eta, st.d_eta, name='η_st', unit='Pa s')) print(dpr.val(hp.eta, hp.d_eta, name='η_hp', unit='Pa s')) print(dpr.dev(st.eta, st.d_eta, hp.eta, hp.d_eta, name='η_st, η_hp')) Re_crit = 3 d_Re_crit = 1 Re_crit_theo = 1 print(dpr.val(Re_crit, d_Re_crit, name='Re_crit')) print(dpr.val(Re_crit_theo, name='Re_crit_theo')) print(dpr.dev(Re_crit, d_Re_crit, Re_crit_theo, name='Re_crit, Re_crit_theo'))
d_Q_V = sqrt(d_Q_el**2 + d_Q_out**2 + d_W_pV**2) P_el = Q_el * f d_P_el = P_el * sqrt((d_Q_el / Q_el)**2 + (d_f / f)**2) P_out = Q_out * f d_P_out = P_out * sqrt((d_Q_out / Q_out)**2 + (d_f / f)**2) P_pV = W_pV * f d_P_pV = P_pV * sqrt((d_W_pV / W_pV)**2 + (d_f / f)**2) eta_th = W_pV / Q_el d_eta_th = eta_th * sqrt((d_W_pV / W_pV)**2 + (d_Q_el / Q_el)**2) if output: print(dpr.val(Q_el, d_Q_el, name='Q_el', unit='J')) print(dpr.val(Q_out, d_Q_out, name='Q_out', unit='J')) print(dpr.val(W_pV, d_W_pV, name='W_pV', unit='J')) print(dpr.val(Q_V, d_Q_V, name='Q_V', unit='J')) print() print(dpr.val(P_el, d_P_el, name='P_el', unit='W')) print(dpr.val(P_out, d_P_out, name='P_out', unit='W')) print(dpr.val(P_pV, d_P_pV, name='P_pV', unit='W')) print() print(dpr.val(eta_th, d_eta_th, name='eta_th', exp_to_fix=0)) print( dpr.val(eta_th * 100, d_eta_th * 100, name='eta_th', unit='%', exp_to_fix=0))
d_v_rho_ratio = v_rho_ratio * sqrt((d_v / v)**2 + (d_rho_K**2 + d_rho_peg**2) / (rho_K - rho_peg)**2) slope1, d_slope1, itc1, d_itc1 = dp.linreg(r2, v_rho_ratio, d_v_rho_ratio, d_r2) if output: lines, *_ = plt.errorbar(*dp.to_units(r2, v_rho_ratio, d_v_rho_ratio, d_r2, x_unit=cs.milli**2, y_unit=(cs.centi**4 / cs.gram)), fmt='o') x_line = dp.x_fit_like(r2) y_line, y_uline = dp.linreg_lines(x_line, slope1, d_slope1, itc1, d_itc1) plt.plot(*dp.to_units(x_line, y_line, x_unit=(cs.milli**2), y_unit=(cs.centi**4 / cs.gram)), label='Fit', color=lines.get_color()) plt.plot(*dp.to_units(x_line, y_uline, x_unit=(cs.milli**2), y_unit=(cs.centi**4 / cs.gram)), label='Fit uncertainty', color=lines.get_color(), ls='dashed') plt.legend() if output: print(dpr.val(slope1 / (cs.centi**2 / cs.gram), d_slope1 / (cs.centi**2 / cs.gram), name='slope1', unit='cm^2 / g', prefix=False)) print() eta = 2 / 9 * g / slope1 d_eta = eta * sqrt((d_g / g)**2 + (d_slope1 / slope1)**2) if output: print(dpr.val(eta, d_eta, name='η', unit='Pa s')) v_theo = 2/9 * g * (rho_K - rho_peg) * r2 / eta d_v_theo = v_theo * sqrt((d_g / g)**2 + (d_rho_K**2 + d_rho_peg**2) / (rho_K - rho_peg)**2 + (d_r2 / r2)**2 + (d_eta / eta)**2) v__v_theo = v / v_theo d_v__v_theo = v__v_theo * sqrt((d_v / v)**2 + (d_v_theo / v_theo)**2) Re = rho_peg * v * R / eta d_Re = Re * sqrt((d_rho_peg / rho_peg)**2 + (d_v / v)**2 + (d_eta / eta)**2)
from numpy import sqrt import scipy.constants as cs import datproc.print as dpr import nutation_I_x as n1 import nutation_I_x_2 as n2 from precession_I_z import I_z_, d_I_z_ print( dpr.val(I_z_ / (cs.gram * cs.centi**2), d_I_z_ / (cs.gram * cs.centi**2), name='I_z', unit='g cm^2')) print() print( dpr.val(n1.I_x / (cs.gram * cs.centi**2), n1.d_I_x / (cs.gram * cs.centi**2), name='I_x', unit='g cm^2')) print( dpr.val(n2.I_x / (cs.gram * cs.centi**2), n2.d_I_x / (cs.gram * cs.centi**2), name='I_x', unit='g cm^2')) print(dpr.dev(n1.I_x, n1.d_I_x, n2.I_x, n2.d_I_x, name='I_x, I_x')) print(dpr.dev(n1.I_x, n1.d_I_x, I_z_, d_I_z_, name='I_x, I_z')) print(dpr.dev(n2.I_x, n2.d_I_x, I_z_, d_I_z_, name='I_x, I_z'))
f = 285.0 / cs.minute d_f = 2.0 / cs.minute ## Evaluation Q1 = c_W * rho_W * delta_T * J / f d_Q1 = Q1 * sqrt((d_delta_T / delta_T)**2 + (d_J / J)**2 + (d_f / f)**2) Q2 = UH * IH / f d_Q2 = Q2 * sqrt((d_UH / UH)**2 + (d_IH / IH)**2 + (d_f / f)**2) WM = UM * IM / f d_WM = WM * sqrt((d_UM / UM)**2 + (d_IM / IM)**2 + (d_f / f)**2) eta = Q2 / WM d_eta = eta * sqrt((d_Q2 / Q2)**2 + (d_WM / WM)**2) Q1_ = Q2 + WM d_Q1_ = sqrt(d_Q2**2 + d_WM**2) if output: print(dpr.val(Q1, d_Q1, name='Q1', unit='J')) print(dpr.val(Q2, d_Q2, name='Q2', unit='J')) print(dpr.val(WM, d_WM, name='WM', unit='J')) print() print(dpr.val(eta, d_eta, name='η', exp_to_fix=0)) print(dpr.val(eta * 100, d_eta * 100, name='eta_th', unit='%', exp_to_fix=0)) print() print(dpr.val(Q1, d_Q1, name='Q1', unit='J')) print(dpr.val(Q1_, d_Q1_, name='Q2 + WM', unit='J')) print(dpr.dev(Q1, d_Q1, Q1_, d_Q1_, name='Q1, Q2 + WM'))
r2_cum = np.cumsum(r2_) t_ = np.append(t[:67], t[68:-1] - (t[67] - t[66])) popt, pcov = curve_fit(lambda x, s, b: s * x + b, t_, r2_cum) d_popt = sqrt(np.diag(pcov)) if output: x_fit = dpl.x_fit_like(t_) y_fit, y_u_fit = dpl.linreg_lines(x_fit, popt[0], d_popt[0], popt[1], d_popt[1]) plt.subplots(num=3) plt.xlabel(r'$t$ / s') plt.ylabel(r'$r^2$ / $\mu$m$^2$') plt.plot(t_, r2_cum / cs.micro**2, marker='o', ls='None') plt.plot(x_fit, y_fit / cs.micro**2) if output: print(dpr.val(popt[0] / cs.micro**2, d_popt[0] / cs.micro**2, name='slope', unit='μm² / s')) print() D = popt[0] / 4 d_D = d_popt[0] / 4 k = 6 * pi * eta * a * D / T d_k = k * sqrt((d_eta / eta)**2 + (d_a / a)**2 + (d_D / D)**2 + (d_T / T)**2) if output: print(dpr.val(D / cs.micro**2, d_D / cs.micro**2, name='D', unit='μm²', prefix=False, exp_to_fix=0)) print(dpr.val(k, d_k, name='k', unit='J / K', prefix=False)) print(dpr.dev(k, d_k, cs.k, name='k, k_lit')) print() print(dpr.dev(D, d_D, st.D, st.d_D, name='D, D_st')) print(dpr.dev(k, d_k, st.k, st.d_k, name='k, k_st'))
## Data tl = np.array([1.03, 17.23]) d_tl = np.array([0.1, 0.1]) tr = np.array([1.41, 17.56]) d_tr = np.array([0.1, 0.1]) ## Data preparation Tl = (tl[1] - tl[0]) / 10.0 d_Tl = sqrt(d_tl[0]**2 + d_tl[1]**2) / 10.0 Tr = (tr[1] - tr[0]) / 10.0 d_Tr = sqrt(d_tr[0]**2 + d_tr[1]**2) / 10.0 omega_l = 2.0 * pi / Tl d_omega_l = omega_l * d_Tl / Tl omega_r = 2.0 * pi / Tr d_omega_r = omega_r * d_Tr / Tr omega = 0.5 * (omega_l + omega_r) d_omega = 0.5 * sqrt(d_omega_l**2 + d_omega_r**2) ## Output if __name__ == "__main__": print(dpr.val('T_L', Tl, d_Tl, unit='s')) print(dpr.val('T_R', Tr, d_Tr, unit='s')) print(dpr.val('ω_L', omega_l, d_omega_l, unit='1/s')) print(dpr.val('ω_R', omega_r, d_omega_r, unit='1/s')) print(dpr.val('ω', omega, d_omega, unit='1/s'))
delta_t = t[1:] - t[:-1] delta_x = x[1:] - x[:-1] delta_y = y[1:] - y[:-1] r2 = delta_x**2 + delta_y**2 d_delta_t = np.std(delta_t) / sqrt(len(delta_t)) delta_t = np.mean(delta_t) r2_ = np.delete(r2, 66) d_r2_mean = np.std(r2_) / sqrt(len(r2_)) r2_mean = np.mean(r2_) if output: print(dpr.val(delta_t, d_delta_t, name='Δt', unit='s')) print(dpr.val(r2_mean / cs.micro**2, d_r2_mean / cs.micro**2, name='r2', unit='μm²', prefix=False)) print() D = r2_mean / (4 * delta_t) d_D = D * sqrt((d_r2_mean / r2_mean)**2 + (d_delta_t / delta_t)**2) k = 6 * pi * eta * a * r2_mean / (4 * T * delta_t) d_k = k * sqrt((d_eta / eta)**2 + (d_a / a)**2 + (d_r2_mean / r2_mean)**2 + (d_T / T)**2 + (d_delta_t / delta_t)**2) if output: print(dpr.val(D / cs.micro**2, d_D / cs.micro**2, name='D', unit='μm^2 / s', prefix=False, exp_to_fix=0)) print(dpr.val(k, d_k, name='k', unit='J / K', prefix=False)) print(dpr.dev(k, d_k, cs.k, name='k, k_lit'))
n0 = p0 * T * lda / (2 * T0 * a * popts[:, 0]) + 1.0 d_n0 = (n0 - 1.0) * sqrt((d_T / T)**2 + (d_lda / lda)**2 + (d_a / a)**2 + (d_popts[:, 0] / popts[:, 0])**2) if output: print( dpr.tbl([ dpr.lst(n0, d_n0, name='n0', prefix=False, exp_to_fix=0), dpr.dev(n0, d_n0, n0_lit, name='n0, n0_lit') ])) n0 = np.mean(n0) d_n0 = sqrt(np.sum(d_n0**2)) / len(d_n0) if output: print(dpr.val(n0, d_n0, name='n0', prefix=False, exp_to_fix=0)) print(dpr.dev(n0, d_n0, n0_lit, name='n0, n0_lit')) if output: fig_folder_path = 'figures/interferometer' if not os.path.exists(fig_folder_path): os.makedirs(fig_folder_path) for i in plt.get_fignums(): plt.figure(i).savefig(os.path.join(fig_folder_path, 'fig' + str(i) + '.pgf'), bbox_inches='tight', pad_inches=0.0) plt.figure(i).savefig( os.path.join(fig_folder_path, 'fig' + str(i) + '.pdf')) plt.show()
plt.ylabel(r'$I_z$ / (kg cm$^2$)') ml = m * l popt, pcov = curve_fit(I_z_func, ml, I_z_, p0=(0.0025, 0.0010)) d_popt = sqrt(np.diag(pcov)) if output: x_fit = dp.x_fit_like(ml) y_fit = I_z_func(x_fit, *popt) dataPts, *_ = plt.errorbar(ml / (cs.gram * cs.centi), I_z_ / cs.centi**2, d_I_z_ / cs.centi**2, fmt='o') plt.plot(x_fit / (cs.gram * cs.centi), y_fit / cs.centi**2, color=dataPts.get_color()) if output: print(dpr.val(popt[0] / cs.centi**2, d_popt[0] / cs.centi**2, name='I_z_t', unit='kg cm^2')) print(dpr.val(popt[1] / (cs.gram * cs.centi), d_popt[1] / (cs.gram * cs.centi), name='μ', unit='g cm')) I_z_ = np.mean(I_z_) d_I_z_ = sqrt(np.sum(d_I_z_**2)) / len(m) I_z_ = popt[0] d_I_z_ = d_popt[0] if output: print(dpr.val(I_z_ / (cs.gram * cs.centi**2), d_I_z_ / (cs.gram * cs.centi**2), name='I_z', unit='g cm^2')) print(dpr.val(I_z_ / (cs.gram * cs.centi**2), d_I_z_ / (cs.gram * cs.centi**2), name='I_z_', unit='g cm^2'))
## Data lda_mfr = 532.0 * cs.nano d_lda_mfr = 1.0 * cs.nano s1 = np.array([0.0000, 0.3010, 0.6000, 0.9010, 1.2010]) * cs.milli d_s1 = np.array([0.0010, 0.0010, 0.0010, 0.0010, 0.0010]) * cs.milli s2 = np.array([3.0640, 3.3560, 3.6570, 3.9730, 4.2640]) * cs.milli d_s2 = np.array([0.0010, 0.0010, 0.0010, 0.0010, 0.0010]) * cs.milli d_s_sys = 9 * cs.micro m = np.array([11170, 11142, 11163, 11187, 11149]) d_m = np.array([50, 50, 50, 50, 50]) ## Evaluation if output: print(dpr.val(np.std(m) / sqrt(len(s1)), name='Δm_stat')) print( dpr.val(sqrt(np.sum(d_s1**2 + d_s2**2)) / len(d_s1), name='Δs_read', unit='m')) s = s2 - s1 d_s = np.std(s) / sqrt(len(s)) s = np.mean(s) m = np.mean(m) d_m = sqrt(np.sum(d_m**2)) / len(d_m) if output: print(dpr.val(s, d_s, name='s', unit='m')) print(dpr.val(m, d_m, name='m'))
import datproc.print as dpr from stokes import delta_x, delta_y ## General output = __name__ == '__main__' def normpdf(x, mu, sigma): return exp(-0.5 * (x - mu)**2 / sigma**2) / sqrt(2 * pi * sigma**2) delta_s = np.append(delta_x, delta_y) delta_s_ = np.delete(delta_s, 66) if output: print(dpr.val(delta_s[66], name='Δs[66]', unit='m')) delta_s_mu = np.mean(delta_s_) delta_s_sigma = np.std(delta_s_) if output: print(dpr.val(delta_s_mu, name='μ(Δs)', unit='m')) print(dpr.val(delta_s_sigma, name='σ(Δs)', unit='m')) if output: x_gauss = np.linspace(np.min(delta_s_), np.max(delta_s_), 1000) y_gauss = normpdf(x_gauss / cs.micro, delta_s_mu / cs.micro, delta_s_sigma / cs.micro) plt.subplots(num=2) plt.xlabel(r'$\Delta s$ / $\mu$m') plt.ylabel(r'Relative Häufigkeit')
N = 50 TL1 = 23.1 + cs.zero_Celsius TL2 = 23.3 + cs.zero_Celsius tL = 46.42 / N # 47.42 / N d_tL = 0.5 / N TAr1 = 23.4 + cs.zero_Celsius TAr2 = 23.5 + cs.zero_Celsius tAr = 46.31 / N d_tAr = 0.5 / N # Evaluation kappa_cd = h1 / (h1 - h3) d_kappa_cd = kappa_cd * sqrt((1 / h1 - 1 / (h1 - h3))**2 * d_h1**2 + d_h3**2 / (h1 - h3)**2) print(dpr.val(tL, d_tL, name='TL', unit='s', prefix=False, exp_to_fix=0)) print(dpr.val(tAr, d_tAr, name='TAr', unit='s', prefix=False, exp_to_fix=0)) print() TL = 0.5 * (TL2 + TL1) d_TL = 0.5 * (TL2 - TL1) TAr = 0.5 * (TAr2 + TAr1) d_TAr = 0.5 * (TAr2 - TAr1) pL = 0.5 * (pL2 + pL1) d_pL = 0.5 * (pL2 - pL1) print(dpr.val(pL, d_pL, name='pL', unit='Pa')) print() kappa_rL = 4 * m * V / (r**4 * tL**2 * pL) d_kappa_rL = kappa_rL * sqrt((d_m / m)**2 + (d_V / V)**2 + (4 * d_r / r)**2 +