fpraktikum/SZ/auswertung/a_1.ipynb
2019-11-24 21:34:22 +01:00

591 lines
14 KiB
Text

{
"cells": [
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from importlib import reload\n",
"import utility\n",
"\n",
"reload(utility)\n",
"from utility import *\n",
"\n",
"from scipy.optimize import curve_fit\n",
"from SecondaryValue import SecondaryValue"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"org_compliance = 0.0098"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"a_an = 26 # cm^2\n",
"a_org = 6.4e-2 # cm^2\n",
"a_fol = 25 # cm^2\n",
"i_ein = 100e-3 # watt/cm^2"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"# anorganic\n",
"an_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_an.dat', compliance=.99)\n",
"an_light = -1*parse_ccurve('../messungen/191114_OM_VB/1_h_an.dat')[::-1]\n",
"fol_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_fol.dat',\n",
" compliance=org_compliance)\n",
"fol_light = parse_ccurve('../messungen/191114_OM_VB/1_h_fol.dat',\n",
" compliance=org_compliance)\n",
"org_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_org.dat',\n",
" compliance=org_compliance)\n",
"org_light = parse_ccurve('../messungen/191114_OM_VB/1_h_or.dat',\n",
" compliance=org_compliance)\n",
"\n",
"all_light = {\n",
" 'an_light': (an_light, a_an),\n",
" 'fol_light': (fol_light, a_fol),\n",
" 'org_light': (org_light, a_org)\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9dd40dd370>)"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(org_light)"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 500x400 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9dd411a3d0>)"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dark_close.pgf', compliance=.01)"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 500x400 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9dd40a7550>)"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dark_all.pgf')\n",
"plot_ccurve(an_light, save='A/an_light_all.pgf')"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.569698438377934"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%matplotlib qt5\n",
"an_dark_lin = an_dark[90:]\n",
"\n",
"d_i = 0.0001\n",
"\n",
"def lin_rs(x, offset, l):\n",
" return x*l + offset\n",
"\n",
"an_param, an_sigma = curve_fit(lin_rs, an_dark_lin.T[1], an_dark_lin.T[0], sigma=np.ones_like(an_dark_lin.T[0])*d_i, absolute_sigma=True)\n",
"an_sigma = np.sqrt(np.diag(an_sigma))\n",
"\n",
"plt.plot(an_dark.T[1], an_dark.T[0], linestyle='None', marker='x', label='Kennlinie')\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Stromstaerke [A]')\n",
"plt.grid()\n",
"plt.plot(an_dark_lin[:,1], lin_rs(an_dark_lin[:,1], *an_param), label='Linearer Fit')\n",
"plt.legend()\n",
"\n",
"plt.savefig('./figs/A/dark_an_lin_fit.pgf', dpi=300)\n",
"R = an_param[0]\n",
"R"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.00020306167618990354"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"an_sigma[0]"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"plt.clf()\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Logarthmus der Stromstaerke')\n",
"plt.grid()\n",
"an_u, an_i = an_dark[an_dark[:,1] > 0].T\n",
"RR=R-0.222\n",
"log_i = np.log(an_i)\n",
"plt.plot(log_i, an_u - an_i * RR, linestyle='None', marker='x', label='Kennlinie')\n",
"\n",
"p, _ = curve_fit(lin_rs, log_i[30:], (an_u - an_i * RR)[30:])\n",
"plt.plot(log_i, lin_rs(log_i,*p), label='Fit')\n",
"plt.legend()\n",
"n = p[1]\n",
"i_s = np.exp(-p[0]/p[1])\n",
"plt.savefig('./figs/A/dark_an_lin_fit_end.pgf', dpi=300)"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.347698438377934"
]
},
"execution_count": 68,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"RR"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"\n",
"def u(x, i, n, RR):\n",
" return n*np.log((x+i)/i) + x*RR\n",
"plt.clf()\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Logarthmus der Stromstaerke')\n",
"plt.grid()\n",
"plt.plot(an_i[10:], an_u[10:], linestyle='None', marker='x', label='Kennlinie')\n",
"plt.plot(an_i, u(an_i, i_s, n, RR), label='Fit')\n",
"plt.legend()\n",
"plt.savefig('./figs/A/dark_an_fit_final.pgf', dpi=300)\n",
"p, _ = curve_fit(u, an_i, an_u, p0=[i_s, n, RR])\n"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(1.4857909265575078, 9.565464918120711e-08, 0.347698438377934)"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Final Parameters\n",
"nn = 11804.5221 * n / (273.15 + 32)\n",
"nn, i_s, RR"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_dark, label='Dunkel')\n",
"plot_ccurve_line(ax, an_light, label='Hell', marker='x')\n",
"ax.legend()\n",
"fig.show()\n",
"save_fig(fig, 'A/anorg_hell_dunkel.pgf')"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 500x400 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9dae311d90>)"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(fol_dark, save='A/fol_dunkel.pgf', area=a_fol)\n",
"plot_ccurve(fol_light, save='A/fol_hell.pgf', area=a_fol, mlp=[4.02000070175182, -0.00050491])"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 500x400 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9dae6cfbb0>)"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dunkel.pgf', area=a_an)\n",
"plot_ccurve(an_light, save='A/an_hell.pgf', area=a_an)"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 500x400 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f9daeb33070>)"
]
},
"execution_count": 74,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(org_dark, save='A/org_dunkel.pgf', area=a_org)\n",
"plot_ccurve(org_light, save='A/org_hell.pgf', area=a_org)"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"an_light {'j_c': 0.02630074615384615, 'u_cc': 0.5599925566487172, 'u_mlp': 0.30999911523151735, 'p_mlp': 0.156638522040846, 'ff': 0.40904859440059965, 'eta': 0.06024558540032538, 'i_mlp': array(-0.505287), 'p_ein': 2.6}\n",
"fol_light {'j_c': 3.2946186e-05, 'u_cc': 7.129314361652983, 'u_mlp': 4.02000070175182, 'p_mlp': 0.002029756267025768, 'ff': 0.3456614690624081, 'eta': 0.0008119025068103072, 'i_mlp': array(-0.00050491), 'p_ein': 2.5}\n",
"org_light {'j_c': 0.0040643187499999995, 'u_cc': 0.9183601229960922, 'u_mlp': 0.7400008818112345, 'p_mlp': 0.00016271274581558095, 'ff': 0.6811469583998824, 'eta': 0.025423866533684523, 'i_mlp': array(-0.00021988), 'p_ein': 0.0064}\n"
]
}
],
"source": [
"for name, (ccurve, area) in all_light.items():\n",
" print(name, analyze_ccurve(ccurve, area, i_ein))"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_dark, area=a_an, label='Dunkelkennlinie')\n",
"plot_ccurve_line(ax, an_light, area=a_an, label='Hellkennlinie')\n",
"ax.legend()\n",
"save_fig(fig, 'A/anorg_combined.pgf')"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_light, area=a_an, label='Anorganisch', mlp=[.30999911523151735, -0.505287])\n",
"plot_ccurve_line(ax, org_light, area=a_org, label='O1', mlp=[0.740000881811234,-0.00021988 ])\n",
"plot_ccurve_line(ax, fol_light, area=a_fol, label='O2')\n",
"ax.legend()\n",
"ax.set_xlim([-1, 1])\n",
"save_fig(fig, 'A/all_combined.pgf')"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"argv": [
"/usr/bin/python3",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"env": null,
"interrupt_mode": "signal",
"language": "python",
"metadata": null,
"name": "python3"
},
"name": "a_1.ipynb"
},
"nbformat": 4,
"nbformat_minor": 2
}