def spe10(logfile): out = report_header(logfile) results = readlog(logfile) keys = [ "processes", "num-levels", "first-theta", "theta", "first-elems-per-agg", "elems-per-agg", # "standard-pcg-iterations", "complexity", "iterations", "time-spectral-setup", "time-spectral-solve" ] formats = [ "d", "d", ".0e", ".0e", "d", "d", # "d", ".2f", "d", ".2f", ".2f" ] # out = out + maketable.maketable(results, keys, formats, require={"w-cycle":True}) # out = out + maketable.maketable(results, keys, formats, require={"w-cycle":False}) out = out + maketable.maketable(results, keys, formats) print(out)
def pro(logfile): out = report_header(logfile) results = readlog(logfile) keys = [ "refine", "processes", "num-levels", "first-elems-per-agg", "elems-per-agg", "first-nu-pro", "nu-pro", "complexity", "iterations", "time-spectral-setup", "time-spectral-solve" ] formats = ["d", "d", "d", "d", "d", "d", "d", ".2f", "d", ".2f", ".2f"] out = out + maketable.maketable(results, keys, formats) print(out)
def main(logfile): """ just ignore missing files and files with no results """ out = report_header(logfile) results = readlog(logfile) keys = [ "serial-refine", "refine", "processes", "num-levels", "complexity", "iterations", "time-spectral-setup", "time-spectral-solve" ] formats = ["d", "d", "d", "d", ".2f", "d", ".2f", ".2f"] out = out + maketable.maketable(results, keys, formats) print(out)
omega = 2 * np.pi * f return 1 / np.sqrt((1 - L * C * omega**2)**2 + omega**2 * R**2 * C**2) def t2(f, R, L, C): omega = 2 * np.pi * f return 1 / unp.sqrt((1 - L * C * omega**2)**2 + omega**2 * R**2 * C**2) f, U, U_C, a = np.genfromtxt('daten/c.txt', unpack=True) a /= 1e6 phi = a / (1 / f) * 2 * np.pi maketable((f[:36], U[:36], U_C[:36], (a * 1e6)[:36], phi[:36], f[35:], U[35:], U_C[35:], (a * 1e6)[35:], phi[35:]), 'build/daten.txt') U = unp.uarray(U, 0.05 * U) U_C = unp.uarray(U_C, 0.05 * U_C) a = unp.uarray(a, 0.05 * a) phi = a / (1 / f) * 2 * np.pi rel = U_C / U #print('Fit 1:') params, pcov = curve_fit(t, f[3:-3], unp.nominal_values(rel)[3:-3], p0=[1e2, 10e-3, 1e-9], maxfev=1000000000)
U_0 = -5.6 start = 1695 #end = 3299 end = 3586 plt.plot(t, U1, 'r-', markersize=0.1, label='U1', linewidth=0.2) plt.plot(t[start]*np.ones(2), (-10,10), 'k-') plt.plot(t[end]*np.ones(2), (-10,10), 'k-') plt.legend(loc='best') plt.xlabel(r'$t/s$') plt.ylabel(r'$U/V$') plt.xlim(0, 0.01) plt.savefig('build/a1.pdf') plt.clf() U_ber = U1[start:end] - U_0 U_ber = np.log(U_ber) t_ber = t[start:end] slope, intercept, r_value, p_value, std_err = linregress(t_ber, U_ber) maketable([-1/unc.ufloat(slope, std_err)], "build/a.txt", True) x = np.linspace(0.003, 0.0075) plt.plot(t_ber, U_ber, 'rx', label='Messwerte', markersize=3) plt.plot(x, slope * x + intercept, 'b-', label='Lineare Regression') plt.legend(loc='best') plt.xlabel(r'$t/\si{\second}$') plt.ylabel(r'$ln(U/\si{\volt})$') plt.savefig('build/a2.pdf')
U0 = unp.uarray(U0, 0.05 * U0) def A(f, RC): return 1 / np.sqrt(1 + (2 * np.pi * f) ** 2 * RC ** 2) def phi(f, RC): return np.arctan(f * 2 * np.pi * RC) phi_ = a / (1 / f) * 2 * np.pi A_ = U / U0 maketable( (f.astype(int), unp.nominal_values(U), unp.nominal_values(U0), A_, unp.nominal_values(a * 1000), phi_), "build/daten.txt", ) paramsa, pcova = curve_fit(A, f, unp.nominal_values(A_), p0=[1 / 742], sigma=unp.std_devs(A_), absolute_sigma=True) paramsb, pcovb = curve_fit( phi, f, unp.nominal_values(phi_), p0=[1 / 742], sigma=unp.std_devs(phi_), absolute_sigma=True ) paramsa_u = unc.correlated_values(paramsa, pcova) paramsb_u = unc.correlated_values(paramsb, pcovb) maketable([paramsa_u], "build/b1.txt", True) maketable([paramsb_u], "build/b2.txt", True) x = np.linspace(0.2, 10000, 100000) # plt.fill_between(x, A(x, paramsa_u[0].n - paramsa_u[0].s*10), A(x, paramsa_u[0].n + paramsa_u[0].s*10), facecolor='blue', alpha=0.25, edgecolor='none', label=r'$1\sigma$-Umgebung ($\times 10$)') plt.plot(x, A(x, *paramsa), "b-", label="Fit")
#Ableitung der Fit-Funktion für die Differentialquotienten #def dTdt(t, A, B, C, α): # return ((A * α * t ** (α - 1) * (1 + B * t ** α)) - (A * t ** α) * (B * α * t ** (α - 1))) / (1 + B * t ** α) ** 2 def dTdt(t, A, B, C): return 2 * A * t + B #Curve Fits an die Messwerte mit ausprobierten Anfangswerten params1, pcov1 = curve_fit(T, t, T1, maxfev = 1000000, p0 = (1, 1e-2, 295), sigma = sigma_T) params2, pcov2 = curve_fit(T, t, T2, maxfev = 1000000, p0 = (-0.01, 1e-2, 295), sigma = sigma_T) #Parameter mit Standardfehler aus Kovarianzmatrix berechnen params1_u = unc.correlated_values(params1, pcov1) params2_u = unc.correlated_values(params2, pcov2) maketable(params1_u, "build/coefficients1.tex", True) maketable(params2_u, "build/coefficients2.tex", True) #4 Testzeitpunkte in der Messung test_points = np.array([120, 600, 990, 1590]) #Bestimmung des Differentialquotienten der Fit-Funktion zu den Testzeitpunkten test_T1 = dTdt(test_points, *params1_u) test_T2 = dTdt(test_points, *params2_u) #Wärmeleistung ins warme Reservoir bestimmen print("c_w") print(v*rho_wasser*c_w) wärmekapazität = (unc.ufloat(750, 10) + c_w*v*rho_wasser) test_T1 *= wärmekapazität test_T2 *= wärmekapazität
import matplotlib.pyplot as plt from scipy.optimize import curve_fit from scipy.constants.constants import C2K from scipy.stats import linregress from maketable import maketable K_k = 0.07640e-6 m_k = 4.43e-3 m_g = 4.95e-3 d_k = 15.319e-3 d_g = 15.492e-3 rho_w = 998.21 t_klein, t_groß = np.genfromtxt('daten/a.txt', unpack=True) maketable((t_klein, t_groß), 'build/d1.tex') t_k = unc.ufloat(t_klein.mean(), t_klein.std()) t_g = unc.ufloat(t_groß.mean(), t_groß.std()) print("t_kquer = {}, t_gquer = {}".format(t_k, t_g)) V_k = 4/3 * np.pi*(d_k/2)**3 V_g = 4/3 * np.pi*(d_g/2)**3 print("rho = {}, {}".format(m_k/V_k, m_g/V_g)) eta_k = K_k * (m_k/V_k - rho_w) * t_k print("ηₖ = {}".format(eta_k*1e3)) K_g = eta_k/((m_g/V_g - rho_w) * t_g) print("Kg = {}".format(K_g))
import numpy as np import matplotlib.pyplot as plt import uncertainties as unc import uncertainties.unumpy as unp import pickle from maketable import maketable U_S = 2.08 ny_0 = 1142 R = unc.ufloat(332, 332*0.002) ny, U_Br = np.genfromtxt("daten/e.txt", unpack=True) C3 = pickle.load(open('build/c3.pickle', 'rb')) * 1e-9 ny_0_th = 1/(2*np.pi*C3*R) maketable((R, C3*1e9, ny_0, ny_0_th, ny_0/ny_0_th), 'build/e.txt') maketable((ny[:18].astype(int), U_Br[:18], ny[18:].astype(int), U_Br[18:]), 'build/e_mess.txt') U_Br /= 1000 q = U_Br / U_S def q_th(omega): return np.sqrt(1/9 * ((omega**2-1)**2)/((1-omega**2)**2 + 9 * omega**2)) omega = ny/ny_0 #Klirrfaktor k = (U_Br[17] / q_th(2)) / U_S maketable((U_Br[17]*1000, q_th(2), k), 'build/f.txt')
import numpy as np import matplotlib.pyplot as plt import uncertainties as unc import uncertainties.unumpy as unp import pickle from maketable import maketable U_S = 2.08 ny_0 = 1142 R = unc.ufloat(332, 332 * 0.002) ny, U_Br = np.genfromtxt("daten/e.txt", unpack=True) C3 = pickle.load(open('build/c3.pickle', 'rb')) * 1e-9 ny_0_th = 1 / (2 * np.pi * C3 * R) maketable((R, C3 * 1e9, ny_0, ny_0_th, ny_0 / ny_0_th), 'build/e.txt') maketable((ny[:18].astype(int), U_Br[:18], ny[18:].astype(int), U_Br[18:]), 'build/e_mess.txt') U_Br /= 1000 q = U_Br / U_S def q_th(omega): return np.sqrt(1 / 9 * ((omega**2 - 1)**2) / ((1 - omega**2)**2 + 9 * omega**2)) omega = ny / ny_0
def T(U): return 25.157 * U - 0.19 * U**2 c_w = 4.18e3 M = np.array([12.0, 118.7, 118.7, 118.7]) / 1e3 rho = np.array([2.25, 7.28, 7.28, 7.28]) * 1e3 alpha = np.array([8, 27, 27, 27]) / 1e6 kappa = np.array([33, 55, 55, 55]) * 1e9 R = unc.ufloat(8.3144598, 0.0000048) U_k, U_w, U_m, m_k, m_Deckel, m_WG = np.genfromtxt('daten/daten.txt', unpack=True) maketable((("Graphit", "Zinn", "", ""), U_k, U_w, U_m, m_k, m_Deckel, m_WG), 'build/daten.tex') m_k /= 1e3 m_Deckel /= 1e3 m_WG /= 1e3 m_Glas = 187.63e-3 m_WG0 = 729.12e-3 U_vorher = 0.84 U_nachher = 2.25 U_wasser = 4.13 m_x = m_y = (m_WG0 - m_Glas) / 2 gerät = (c_w * m_y * (T(U_wasser) - T(U_nachher)) - c_w * m_x * (T(U_nachher) - T(U_vorher))) / (T(U_nachher) - T(U_vorher)) print(gerät)
omega = 2 * np.pi * f return 1 / np.sqrt((1 - L * C * omega ** 2) ** 2 + omega ** 2 * R ** 2 * C ** 2) def t2(f, R, L, C): omega = 2 * np.pi * f return 1 / unp.sqrt((1 - L * C * omega ** 2) ** 2 + omega ** 2 * R ** 2 * C ** 2) f, U, U_C, a = np.genfromtxt("daten/c.txt", unpack=True) a /= 1e6 phi = a / (1 / f) * 2 * np.pi maketable( (f[:36], U[:36], U_C[:36], (a * 1e6)[:36], phi[:36], f[35:], U[35:], U_C[35:], (a * 1e6)[35:], phi[35:]), "build/daten.txt", ) U = unp.uarray(U, 0.05 * U) U_C = unp.uarray(U_C, 0.05 * U_C) a = unp.uarray(a, 0.05 * a) phi = a / (1 / f) * 2 * np.pi rel = U_C / U # print('Fit 1:') params, pcov = curve_fit(t, f[3:-3], unp.nominal_values(rel)[3:-3], p0=[1e2, 10e-3, 1e-9], maxfev=1000000000) params = unc.correlated_values(params, pcov) x = np.linspace(0, 1e6, 10000) y_e = t2(x, *params)
from maketable import maketable L = unc.ufloat(10.11e-3, 0.03e-3) C = unc.ufloat(2.098e-9, 0.006e-9) R_ges = unc.ufloat(509.5 + 50 , 0.5) def t(f, R, L, C): omega = 2 * np.pi * f return 1/np.sqrt((1-L*C*omega**2)**2 + omega**2 * R**2 * C**2) f, U, U_C, a = np.genfromtxt('daten/c.txt', unpack=True) a /= 1e6 phi = a / (1/f) * 2 * np.pi maketable((f, U, U_C, a*1e6, phi), 'build/daten.txt') #print('Fit 1:') params, pcov = curve_fit(t, f, U_C/U, p0=[1e2, 10e-3, 1e-9], maxfev=10000) x = np.linspace(0, 1e6, 1000000) y = t(x, *params) q = y.max() writevalue(q, 'build/q.txt') q_t = 1/R_ges * unp.sqrt(L/C) writevalue(q_t , 'build/q_t.txt') print(q, q_t) drüber = np.where(y > 1/np.sqrt(2) * q)[0] ny_minus = x[drüber[0]] ny_plus = x[drüber[-1]]
import uncertainties.unumpy as unp import matplotlib.pyplot as plt from scipy.optimize import curve_fit from scipy.constants.constants import C2K from scipy.stats import linregress from maketable import maketable K_k = 0.07640e-6 m_k = 4.43e-3 m_g = 4.95e-3 d_k = 15.319e-3 d_g = 15.492e-3 rho_w = 998.21 t_klein, t_groß = np.genfromtxt('daten/a.txt', unpack=True) maketable((t_klein, t_groß), 'build/d1.tex') t_k = unc.ufloat(t_klein.mean(), t_klein.std()) t_g = unc.ufloat(t_groß.mean(), t_groß.std()) print("t_kquer = {}, t_gquer = {}".format(t_k, t_g)) V_k = 4 / 3 * np.pi * (d_k / 2)**3 V_g = 4 / 3 * np.pi * (d_g / 2)**3 print("rho = {}, {}".format(m_k / V_k, m_g / V_g)) eta_k = K_k * (m_k / V_k - rho_w) * t_k print("ηₖ = {}".format(eta_k * 1e3)) K_g = eta_k / ((m_g / V_g - rho_w) * t_g) print("Kg = {}".format(K_g))
#Genauigkeiten (relativ) uncertainty_r3r4 = 0.0005 uncertainty_2 = 0.0002 uncertainty_r2 = 0.03 a = np.genfromtxt("daten/a.txt", unpack=True) b = np.genfromtxt("daten/b.txt", unpack=True) b[0] *= 1e-9 c = np.genfromtxt("daten/c.txt", unpack=True) c[0] *= 1e-3 d = np.genfromtxt("daten/d.txt", unpack=True) d[0] *= 1e-9 #Daten exportieren maketable((a[0][:3], a[1][:3], a[2][:3], a[1][3:], a[2][3:]), 'build/a_mess.txt') maketable((b[0][:3]*1e9, b[1][:3], b[2][:3], b[3][:3], b[0][3:]*1e9, b[1][3:], b[2][3:], b[3][3:]), 'build/b_mess1.txt') maketable((b[0][6:]*1e9, b[1][6:], b[2][6:], b[3][6:]), 'build/b_mess2.txt') maketable((c[0]*1e3, c[1], c[2], c[3]), 'build/c_mess.txt') maketable((d[0]*1e9, d[1], d[2], d[3]), 'build/d_mess.txt') #### Wheatstone-Brücke R3R4 = unp.uarray(a[1] / a[2], a[1]/a[2] * uncertainty_r3r4) R2 = unp.uarray(a[0], a[0]*uncertainty_2) Rx = R2 * R3R4 #TODO: Fehlerrechnung? R10 = mittel(Rx[0:3]) R12 = mittel(Rx[3:6])
from maketable import maketable from scipy.constants.constants import C2K def T(U): return 25.157*U - 0.19*U**2 c_w = 4.18e3 M = np.array([12.0, 118.7, 118.7, 118.7])/1e3 rho = np.array([2.25,7.28,7.28,7.28])*1e3 alpha = np.array([8,27,27,27])/1e6 kappa = np.array([33,55,55,55])*1e9 R = unc.ufloat(8.3144598, 0.0000048) U_k, U_w, U_m, m_k, m_Deckel, m_WG = np.genfromtxt('daten/daten.txt', unpack=True) maketable((("Graphit", "Zinn", "", ""), U_k, U_w, U_m, m_k, m_Deckel, m_WG), 'build/daten.tex') m_k /= 1e3 m_Deckel /= 1e3 m_WG /= 1e3 m_Glas = 187.63e-3 m_WG0 = 729.12e-3 U_vorher = 0.84 U_nachher = 2.25 U_wasser = 4.13 m_x = m_y = (m_WG0 - m_Glas)/2 gerät = (c_w*m_y*(T(U_wasser) - T(U_nachher)) - c_w*m_x*(T(U_nachher) - T(U_vorher)))/(T(U_nachher)-T(U_vorher)) print(gerät)
f, U, a, U0 = np.genfromtxt('daten/bc.txt', unpack=True) a = unp.uarray(a, 0.05*a) a /= 1000 U = unp.uarray(U, 0.05*U) U0 = unp.uarray(U0, 0.05*U0) def A(f, RC): return 1 / np.sqrt(1+(2*np.pi*f)**2 * RC**2) def phi(f, RC): return np.arctan(f*2*np.pi*RC) phi_ = a / (1/f) * 2 * np.pi A_ = U/U0 maketable((f.astype(int),unp.nominal_values(U),unp.nominal_values(U0),A_,unp.nominal_values(a*1000),phi_), 'build/daten.txt') paramsa, pcova = curve_fit(A, f, unp.nominal_values(A_), p0=[1/742], sigma=unp.std_devs(A_), absolute_sigma=True) paramsb, pcovb = curve_fit(phi, f, unp.nominal_values(phi_), p0=[1/742], sigma=unp.std_devs(phi_), absolute_sigma=True) paramsa_u = unc.correlated_values(paramsa, pcova) paramsb_u = unc.correlated_values(paramsb, pcovb) maketable([paramsa_u], 'build/b1.txt', True) maketable([paramsb_u], 'build/b2.txt', True) x = np.linspace(0.2, 10000, 100000) #plt.fill_between(x, A(x, paramsa_u[0].n - paramsa_u[0].s*10), A(x, paramsa_u[0].n + paramsa_u[0].s*10), facecolor='blue', alpha=0.25, edgecolor='none', label=r'$1\sigma$-Umgebung ($\times 10$)') plt.plot(x, A(x, *paramsa), 'b-', label='Fit') plt.errorbar(f, unp.nominal_values(A_), yerr=unp.std_devs(A_), fmt='rx', label='Messdaten') plt.xlabel(r'$\nu/\si{\hertz}') plt.ylabel(r'$U/U0$')