[30, 30, 30, 30, 30, 30, 30, 60, 120, 120, 120, 120, 120, 120, 300]) d = npfarray( [0, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.9]) N = npfarray( [1196, 677, 449, 289, 189, 143, 78, 86, 123, 91, 61, 68, 65, 42, 131]) N_err = sqrt(N) N_t_ratio = N / t - ug_1s N_t_ratio_err = sqrt((N_err / t)**2 + ug_1s_err**2) pltext.initplot(num=1, title=r'Abbildung : Absoprtion $\beta$-Strahlung', xlabel='Dicke in mm', ylabel='Ereignisse pro Sekunde', scale='linlog') pltext.plotdata(d, N_t_ratio, N_t_ratio_err, label='Messwerte') pltext.set_layout(xlim=(-0.2, 5.2), ylim=(1e-2, 6e1)) pltext.initplot(num=2, title=r'Abbildung : Absoprtion $\beta$-Strahlung', xlabel='Dicke in mm', ylabel='Ereignisse pro Sekunde', scale='linlin') pltext.plotdata(d[-6:], N_t_ratio[-6:], N_t_ratio_err[-6:], label='Messwerte') [slope, dslope, yitc, dyitc] = linreg(d[-6:], N_t_ratio[-6:], N_t_ratio_err[-6:], plot=True, prange=(2.5, 5)) pltext.set_layout(xlim=(2.5, 5), ylim=(-0.15, 0.5))
Vss = npfarray([0.3,1.0]) / 10 Vss_dsys = npfarray([5e-3,20e-3]) / 10 V_A1 = U_A1 / Vss[0] V_A1_dsys = 1/Vss[0] * sqrt(U_A1_dsys**2 + (U_A1 * Vss_dsys[0] / Vss[0])**2) V_A2 = U_A2 / Vss[0] V_A2_dsys = 1/Vss[0] * sqrt(U_A2_dsys**2 + (U_A2 * Vss_dsys[0] / Vss[0])**2) V_A3 = U_A3 / Vss[1] V_A3_dsys = 1/Vss[1] * sqrt(U_A3_dsys**2 + (U_A3 * Vss_dsys[1] / Vss[1])**2) V_A4 = U_A4 / Vss[1] V_A4_dsys = 1/Vss[1] * sqrt(U_A4_dsys**2 + (U_A4 * Vss_dsys[1] / Vss[1])**2) V_A5 = U_A5 / Vss[1] V_A5_dsys = 1/Vss[1] * sqrt(U_A5_dsys**2 + (U_A5 * Vss_dsys[1] / Vss[1])**2) pltext.initplot(num=1,title='Abbildung : Frequenzgang des Verstärkers (Spannung)',xlabel='Frequenz in Hz',ylabel='Spannung in V',scale='loglog') pltext.plotdata(f_1,U_A1,U_A1_dsys,f_1_dsys,label='680k',caps=False) pltext.plotdata(f_1,U_A2,U_A2_dsys,f_1_dsys,label='274k',caps=False) pltext.plotdata(f_1,U_A3,U_A3_dsys,f_1_dsys,label='48k7',caps=False) pltext.plotdata(f_1,U_A4,U_A4_dsys,f_1_dsys,label='48k7 mit 560pF Parallelkapazität',caps=False) pltext.plotdata(f_2,U_A5,U_A5_dsys,f_2_dsys,label='48k7 mit 47nF Eingangskapazität',caps=False) pltext.set_layout(legend=True,xlim=(260,3.4e5),ylim=(3e-2,8)) pltext.initplot(num=2,title='Abbildung : Frequenzgang des Verstärkers (Verstärkung)',xlabel='Frequenz in Hz',ylabel='Verstärkung',scale='loglog') pltext.plotdata(f_1,V_A1,V_A1_dsys,f_1_dsys,label='680k',caps=False,connect=True) pltext.plotdata(f_1,V_A2,V_A2_dsys,f_1_dsys,label='274k',caps=False,connect=True) pltext.plotdata(f_1,V_A3,V_A3_dsys,f_1_dsys,label='48k7',caps=False,connect=True) pltext.plotdata(f_1,V_A4,V_A4_dsys,f_1_dsys,label='48k7 mit 560pF Parallelkapazität',caps=False,connect=True) pltext.plotdata(f_2,V_A5,V_A5_dsys,f_2_dsys,label='48k7 mit 47nF Eingangskapazität',caps=False,connect=True) pltext.set_layout(legend=True,xlim=(260,3.4e5),ylim=(3e-1,3e2)) print()
return B * A_i * N_i * 2 * pi * 100 * cos(w * deg_to_rad) w_array = nplinspace(-10, 100) popt_3a, pcov_3a = curve_fit(fitfunc_3a, w_3a, Uind_3a, sigma=Uind_3a_dsys) B_3a = popt_3a[0] B_3a_dsys = sqrt(pcov_3a[0][0]) pltext.initplot( num=3, title='Abbildung : Induktionsspannung als Funktion des Winkels', xlabel='Winkel in deg', ylabel='Induktionsspannung in V') plt.plot(w_array, fitfunc_3a(w_array, *popt_3a), label=' Fit') pltext.plotdata(w_3a, Uind_3a, Uind_3a_dsys, w_3a_dsys, label=' Measurements') pltext.set_layout(legend=True, xlim=(-10, 100), ylim=(0, 0.8)) print('\nAufgabe 3a:\n') print(val(B_3a, B_3a_dsys, 'B')) # Aufgabe 3b f_3b = npfarray([ 20.3, 40.4, 60.2, 80.1, 100.2, 120.0, 142.3, 165.0, 180.3, 200.5, 404.5, 595.5, 802.5, 1006, 1206, 1404, 1603, 1784, 2025 ]) f_3b_dsys = npfarray([ 0.1, 0.1, 0.2, 0.1, 0.3, 0.2, 0.2, 0.3, 0.3, 0.2, 0.3, 0.4, 1.5, 2, 2, 2, 3, 4, 3 ]) Vss_ind_3b = npfarray([
fgr_fgang = npfarray([3.16, 3.58]) * 1e3 fgr_fgang_dsys = npfarray([0.15, 0.15]) * 1e3 fgr_fgang_mv = mv(fgr_fgang) fgr_fgang_mv_dtot = dtot_mv(fgr_fgang, fgr_fgang_dsys) fgr_calc = 1 / (2 * pi * R_A3 * C_A3) fgr_calc_dsys = 1 / (2 * pi * R_A3 * C_A3) * sqrt((R_A3_dsys / R_A3)**2 + (C_A3_dsys / C_A3)**2) f_array = linspace(1e3, 10e3, 1000) pltext.initplot(num=1, title='Abbildung : Phase in Abhängigkeit der Frequenz', xlabel='Frequenz in Hz', ylabel='Phase in rad', scale='loglin') pltext.plotdata(f_A3, Phi, Phi_dsys, label='gemessene Phase') plt.plot([1e3, 10e3], [pi / 4, pi / 4], label='45°') plt.plot(f_array, phase_b(f_array), label='berechnet') plt.plot(f_array, phase_b_dys(f_array), label='berechnet, Fehler') plt.legend() print() print('Aufgabe 3:\n') print( tbl([['Messgröße', 'bei 45° Phase', 'Frequenzgang', 'berechnet'], lst([fgr_phase, fgr_fgang_mv, fgr_calc], [fgr_phase_dsys, fgr_fgang_mv_dtot, fgr_calc_dsys], 'f_gr in Hz')])) print( sig('Phase/Fgang', fgr_phase, fgr_phase_dsys, fgr_fgang_mv, fgr_fgang_mv_dtot))
slope_dtot = sqrt(pcov[0][0]) yitc_dtot = sqrt(pcov[1][1]) vert_D = slope / 4. vert_D_dtot = slope_dtot / 4. vert_kB = 6. * pi * nu * r_k * vert_D / T_mv vert_kB_dtot = 6. * pi / T_mv * sqrt((nu_dsys * r_k * vert_D)**2 + (nu * r_k_dsys * vert_D)**2 + (nu * r_k * vert_D_dtot)**2 + (nu * r_k * vert_D * T_dtot / T_mv)**2) pltext.initplot(num=3, title='Kumulative Verteilung der Verschiebungsquadrate', xlabel='Zeit in s', ylabel='Summe $r_i^2$ in μm') pltext.plotdata(t[:-1], r_kum) plt.plot(t[:-1], lin(t[:-1], slope, yitc), label='Ausgleichsgerade') plt.plot(t[:-1], lin(t[:-1], slope - slope_dtot, yitc + yitc_dtot), label='Fehlergerade') plt.xlim(0.0, 177.0) plt.ylim(-0.04e-10, 2.20e-10) plt.legend(loc='upper left') plt.savefig('fig3.pdf', format='pdf') print() print('Kumulative Verteilung:') print(val('Steigung', slope, slope_dtot)) print(val('Diffusionskonstante D', vert_D, vert_D_dtot)) print(val('Bolatzmannkonstante k', vert_kB, vert_kB_dtot))
chi2_pf = chi2stat.chi2(N_ag, N_ag_err, fitfunc_pf(t, *p_opt_pf)) chi2_red_pf = chi2stat.chi2_red(chi2_pf, len(N_ag), ddof=4) prob_pf = chi2stat.fit_prob(chi2_pf, len(N_ag), ddof=4) chi2_mf = chi2stat.chi2(N_ag, N_ag_err, fitfunc_mf(t, *p_opt_mf)) chi2_red_mf = chi2stat.chi2_red(chi2_mf, len(N_ag), ddof=4) prob_mf = chi2stat.fit_prob(chi2_mf, len(N_ag), ddof=4) t_array = nplinspace(0, 400) pltext.initplot(num=1, title='Abbildung : Zerfall von Silber', xlabel='Zeit in s', ylabel='# Zerfälle (mit Untergrund)', scale='linlog') pltext.plotdata(t, N_ag, N_ag_err, label='Messwerte') plt.plot(t_array, fitfunc(t_array, *p_opt), label='Fit') plt.plot(t_array, fitfunc_pf(t_array, *p_opt_pf), label='Fit + Fehler Ug') plt.plot(t_array, fitfunc_mf(t_array, *p_opt_mf), label='Fit - Fehler Ug') pltext.set_layout(xlim=(0, 4e2), ylim=(2e1, 4e2)) print('\nSilber:\n') print(val(unterg_ag_mv, unterg_ag_mv_dsto, name='Untergrund')) print() print( tbl([['', 'A1', 'l1', 'A2', 'l2'], [ 'Fitwerte', val(p_opt[0], p_err[0]), val(p_opt[1], p_err[1]), val(p_opt[2], p_err[2]),
# measure version 1.9.2s from measure import plt, pltext, linreg, sqrt, val, sin, cos, h as h_lit, NA as NA_lit, c, e, deg_to_rad, rad_to_deg, dev, arcsin, spcurvefit, exp, pi, nplinspace, ln, tbl, lst, npfarray, mv, dtot_mv, loadtxt # Aufgabe 1a alpha, rate = loadtxt('data/255_1a.txt', unpack=True) rate_err = sqrt(rate) pltext.initplot(num=1, title='Abbildung : Zählrate als Funktion des Winkels (LiF)', xlabel='Winkel in deg', ylabel='Zählrate in 1/s') pltext.plotdata(alpha, rate, rate_err, label='Messwerte', connect=True) pltext.set_layout(xlim=(2, 22.5), ylim=(-0.1e3, 1.6e3)) pltext.initplot(num=2, title='Abbildung : Zählrate als Funktion des Winkels (LiF)', xlabel='Winkel in deg', ylabel='Zählrate in 1/s') pltext.plotdata(alpha, rate, rate_err, label='Messwerte') [slope, slope_err, yitc, yitc_err] = linreg(alpha[12:18], rate[12:18], rate_err[12:18], plot=True, prange=(4, 7)) pltext.set_layout(xlim=(4, 7), ylim=(-100, 400)) a1_uncorr = -yitc / slope * deg_to_rad a1_uncorr_err = 1 / slope * sqrt(yitc_err**2 + (yitc / slope * slope_err)**2) * deg_to_rad Ug = mv(rate[0:12])
# Einzelspaltbreite lage_es_hmax = 499.79 lage_es_min = (npfarray([529.91, 561.26, 590.92, 623.13, 653.63]) - lage_es_hmax) * mpp lage_es_max = (lage_es_hmax - npfarray([456.82, 424.68, 394.69, 363.78, 333.80])) * mpp lage_es_d = npfarray([3, 3, 3, 3, 3]) * mpp n_es = npfarray([1, 2, 3, 4, 5]) pltext.initplot(num=1, title='Position Extrema am Einzelspalt', xlabel='Ordnung', ylabel='Abstand') [es_sl, es_dsl, es_itc, es_ditc] = linreg(n_es, lage_es_min, dy=lage_es_d) plt.plot([0, 6], [es_itc, es_itc + 6 * es_sl]) pltext.plotdata(n_es, lage_es_min, dy=lage_es_d, label='Minima') pltext.plotdata((lage_es_max - es_itc) / es_sl, lage_es_max, dx=lage_es_max / es_sl + n_es * (es_dsl / es_sl - 1) - (es_itc + es_ditc) / es_sl, label='Maxima') plt.xlim((0.8, 6)) plt.ylim((0.0, 0.0014)) plt.legend(loc=2) es_breite = schirmabstand * laser / es_sl es_breite_err = schirmabstand * laser * es_dsl / es_sl**2 print() print(val('ES Breite', es_breite, es_breite_err)) # Doppelspaltabstand
p0 = npfarray([sqrt_Er_lit, sig12_lit]) print() print(val('Literaturwert sqrt(Er)', sqrt_Er_lit)) # K_alpha K_alpha = npfarray([6.42, 17.47, 8.08, 4.49, 21.90, 15.79, 8.68, 7.51]) Delta_K_alpha = npfarray([0.16, 0.17, 0.15, 0.16, 0.20, 0.17, 0.16, 0.15]) sqrt_K_alpha = sqrt(K_alpha) Delta_sqrt_K_alpha = 1 / 2 * 1 / sqrt(K_alpha) * Delta_K_alpha pltext.initplot(num=1, title=r'$\sqrt{E_\alpha}$ als Funktion von $Z$', xlabel=r'$Z$', ylabel=r'$\sqrt{E_\alpha}$ in $\sqrt{keV}$') pltext.plotdata(x=Z, y=sqrt_K_alpha, dy=Delta_sqrt_K_alpha) n1 = 1 n2 = 2 def fit_func_alpha(x, sqrt_Er, sig12): return sqrt_Er * (x - sig12) * sqrt(1 / n1**2 - 1 / n2**2) popt, pcov = curve_fit(fit_func_alpha, Z, sqrt_K_alpha, sigma=Delta_sqrt_K_alpha, p0=p0)
Q_V_pv = Qel - Qab - wk_Wpv_mv Q_V_pv_dtot = sqrt(Qel_dtot**2 + Qab_dtot**2 + wk_Wpv_dsto**2) Q_V_D = Qel - Qab - W_D Q_V_D_dtot = sqrt(Qel_dtot**2 + Qab_dtot**2 + W_D_dsys**2) P_V_pv = Q_V_pv * wk_f_mv P_V_pv_dtot = sqrt((Q_V_pv_dtot * wk_f_mv)**2 + (Q_V_pv * wk_f_dsto)**2) P_V_D = Q_V_D * wk_f_mv P_V_D_dtot = sqrt((Q_V_D_dtot * wk_f_mv)**2 + (Q_V_D * wk_f_dsto)**2) wk_n_th = wk_Wpv_mv / Qel wk_n_th_dtot = 1 / Qel * sqrt(wk_Wpv_dsto**2 + (wk_Wpv_mv * Qel_dtot / Qel)**2) wk_n_eff = W_D / Qel wk_n_eff_dsys = 1 / Qel * sqrt(W_D_dsys**2 + (W_D * Qel_dtot / Qel)**2) print() print(tbl([['Qel']+lst(Qel,Qel_dtot),['Qab']+lst(Qab,Qab_dtot),['Wpv']+lst(wk_Wpv_mv,wk_Wpv_dsto),['W_D']+lst(W_D,W_D_dsys)])) print(tbl([['Pel']+lst(Pel,Pel_dtot),['Pab']+lst(Pab,Pab_dtot),['Ppv']+lst(Ppv,Ppv_dsto),['P_D']+lst(P_D,P_D_dtot)])) print(tbl([['Q_V (Wpv)']+lst(Q_V_pv,Q_V_pv_dtot),['Q_V (W_D)']+lst(Q_V_D,Q_V_D_dtot),['P_V (Wpv)']+lst(P_V_pv,P_V_pv_dtot),['P_V (W_D)']+lst(P_V_D,P_V_D_dtot)])) print(tbl([['f']+lst(wk_f_mv,wk_f_dsto),['F']+lst(wk_F,wk_F_dsys),['n_th']+lst(wk_n_th,wk_n_th_dtot),['n_eff']+lst(wk_n_eff,wk_n_eff_dsys)])) pltext.initplot(title='Wirkungsgrade in Abhängigkeit von der Frequenz', xlabel='Frequenz f / Hz', ylabel='Wirkungsgrad') pltext.plotdata(wk_f_mv, wk_n_th, wk_n_th_dtot, wk_f_dsto, label=r'$n_{th}$', connect=True) pltext.plotdata(wk_f_mv, wk_n_eff, wk_n_eff_dsys, wk_f_dsto, label=r'$n_{eff}$', connect=True) plt.xlim(3.75,5.875) plt.ylim(0.0,0.1) plt.legend(loc='upper left') plt.savefig('fig0.pdf', format='pdf') plt.show()
# measure version 1.8.12s from measure import plt, pltext, npfarray, linreg, sqrt, val, dev, exp, pi, spcurvefit, nplinspace, tbl from numpy import loadtxt from scipy.special import gamma # Aufgabe 2 U = npfarray([420, 445, 470, 495, 520, 545, 570]) N = npfarray([1887, 2330, 2337, 2359, 2407, 2374, 2310]) N_dsto = sqrt(N) pltext.initplot(num=1, title='Abbildung : Zählrohrcharakteristik', xlabel='Spannung in V', ylabel='Ereignisse') pltext.plotdata(U, N, N_dsto, label='Messwerte') [slope, dslope] = linreg(U[1:], N[1:], N_dsto[1:], plot=True, prange=(410, 580))[0:2] pltext.set_layout(xlim=(410, 580), ylim=(1800, 2500)) U0 = 510 print('\nAufgabe 2\n') print(val(slope, dslope, name='Steigung')) # Aufgabe 3 U = [510, 610] N1min = npfarray([9838, 9871]) N1min_dsto = sqrt(N1min)
f, U_aus = np.loadtxt('./data/243.txt', skiprows=1, usecols=(0, 1), unpack=True) D = 1e-3 U_ein = 0.2 g = U_aus / (U_ein * D) pltext.initplot(num=1, title='Abbildung : Frequenzgang (Messwerte)', xlabel='Frequenz in Hz', ylabel='g(f)', scale='loglog') pltext.plotdata(f, g) pltext.set_layout(xlim=(1e2, 1e6), ylim=(3e0, 2e3)) def fitfunc(f, V, W1, W2, n1, n2): return V / (np.sqrt(1 + 1 / (f / W1)**(2 * n1)) * np.sqrt(1 + (f / W2)**(2 * n2))) V = 1000 W1 = 1000 W2 = 50000 n1 = 5 n2 = 5 p0 = (V, W1, W2, n1, n2)