Esempio n. 1
0
phi_rubidium = -np.array(adapt_angle(roh_winkel_rubidium))* np.pi / 180.    # das - kommt von k = -1
phi_kalib = -np.array(adapt_angle(roh_winkel_kalib))* np.pi / 180.          # das - kommt von k = -1

########## Aufgabenteil a) ##########
# Bestimmung der Gitterkonstante

# bekannte Wellenlängen der Helium Spektrallinien (hier muss die
# Reihenfolge natürlich übereinstimmen mit derjenigen der Datei
# WinkelHelium.txt):
lambda_helium = np.array([438.8, 447.1, 471.3, 492.2,
                          501.6, 504.8, 587.6, 667.8, 706.5]) * 1e-9    # in m

# sinus für den plot und den fit
sin_phi_helium = np.array(np.sin(phi_helium))
# fit sin(phi) gegenüber lambda zur Bestimmung von g
params_gitterkonstante = ucurve_fit(
    reg_linear, sin_phi_helium, lambda_helium)

g, offset = params_gitterkonstante                  # g in m, offset Einheitenfrei
write('build/gitterkonstante.tex', make_SI(g * 1e9, r'\nano\meter', figures=1))
write('build/offset.tex', make_SI(offset * 1e9, r'\nano\meter', figures=1))
write('build/Tabelle_messdaten_kalium.tex', make_table([phi_kalium*180/np.pi],[1]))
write('build/Tabelle_messdaten_natrium.tex', make_table([phi_natrium*180/np.pi],[1]))
write('build/Tabelle_messdaten_rubidium.tex', make_table([phi_rubidium*180/np.pi],[1]))

##### PLOT lineare Regression #####
t_plot = np.linspace(np.amin(sin_phi_helium), np.amax(sin_phi_helium), 2)
plt.xlim(t_plot[0] - 1 / np.size(sin_phi_helium) * (t_plot[-1] - t_plot[0]),
         t_plot[-1] + 1 / np.size(sin_phi_helium) * (t_plot[-1] - t_plot[0]))
plt.plot(t_plot,
         reg_linear(t_plot, *noms(params_gitterkonstante))* 1e9,
         'b-', label='Fit')
Esempio n. 2
0
write('build/Tabelle_0.tex', make_table([h_zylinder*10**3, t_zylinder*10**6, v_zylinder],[2, 1, 2]))     # Jeder fehlerbehaftete Wert bekommt zwei Spalten
write('build/Tabelle_0_texformat.tex', make_full_table(
     'Bestimmung der Schallgeschwindigkeit mittels Impuls-Echo-Verfahren.',
     'tab:0',
     'build/Tabelle_0.tex',
     [],              # Hier aufpassen: diese Zahlen bezeichnen diejenigen resultierenden Spaltennummern,
                               # die Multicolumns sein sollen
     [r'$h_{\text{zylinder}} \:/\: 10^{-3} \si{\metre}$',
     r'$\increment t \:/\: 10^{-6} \si{\second} $',
     r'$c_\text{Acryl} \:/\:\si{\metre\per\second} $']))

c_arcyl_1 = ufloat(np.mean(v_zylinder), np.std(v_zylinder))
write('build/c_acryl_1.tex', make_SI(c_arcyl_1, r'\metre\per\second', figures=2))      # type in Anz. signifikanter Stellen

params = ucurve_fit(reg_linear, 0.5*t_zylinder, h_zylinder)             # linearer Fit
a, b = params
write('build/parameter_a.tex', make_SI(a, r'\metre\per\second', figures=1))       # type in Anz. signifikanter Stellen
write('build/parameter_b.tex', make_SI(b, r'\metre', figures=2))      # type in Anz. signifikanter Stellen

v_lit   = 2730
v_rel_3 = abs(np.mean(a)-v_lit)/v_lit *100
write('build/v_rel_3.tex', make_SI(v_rel_3, r'\percent', figures=2))

t_plot = np.linspace(0.9*np.amin(0.5*t_zylinder), np.amax(0.5*t_zylinder)*1.1, 100)
plt.plot(t_plot, t_plot*a.n+b.n, 'b-', label='Linearer Fit')
plt.plot(0.5*t_zylinder, h_zylinder, 'rx', label='Messdaten')
# t_plot = np.linspace(-0.5, 2 * np.pi + 0.5, 1000) * 1e-3
#
## standard plotting
# plt.plot(t_plot * 1e3, f(t_plot, *noms(params)) * 1e-3, 'b-', label='Fit')
Esempio n. 3
0
def do_job_b(filename, error, P, limits):
    # Einlesen der Messdaten
    Tiefe, Delta_f, Intensity = np.genfromtxt(filename, unpack=True)

    colors = ["rx", "bx", "gx"]

    Delta_f_error = Delta_f * error
    Delta_f = unp.uarray(Delta_f, Delta_f_error)

    v = c_L / 2 / nu_0 * Delta_f / np.cos(alpha[1])  # 15 ° Winkel

    ###### Fit im Intervall limits mit quadratischer Funktion gemäß dem Gesetz von Hagen-Poiseuille
    i = 0
    start = 0
    end = 0
    for x in Tiefe:
        if x == limits[0]:
            start = i
        if x == limits[1]:
            end = i
        i += 1
    params = ucurve_fit(reg_quadratic, Tiefe[start : (end + 1)], v[start : (end + 1)])  # quadratischer Fit
    a, x0, c = params
    write("build/parameter_a.tex", make_SI(a * 1e-3, r"\kilo\volt", figures=1))
    ##### Ende Fit ########

    # Plotting
    plt.clf
    fig, ax1 = plt.subplots()
    t_plot = np.linspace(limits[0] - 0.5, limits[1] + 0.5, 50)

    # Momentangeschwindigkeiten
    Ins1 = ax1.plot(Tiefe, noms(v), "rx", label="Momentangeschwindigkeit")
    Ins2 = ax1.plot(t_plot, reg_quadratic(t_plot, *noms(params)), "r--", label="Fit")
    ax1.set_xlabel(r"$\text{Laufzeit} \:/\: \si{\micro\second}$")
    ax1.set_ylabel(r"$v \:/\: \si{\meter\per\second}$")
    if P == 45:
        ax1.set_ylim(0.45, 0.9)  # hard coded stuff ftl !

    # Streuintensitäten
    ax2 = ax1.twinx()
    Ins3 = ax2.plot(Tiefe, Intensity, "b+", label="Intensität")
    ax2.set_ylabel(r"$I \:/\: \si{\kilo\volt\squared\per\second}$")

    # Theoretische Grenzen des Rohres einzeichnen
    ax1.plot((noms(x0) - 5 / 1.5, noms(x0) - 5 / 1.5), (ax1.get_ylim()[0], ax1.get_ylim()[1]), "k:", linewidth=1)
    ax1.plot((noms(x0) + 5 / 1.5, noms(x0) + 5 / 1.5), (ax1.get_ylim()[0], ax1.get_ylim()[1]), "k:", linewidth=1)
    ax1.plot(
        (noms(x0) - 5 / 1.5 - 2.5 / 2.5, noms(x0) - 5 / 1.5 - 2.5 / 2.5),
        (ax1.get_ylim()[0], ax1.get_ylim()[1]),
        "k:",
        linewidth=1,
    )
    ax1.plot(
        (noms(x0) + 5 / 1.5 + 2.5 / 2.5, noms(x0) + 5 / 1.5 + 2.5 / 2.5),
        (ax1.get_ylim()[0], ax1.get_ylim()[1]),
        "k:",
        linewidth=1,
    )

    Ins = Ins1 + Ins2 + Ins3
    labs = [l.get_label() for l in Ins]
    ax1.legend(Ins, labs, loc="upper left")
    plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
    plt.savefig("build/Plot_b_P" + str(P) + ".pdf")
Esempio n. 4
0

# Magnetfeldkram
B = 0.8**1.5 *Windungszahl*I*const.mu_0 / r_HelmHoltz
T = unp.uarray([np.mean(T_10), np.mean(T_08), np.mean(T_06), np.mean(T_04), np.mean(T_02)],[np.std(T_10), np.std(T_08), np.std(T_06), np.std(T_04), np.std(T_02)])

#Fit
# y2 = 1/T**2
# params2 = ucurve_fit(reg.reg_linear, B, y2)
# m2,D2 = params2
# # m2 *= 4*np.pi**2*(Theta_Kugel+Theta_Aufhaengung)
# write('build/m2.tex', make_SI(m2*1e3, r'\ampere\square\meter', 'e-3', figures=1))
# write('build/D2.tex', make_SI(D2*1e5, r'\kilogram\square\meter\per\square\second', 'e-5', figures=1))

y = 4*np.pi**2*(Theta_Kugel+Theta_Aufhaengung)/T**2
params = ucurve_fit(reg.reg_linear, B, y)         # linearer Fit
m, D = params
write('build/m.tex', make_SI(m*1e3, r'\ampere\square\meter', 'e-3', figures=1))
write('build/D.tex', make_SI(D*1e5, r'\kilogram\square\meter\per\square\second', 'e-5', figures=1))
# D = 4*(np.pi**2)*(Theta_Kugel+Theta_Aufhaengung)/(T**2)
m_th = 1/B * (4*(np.pi**2) * (Theta_Kugel+Theta_Aufhaengung) / T**2 - D_ohneB)
m_th_unc = ufloat(np.mean(noms(m_th)), MeanError(noms(m_th)))
write('build/m_th.tex', make_SI(m_th_unc*1e3, r'\ampere\square\meter', 'e-3', figures=1))
# print(m_th)

t_plot = np.linspace(np.amin(B), np.amax(B), 100)
#
plt.plot(t_plot*1e3, reg.reg_linear(t_plot, *noms(params))*1e5, 'b-', label='Methode 1')
plt.plot(t_plot*1e3, reg.reg_linear(t_plot, np.mean(noms(m_th)), np.mean(noms(D)))*1e5, 'g-', label='Methode 2')
# plt.plot(B * 1e3, noms(y)*1e5, 'rx', label='Messdaten')
plt.errorbar(B * 1e3, noms(y) * 1e5, fmt='r.', yerr=stds(y) * 1e5, label='Messdaten')
    A=konst_a
    R=konst_R
    p = a*T**3 + b*T**2 + c*T +d
    dp = 3*a*T**2 + 2*b*T + c
    return (R*T/2+np.sqrt((R*T/2)**2 - A*p))*dp*T/p

R = const.physical_constants["molar gas constant"]

T11, p11, T22, p22, T33, p33, T44, p44 = np.genfromtxt('Messwerte/vergleichLinneweber.txt', unpack=True)
T2 = np.concatenate((T11,T22,T33,T44))
p2 = np.concatenate((p11,p22,p33,p44))


T2 += 273.1     # T in K
p2 *= 1e5       # p in N/m^2  (Pa)
params_2 = ucurve_fit(g, T2, p2)

# Korrektur wegen Offset : T = 373.1 K -> p = 1 bar = 1e5 Pa
# write('build1/offset2.tex', make_SI(1e-5*g(373.1, *noms(params_2))-1, r'\bar', '', 1))
# p2 += 1e5-g(373.1, *noms(params_2))
# params_2 = ucurve_fit(g, T2, p2)

a2, b2, c2, d2 = params_2
d2 += 48*1e3    # Korrektur Offset (laut Protokoll)
write('build1/a2.tex', make_SI(a2 * 1e-5, r'\bar\per\kelvin\tothe{3}', '', 1))
write('build1/b2.tex', make_SI(b2 * 1e-5, r'\bar\per\kelvin\tothe{2}', '', 1))
write('build1/c2.tex', make_SI(c2 * 1e-5, r'\bar\per\kelvin\tothe{1}', '', 1))
write('build1/d2.tex', make_SI(d2 * 1e-5, r'\bar', '', 1))

T_hilf = np.linspace(np.amin(T2), np.amax(T2), 5)
T_plot = np.linspace((T_hilf[0]-1/np.size(T2)*(T_hilf[-1]-T_hilf[0])), (T_hilf[-1]+1/np.size(T2)*(T_hilf[-1]-T_hilf[0])), 10)
Esempio n. 6
0
############# MICROSCOPE MEASUREMENTS ##################
scale_mic = 0.5/1.3                     # mm pro cm bei Vergrößerung 3,2
scale_mic *= 3.2/4                      # jetzt für Vergrößerung 4
b_microscope = np.array([b_k_mic, b_m_mic, b_g_mic, b_ds_mic])
b_microscope *= scale_mic * 1e-3        # in m
s_ds_mic *= scale_mic * 1e-3            # in m


############# STARTING FITS ##################
plot_it = True
#### KLEINER EINZELSPALT ####
zeta_0_k = zeta_0[0]                        # in m
phi_k = phi1 - zeta_0_k/L                   # in rad
phi_k_plot = phi1_plot - zeta_0_k/L         # in rad

params_k = ucurve_fit(theory_einfach, phi_k, I_k, p0=[np.sqrt(max(I_k)) / b_k_hst, b_k_hst])
A0_k, b_k = params_k

if (plot_it):
    plt.clf()
    plt.plot(phi1_plot*1e3, theory_einfach(phi_k_plot, *noms(params_k))*1e6, 'b-', label='Fit')
    plt.plot(phi1*1e3, I_k*1e6, 'rx', label='Messdaten')
    plt.xlabel(r'$\varphi \:/\: \si{\milli\radian}$')
    plt.ylabel(r'$I \:/\: \si{\micro\ampere}$')
    plt.legend(loc='best')
    plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
    plt.savefig('build/plot_klein.pdf')


#### MITTLERER EINZELSPALT ####
zeta_0_m = zeta_0[1]            # in m
Esempio n. 7
0
        Falldauer_unc[i] = ufloat(a, b)
        T_2[i] = T[j]
        i += 1
    j += 1
Falldauer_unc[0] = t_gr_a
# print (Falldauer_unc)


rho_Wasser = [998.8, 996.5, 995.3, 994.0, 992.6, 991.0, 989.3, 987.5, 985.7, 983.2]
rho_K = rho_gr * np.ones(10)
eta_gr_b = K_gr * (rho_K - rho_Wasser) * Falldauer_unc
print('eta')
print(eta_gr_b)
eta_gr_b_log = unp.log(eta_gr_b)

params = ucurve_fit(reg.reg_linear, 1/T_2, noms(eta_gr_b_log))
m, b = params
write('build/Steigung_b.tex', make_SI(m, r'\kelvin', figures=1))  # Dies ist tatsächlich B !
write('build/Offset_b.tex', make_SI(b, r'', figures=1))
A = unp.exp(b)
# print(A)
write('build/ParameterA_b.tex', make_SI(A*1e3, r'\kilogram\meter\per\second', 'e-3', figures=1))

# write('build/Tabelle_daten1.tex', make_table([T_2-273, noms(Falldauer_unc), stds(Falldauer_unc), rho_Wasser, 1/T_2*1e3, noms(eta_gr_b)*1e3, stds(eta_gr_b)*1e3, noms(eta_gr_b_log)*(-1), stds(eta_gr_b_log)],[0, 2, 2, 1, 3, 3, 2 , 2, 2]))
write('build/Tabelle_daten1.tex', make_table([T_2-273, Falldauer_unc, rho_Wasser, 1/T_2*1e3, eta_gr_b*1e3, (-1)*eta_gr_b_log],[0, 1, 1, 3, 1, 1]))
# FULLTABLE
write('build/Tabelle_daten1_texformat.tex', make_full_table(
    'Messdaten Falldauer in Abhängigkeit der Temperatur.',
    'table:daten1',
    'build/Tabelle_daten1.tex',
    [1,4,5],              # Hier aufpassen: diese Zahlen bezeichnen diejenigen resultierenden Spaltennummern,
Esempio n. 8
0
    A=konst_a
    R=konst_R
    p = d*T**3 + c*T**2 + b*T +a
    dp = 3*d*T**2 + 2*c*T + b
    return (R*T/2+np.sqrt((R*T/2)**2 - A*p))*dp*T/p

# Verdampfungswärme als Funktion der Temperatur n=4
def L4(konst_a, konst_R, T, e, d, c, b, a):
    A=konst_a
    R=konst_R
    p = e*T**4 + d*T**3 + c*T**2 + b*T +a
    dp = 4*e*T**3 + 3*d*T**2 + 2*c*T + b
    return (R*T/2+np.sqrt((R*T/2)**2 - A*p))*dp*T/p


params = ucurve_fit(f, 1/T1, np.log(p1), p0=[-1, 1])
m1, b1 = params
write('build/m1.tex', make_SI(m1, r'\kelvin', '', 1))   # 1 signifikante Stelle
write('build/b1.tex', make_SI(b1, r'', '', 1))   # 1 signifikante Stelle

# Plot ln(p) vs 1/T
T_plot = np.linspace(np.amin(1/T1), np.amax(1/T1), 100)
T_hilf = np.linspace(2.5e-3, 3.5e-3, 100)

plt.plot(T_hilf*1e3, f(T_hilf, *noms(params)), 'b-', label='Fit')
plt.plot(1/T1*1e3, np.log(p1), '.r', label='Messdaten')

plt.xlim(1e3*(T_plot[0]-1/np.size(T1)*(T_plot[-1]-T_plot[0])), 1e3*(T_plot[-1]+1/np.size(T1)*(T_plot[-1]-T_plot[0])))
plt.xlabel(r'$T^{-1} \:/\: 10^{-3}\si{\per\kelvin}$')
plt.ylabel(r'$\ln(p / \si{\pascal})$')
plt.legend(loc='best')
Esempio n. 9
0
import numpy as np
from uncertainties.unumpy import nominal_values as noms
import matplotlib.pyplot as plt

from curve_fit import ucurve_fit


def Ur(r, A, B, C):
    return A + B / (r + C)**2


r, U, PA, LI, LP = np.genfromtxt('LED.txt', unpack=True)
r *= 1e-2
U /= PA * LI * LP

A, B, C = ucurve_fit(Ur, r, U)
print(A, B, C, sep='\n')

x = np.linspace(r[0] - 0.002, 1.6, 1000)
plt.plot(x, noms(Ur(x, A, B, C)), label='Ausgleichskurve')
plt.plot(r, U, 'x', label='Messwerte')
plt.xlim(0, 1.6)
plt.ylim(-0.05, 0.3)
plt.xlabel(r'$r \,/\, \mathrm{m}$')
plt.ylabel(r'$U \,/\, \mathrm{V}$')
plt.legend(loc='upper right')
plt.tight_layout()
plt.savefig('loesung.pdf')
Esempio n. 10
0
write('build/Tabelle_Silber.tex', make_table([Si[:23],t_Si[:23],Si[23:],t_Si[23:]],[1,0,1,0]))     # Jeder fehlerbehaftete Wert bekommt zwei Spalten
write('build/Tabelle_Silber_texformat.tex', make_full_table(
    caption = 'Messdaten von Silber unter Berücksichtigung des Nulleffekts.',
    label = 'table:Silber',
    source_table = 'build/Tabelle_Silber.tex',
    stacking = [0,2],              # Hier aufpassen: diese Zahlen bezeichnen diejenigen resultierenden Spaltennummern, die Multicolumns sein sollen
    units = [
    r'$N_\textrm{\Delta t}$',
    r'$t \:/\: \si{\second}$',
    r'$N_\textrm{\Delta t}$',
    r'$t \:/\: \si{\second}$']))         # default = '-'



params = ucurve_fit(reg_linear, t, np.log(noms(Ind)))                                       # linearer Fit
m,b = params
write('build/Indium_m.tex', make_SI(m*1e4, r'\per\second', '1e-4' ,figures=1))
write('build/Indium_b.tex', make_SI(b, r'', figures=1))
t_plot = np.linspace(0, 4000, 2)
plt.plot(t_plot, np.exp(reg_linear(t_plot, *noms(params))), 'b-', label='Fit')
plt.errorbar(t, noms(Ind), fmt='rx', yerr=stds(Ind), label='Messdaten')                      # mit Fehlerbalken
plt.yscale('log')                                                                            # logarithmische x-Achse
plt.xlabel(r'$t \:/\: \si{\second}$')
plt.ylabel(r'$ \text{ln}(N_\textrm{\Delta t}) $')
plt.legend(loc='best')
plt.savefig('build/Indium_plot.pdf')
plt.clf()

lambda_Ind = -m
Esempio n. 11
0
    else:
        x = '{0:.{1:}f}'.format(num, figures)

    return r'\SI{{{}{}}}{{{}}}'.format(x, exp, unit)


t, U, U_err = np.genfromtxt('data.txt', unpack=True)
t *= 1e-3
U = 1e3 * unp.uarray(U, U_err)


def f(t, a, b, c, d):
    return a * np.sin(b * t + c) + d


params = ucurve_fit(f, t, U, p0=[1, 1e3, 0, 0])

t_plot = np.linspace(-0.5, 2 * np.pi + 0.5, 1000) * 1e-3

plt.plot(t_plot * 1e3, f(t_plot, *noms(params)) * 1e-3, 'b-', label='Fit')
plt.errorbar(
    t * 1e3,
    noms(U) * 1e-3,
    yerr=stds(U) * 1e-3,
    fmt='r_',
    label='Daten',
)
plt.xlim(t_plot[0] * 1e3, t_plot[-1] * 1e3)
plt.xlabel(r'$t \:/\: \si{\milli\second}$')
plt.ylabel(r'$U \:/\: \si{\kilo\volt}$')
plt.legend(loc='best')
Esempio n. 12
0
    [
    r'$x \:/\: \si{\milli\meter}$',
    r'$D_\text{ohne} \:/\: \si{\milli\meter}$',
    r'$D_\text{mit} \:/\: \si{\milli\meter}$',
    r'$D_\text{x} \:/\: \si{\milli\meter}$',
    r'$L_1 x^2-\frac{x^3}{3} \:/\: \si{\milli\meter}$']))

### Berechnung des E-moduls für Material1

plt.plot(x_achse[::-1]*1e3,D_x[::-1]*1e3, 'rx', label='Messdaten')
plt.ylabel(r'$U \:/\: \si{\volt}$')
plt.xlabel(r'$t \:/\: \si{\milli\second}$')
plt.legend(loc='best')
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)

params = ucurve_fit(reg.reg_linear, x_achse[::-1] , D_x[::-1])
t_plot = np.linspace(0, 90, 2)
plt.plot(t_plot, reg.reg_linear(t_plot, *noms(params)), 'b-', label='$Fit_\t{1}$')

plt.ylabel(r'$D(x) \:/\: \si{\milli\meter}$')
plt.xlabel(r'$L_1 x^2-\frac{x^3}{3} \:/\: \si{\milli\meter}$')
plt.legend(loc='best')
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
plt.savefig('build/Material1.pdf')
plt.clf()

print('m und b')
print(params[0])
print(params[1])

### Flächenträgheitsmoment
Esempio n. 13
0
U_recht_ges = unp.uarray(Skalierung(U_recht,Skala_U_recht),U_recht_err)
I_recht_ges = unp.uarray(Skalierung(I_recht,Skala_I_recht),I_recht_err)
write('build/Tabelle_Rechteck.tex', make_table([U_recht_ges , I_recht_ges*1e3],[2,1]))

print('hallo, nah alles klar bei dir ?')


# plot für die Monozelle
plt.errorbar(unp.nominal_values(I1_ges)*1e3, unp.nominal_values(U1_ges), xerr = unp.std_devs(I1_ges), yerr=unp.std_devs(U1_ges), fmt='r.')
plt.ylabel(r'$U \:/\: \si{\volt}$')
plt.xlabel(r'$I \:/\: \si{\milli\ampere}$')
plt.legend(loc='best')
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
#plt.savefig('build/plot1.pdf')

params = ucurve_fit(f, I1, U1_ges)
m1, b1 = params
write('build/m1.tex', make_SI(m1, r'\ohm', '', 1))   # 1 signifikante Stelle
write('build/m1_fuer_Latex.tex', make_SI(m1*(-1), r'\ohm', '', 1))   # 1 signifikante Stelle
write('build/b1.tex', make_SI(b1, r'\volt', '', 1))   # 1 signifikante Stelle

i = np.linspace(0.02,0.11, 100)
plt.plot(i*1e3,f(i, noms(m1), noms(b1) ), 'b-', label='Monozelle')
plt.savefig('build/plot1.pdf')
plt.clf()

plt.errorbar(unp.nominal_values(I1_c_ges)*1e3, unp.nominal_values(U1_c_ges), xerr = unp.std_devs(I1_c_ges), yerr=unp.std_devs(U1_c_ges), fmt='r.')
plt.ylabel(r'$U \:/\: \si{\volt}$')
plt.xlabel(r'$I \:/\: \si{\milli\ampere}$')
plt.legend(loc='best')
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
Esempio n. 14
0
plt.plot(lambda_nm,n**2, 'rx', label='Messdaten')
plt.xlabel(r'$\lambda \:/\: \si{\nano\metre}$')
plt.ylabel(r'$n^2$')
plt.legend(loc='best')
plt.savefig('build/Dispersionskurve_ohne_Fit.pdf')

 # def reg_linear (x, m, b):
 #     return m*x + b

def f(l, A_0, A_2):
    return A_0 + A_2/(l**2)

def g(l, B_0, B_2):
    return B_0 - B_2*(l**2)

params_f = ucurve_fit(f, lambda_nm, n**2)
write('build/A_0_f.tex', make_SI(params_f[0], r'', figures=1))
write('build/A_2_f.tex', make_SI(params_f[1]*1e-3, r'\metre','1e6', figures=1))
params_g = ucurve_fit(g, lambda_nm, n**2)
write('build/A_0_g.tex', make_SI(params_g[0], r'', figures=1))
write('build/A_2_g.tex', make_SI(params_g[1]*1e8, r'\metre','1e-16', figures=1))


t_plot = np.linspace(400, 750)

# plt.plot(lambda_nm,n**2, 'rx', label='Messdaten')


plt.plot(t_plot, f(t_plot, *noms(params_f)), 'b-', label='Fit 1')
plt.plot(t_plot, g(t_plot, *noms(params_g)), 'g-', label='Fit 2')
Esempio n. 15
0
#### Bestimmung der Abschirmkonstante

sigma_ger = 32 - np.sqrt((E_ger/r) -((s_k**2)/4)*32**4)
sigma_zink = 30 - np.sqrt((E_zink/r) -((s_k**2)/4)*30**4)
sigma_zir = 40 - np.sqrt((E_zir/r) -((s_k**2)/4)*40**4)

write('build/Abschirmkonstante_Germanium.tex', make_SI(sigma_ger, r' ', figures=2))
write('build/Abschirmkonstante_Zink.tex', make_SI(sigma_zink, r' ', figures=2))
write('build/Abschirmkonstante_Zirkonium.tex', make_SI(sigma_zir, r' ', figures=2))

#Moseley-Diagramm

E_k = (E_zink, E_ger, E_zir)
Z   = (30,32,40) # Zn, Ge, Zr
E_k_wurzel = np.sqrt(E_k)
params = ucurve_fit(reg_linear, Z, E_k_wurzel)
m,b = params
write('build/hcRydbergonstante.tex', make_SI(4/3*m**2, r'\electronvolt', figures=1))
write('build/Rydbergonstante.tex', make_SI(4/3*m**2/(h*c), r'\per\meter', figures=1))

plt.clf
t_plot = np.linspace(25,45, 100)
plt.plot(t_plot , reg_linear(t_plot, *noms(params)), 'b-', label='Fit')
plt.plot(Z, E_k_wurzel, 'rx', label='Messdaten')
plt.xlabel(r'Kernladungszahl  $Z$')
plt.ylabel(r'$\sqrt{E_\textrm{k} \:/\: \si{\kilo\electronvolt}}$')
plt.legend(loc='best')
plt.savefig("build/Moseley_Diagramm.pdf")
plt.close

################################ FREQUENTLY USED CODE ################################
Esempio n. 16
0
T1 += 273.1     # T in K
p1 += 1         # Offset 1 bar
p1 *= 1e5       # in Pa
write('build/Tabelle_Verdampfungskurve.tex', make_table([T1, p1, 1e3/(T1), np.log(p1)], [1,1,3,2]))
write('build/Tabelle_Verdampfungskurve_texformat.tex', make_full_table(
    'Abgelesene und daraus abgeleitete Werte für die Berechnung der Verdampfungswärme.',
    'table:A1',
    'build/Tabelle_Verdampfungskurve.tex',
    [],
    [r'$T \:/\: \si{\kelvin}$',
    r'$p \:/\: \si{\bar}$',
    r'$\frac{1}{T} \:/\: 10^{-3}\si{\per\kelvin}$',
    r'$\ln{(p/\si{\pascal})}$']))

# Fit Verdampfungskurve
params = ucurve_fit(reg.reg_linear, 1/T1, np.log(p1), p0=[-1, 1])
m1, b1 = params
write('build/m1.tex', make_SI(m1, r'\kelvin', '', 1))   # 1 signifikante Stelle
write('build/b1.tex', make_SI(b1, r'', '', 1))   # 1 signifikante Stelle

# Plot ln(p) vs 1/T  -> Verdampfungskurve
T_plot = np.linspace(np.amin(1/T1), np.amax(1/T1), 100)
plt.plot(T_plot*1e3, reg.reg_linear(T_plot, *noms(params)), 'b-', label='Fit')
plt.plot(1/T1*1e3, np.log(p1), '.r', label='Messdaten')
plt.xlim(1e3*(T_plot[0]-1/np.size(T1)*(T_plot[-1]-T_plot[0])), 1e3*(T_plot[-1]+1/np.size(T1)*(T_plot[-1]-T_plot[0])))
plt.xlabel(r'$T^{-1} \:/\: 10^{-3}\si{\per\kelvin}$')
plt.ylabel(r'$\ln(p / \si{\pascal})$')
plt.legend(loc='best')
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08)
plt.savefig('build/Verdampfungskurve.pdf')
Esempio n. 17
0
# a)
# Abschlusswiderstand (Wellenwiderstand)
# frequenzunabhängig
Z_0 = np.sqrt(L/C1)
def Wellenwiderstand ( omega ):
    return np.sqrt(L/C1) * 1 / np.sqrt((1- 0.25 * omega**2 * L * C1))
write('build/Z_0.tex', make_SI(Z_0, r'\ohm', figures=0))


# "Lineare Regression"
# Teil 1
f1_log_a = np.array([29900, 35500, 41800, 49200, 57300, 66300, 77600])
abstand_skala1_a = [0,3,6,9,12,15,18]
f1_a = np.log(f1_log_a)

params = ucurve_fit(reg.reg_linear, abstand_skala1_a, f1_a)
m1, b1 = params
write('build/m1_a.tex', make_SI(m1*1e3, r'\per\centi\meter', 'e-3', figures=1))     # type in Anz. signifikanter Stellen
write('build/b1_a.tex', make_SI(b1*1e3, r'', 'e-3', figures=1))

# Teil 2
f2_log_a = np.array([26800.1, 29500, 32800, 36400, 40100, 44300, 48700, 53500, 58800, 64200, 70200, 77500])
abstand_skala2_a = [0,2,4,6,8,10,12,14,16,18,20,22]
f2_a = np.log(f2_log_a)

params = ucurve_fit(reg.reg_linear, abstand_skala2_a, f2_a)
m2, b2 = params
write('build/m2_a.tex', make_SI(m2*1e3, r'\per\centi\meter', 'e-3',figures=1))     # type in Anz. signifikanter Stellen
write('build/b2_a.tex', make_SI(b2*1e3, r'', 'e-3', figures=1))

write('build/Tabelle_a.tex', make_table([abstand_skala1_a, f1_log_a*1e-3, f1_a, abstand_skala2_a, f2_log_a*1e-3, f2_a], [0, 1, 2, 0, 1, 2]))  # type in Nachkommastellen
Esempio n. 18
0
write('build/Tabelle_a_texformat.tex', make_full_table(
    caption = 'Messdaten für die Charakteristik des Zählrohrs.',
    label = 'table:a',
    source_table = 'build/Tabelle_a.tex',
    stacking = [1,2,4],              # Hier aufpassen: diese Zahlen bezeichnen diejenigen resultierenden Spaltennummern, die Multicolumns sein sollen
    units = [r'$U \:/\: \si{\volt}$',
    r'$Z$',
    r'$N \:/\: \si{\per\second}$',
    r'$I \:/\: 10^{10}\si{\micro\ampere}$',
    r'$\Delta Q \:/\: \si{\elementarycharge}$']))


##### Fit ####
no_of_first_ignored_values = 3
no_of_last_ignored_values = 5
params = ucurve_fit(reg_linear, U[no_of_first_ignored_values:-no_of_last_ignored_values],
N[no_of_first_ignored_values:-no_of_last_ignored_values])   # skip first 3 and last 5 values as they dont belong to the plateau
write('build/plateaulaenge.tex', make_SI(U[-no_of_last_ignored_values] - U[no_of_first_ignored_values], r'\volt', figures = 0))
a, b = params
write('build/parameter_a.tex', make_SI(a, r'\per\second\per\volt', figures=1))
write('build/plateaumitte.tex', make_SI(reg_linear(500, *noms(params)), r'\per\second', figures=1) )   # Der Wert in der Hälfte des Plateaus als Referenz für die plateausteigung
write('build/plateausteigung.tex', make_SI(a*100*100/reg_linear(500, *noms(params)), r'\percent', figures=1))  #   %/100V lässt sich nicht mit siunitx machen -> wird in latex hart reingeschrieben
write('build/parameter_b.tex', make_SI(b, r'\per\second', figures=1))

#### Plot ####
t_plot = np.linspace(350, 650, 2)
plt.xlim(290,710)
plt.plot(t_plot, reg_linear(t_plot, *noms(params)), 'b-', label='Fit')
U[no_of_first_ignored_values:-no_of_last_ignored_values]
plt.errorbar(U[no_of_first_ignored_values:-no_of_last_ignored_values],
    noms(N[no_of_first_ignored_values:-no_of_last_ignored_values]),
    fmt='bx', yerr=stds(N[no_of_first_ignored_values:-no_of_last_ignored_values]),
Esempio n. 19
0
Umax *= -1
Umax_log = np.log (Umax)

Umin += 10
tmin += 800
tmax += 800*1e-6

print('tmax:')
print(tmax)
print ('Umax')
print(Umax)


# Dämpfungswiderstand ausrechnen
# params_max = ucurve_fit(reg.reg_linear, tmax, Umax_log)
params_max = ucurve_fit(reg.reg_linear, text, U_pos_ges_log)

R_a, Offset_a = params_max

print('R_a')
print(R_a)
R_a_2 = R_a*(-2*10.11e-3)
R_dampf_theo = 2*(unp.sqrt(L[0]/C[0]))
print('hhhhhhh')
print(L[0])
print(C[0])
write('build/R_daempfung_theo.tex', make_SI(R_1[0], r'\ohm', figures=1))
write('build/R_daempfung_mess.tex', make_SI(R_a_2, r'\ohm', figures=1))     # type in Anz. signifikanter Stellen
write('build/R_abweichung.tex', make_SI(R_a_2-R_1[0], r'\ohm', figures=1))
# write('build/loesung-b.tex', make_SI(b * 1e-3, r'\kilo\hertz', figures=1))
Esempio n. 20
0
T_weiss+=273.1  # T in K
T_schwarz+=273.1
T_matt+=273.1
T_glanz+=273.1
U_weiss*=10**(-7)    # U in V
U_schwarz*=10**(-7)    # U in V
U_matt*=10**(-7)    # U in V
U_glanz*=10**(-7)    # U in V

T0 = 273.1+23.6     # Umgebungstemperatur in K
U0 = 60e-7          # Offsetspannung in V

def f(t, a, b):
    return a * t + b

params_w = ucurve_fit(f, (T_weiss**4-T0**4), (U_weiss - U0), p0=[0.8e-9, 0])
params_s = ucurve_fit(f, (T_schwarz**4-T0**4), (U_schwarz - U0), p0=[0.8e-9, 0])
params_m = ucurve_fit(f, (T_matt**4-T0**4), (U_matt - U0), p0=[0.8e-9, 0])
params_g = ucurve_fit(f, (T_glanz**4-T0**4), (U_glanz - U0), p0=[0.8e-9, 0])

a_w, b_w = params_w
a_s, b_s = params_s
a_m, b_m = params_m
a_g, b_g = params_g
write('build/Steigung_w.tex', make_SI(a_w * 1e13, r'\volt\per\kelvin\tothe{4}' , 'e-13'))
write('build/Offset_w.tex', make_SI(b_w * 1e6, r'\volt' , 'e-6'))
write('build/Steigung_s.tex', make_SI(a_s * 1e13, r'\volt\per\kelvin\tothe{4}' , 'e-13'))
write('build/Offset_s.tex', make_SI(b_s * 1e6, r'\volt' , 'e-6'))
write('build/Steigung_m.tex', make_SI(a_m * 1e13, r'\volt\per\kelvin\tothe{4}' , 'e-13'))
write('build/Offset_m.tex', make_SI(b_m * 1e6, r'\volt' , 'e-6'))
write('build/Steigung_g.tex', make_SI(a_g * 1e13, r'\volt\per\kelvin\tothe{4}' , 'e-13'))