{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3487469a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([<matplotlib.axis.XTick at 0x7e10b04929b0>,\n",
       "  <matplotlib.axis.XTick at 0x7e10b04b0310>,\n",
       "  <matplotlib.axis.XTick at 0x7e10b034ba60>,\n",
       "  <matplotlib.axis.XTick at 0x7e10b0328670>,\n",
       "  <matplotlib.axis.XTick at 0x7e10b0329360>],\n",
       " [Text(0.0, 0, '0.00'),\n",
       "  Text(0.05, 0, '0.05'),\n",
       "  Text(0.1, 0, '0.10'),\n",
       "  Text(0.15000000000000002, 0, '0.15'),\n",
       "  Text(0.2, 0, '0.20')])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 29224 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from pint import UnitRegistry\n",
    "\n",
    "# Set up unit system\n",
    "unit = UnitRegistry()\n",
    "unit.formatter.default_format = \"~\"\n",
    "unit.setup_matplotlib()\n",
    "\n",
    "# Physical constants\n",
    "e=-1.602176634e-19 * unit.C # electron charge\n",
    "m=9.109e-31 * unit.kg # electron mass\n",
    "hbar=6.62607015e-34/2/np.pi * unit.joule * unit.second # Planck constant\n",
    "phi=4 * unit.eV # Work function (see table)\n",
    "phi_joule=phi.to(\"joule\")\n",
    "U=5 *unit.V\n",
    "\n",
    "# Table working functions different metals\n",
    "\n",
    "# Metal F(eV)\n",
    "# (Work Function)\n",
    "# Ag (silver) 4.26\n",
    "# Al (aluminum) 4.28\n",
    "# Au (gold) 5.1\n",
    "# Cs (cesium) 2.14\n",
    "# Cu (copper) 4.65\n",
    "# Li (lithium) 2.9\n",
    "# Pb (lead) 4.25\n",
    "# Sn (tin) 4.42\n",
    "# Chromium 4.6\n",
    "# Molybdenum 4.37\n",
    "# Stainless Steel 4.4\n",
    "# Gold 4.8\n",
    "# Tungsten 4.5\n",
    "# Copper 4.5\n",
    "# Nickel 4.6\n",
    "\n",
    "# Distance range\n",
    "Distance_tip_sample=np.linspace(10e-13,2e-10,100)* unit.m\n",
    "Tunneling_current=U*np.exp(-2*np.sqrt(2*m*phi_joule)/hbar*Distance_tip_sample) /unit.V #please note: This is not the tunneling current as this formular gives just the proportionality. Calculating the current constant is difficult as there are for us unknown parameters\n",
    "Distance_tip_sample_nm=Distance_tip_sample.to(\"nm\")\n",
    "\n",
    "plt.plot(Distance_tip_sample_nm, Tunneling_current)\n",
    "plt.xlabel(f\"Distance tip sample [{Distance_tip_sample_nm.units:~P}]\")\n",
    "plt.ylabel(f\"Tunneling-Proportionality [arb. Unit]\")\n",
    "plt.xticks(ticks=np.linspace(0, 0.2, 5), labels=[f\"{x:.2f}\" for x in np.linspace(0, 0.2, 5)])\n",
    "#plt.yscale(\"log\")\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "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.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
