{
"cells": [
{
"cell_type": "markdown",
"id": "51ea5530-ffc5-458d-b3dc-58f126597e76",
"metadata": {},
"source": [
"Jochen Kieninger
\n",
"**Electrochemical Methods for the Micro- and Nanoscale**
\n",
"www.electrochemical-methods.org\n",
"\n",
"## Task 7.2 (Electrochemical impedance spectroscopy - Randles circuit)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "4b447e3f-71dd-4cf7-ae78-ef5ab6313e4e",
"metadata": {},
"outputs": [],
"source": [
"from sympy import re, im, I, simplify, symbols, sqrt, atan"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "97a63ce4-b23b-4018-954c-aea4275bd724",
"metadata": {},
"outputs": [],
"source": [
"Ru, Rct, Cdl, omega = symbols('R_u R_ct C_dl, omega', real=True)"
]
},
{
"cell_type": "markdown",
"id": "218acdc4-ed87-4611-9fba-e9fcb6f7421e",
"metadata": {},
"source": [
"The complex impedance of a Randles circuit with uncompensated resistance $R_u$ in series with a parallel circuit of the charge transfer resistance $R_{ct}$ and the double layer capacity $C_{dl}$ is:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ac6d4468-d746-491f-8971-8b5d7a46802b",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle R_{u} + \\frac{1}{i C_{dl} \\omega + \\frac{1}{R_{ct}}}$"
],
"text/plain": [
"R_u + 1/(I*C_dl*omega + 1/R_ct)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Z = Ru+1/(I*omega*Cdl + 1/Rct)\n",
"Z"
]
},
{
"cell_type": "markdown",
"id": "357b74ea-e3d4-4e0e-b7ff-109f8894ad89",
"metadata": {},
"source": [
"Because of the uncompensated resistance, the equations are not as handsome as one would wish,\n",
"\n",
"- Real part:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "07b1a16d-40bb-4e27-ab4a-261a4a12421b",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{R_{ct} + R_{u} \\left(C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1\\right)}{C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1}$"
],
"text/plain": [
"(R_ct + R_u*(C_dl**2*R_ct**2*omega**2 + 1))/(C_dl**2*R_ct**2*omega**2 + 1)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(re(Z))"
]
},
{
"cell_type": "markdown",
"id": "0a730f8a-1a5d-4aec-a80b-4af10dd2157b",
"metadata": {},
"source": [
"- Imaginary part:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "b27d29a3-4f4f-4b0d-8198-5a6f03efce1c",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\frac{C_{dl} R_{ct}^{2} \\omega}{C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1}$"
],
"text/plain": [
"-C_dl*R_ct**2*omega/(C_dl**2*R_ct**2*omega**2 + 1)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(im(Z))"
]
},
{
"cell_type": "markdown",
"id": "73438eb6-4795-43d2-9991-eee8d279d60c",
"metadata": {},
"source": [
"- Absolute value:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8b066e3a-d528-4dbe-86df-3d68732235ff",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\frac{\\sqrt{C_{dl}^{2} R_{ct}^{4} \\omega^{2} + \\left(R_{ct} + R_{u} \\left(C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1\\right)\\right)^{2}}}{C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1}$"
],
"text/plain": [
"sqrt(C_dl**2*R_ct**4*omega**2 + (R_ct + R_u*(C_dl**2*R_ct**2*omega**2 + 1))**2)/(C_dl**2*R_ct**2*omega**2 + 1)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(sqrt(re(Z)**2 + im(Z)**2))"
]
},
{
"cell_type": "markdown",
"id": "8b846b6a-bb51-4eda-9e09-6e59c53b66b3",
"metadata": {},
"source": [
"- Phase:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "64112451-8015-4f55-a549-de4ddd4bca85",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle - \\operatorname{atan}{\\left(\\frac{C_{dl} R_{ct}^{2} \\omega}{R_{ct} + R_{u} \\left(C_{dl}^{2} R_{ct}^{2} \\omega^{2} + 1\\right)} \\right)}$"
],
"text/plain": [
"-atan(C_dl*R_ct**2*omega/(R_ct + R_u*(C_dl**2*R_ct**2*omega**2 + 1)))"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(atan(im(Z)/re(Z)))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}