{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "782581b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Importing relevant libraries\n",
    "\n",
    "import numpy as np\n",
    "from scipy import integrate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "946efaf2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Defining functions\n",
    "\n",
    "def surf_source(x):\n",
    "    return dep_rate / (1 + (x/H)**2)**2\n",
    "# Using relative film thickness distribution for surface source from https://doi.org/10.3390/coatings8090325\n",
    "\n",
    "def line_source(x):\n",
    "    return 0.5 * (np.arctan((a + x) / H) + np.arctan((a - x) / H)) + (a * H * (a**2 + H**2 - x**2)) / (((a - x)**2 + H**2) * ((a + x)**2 + H**2))\n",
    "# Calculated by intergrating the film thickness distribution for surface source from -a to a\n",
    "\n",
    "def line_source_norm(x):\n",
    "    return line_source(x) / line_source(0)\n",
    "# Maximum deposition rate when x = 0 - normalised to this"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "95ff0216",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Input parameters\n",
    "\n",
    "H = 0.08 # m - separation between source and substrate\n",
    "W = 1.2 # m - width of substrate\n",
    "W_s = 1.44 # m - width of linesource\n",
    "\n",
    "# Calculating half the width of the linesource\n",
    "\n",
    "a = W_s/2 # m - half width of substrate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "190ab2cb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Source separation = 8.0 cm\n",
      "Source width = 1.44 m\n",
      "Substrate width = 1.2 m\n",
      "Percentage thickness variation =  3.9750949877874753 %\n",
      "Deposition efficiency = 82.92032830350276 %\n"
     ]
    }
   ],
   "source": [
    "# Integrating line_source_norm function from -inf to inf, and from -W/2 to W/2 to calculate deposition efficiency\n",
    "\n",
    "Atot = integrate.quad(line_source_norm, -np.inf, np.inf)[0]\n",
    "Auseful = integrate.quad(line_source_norm, -W/2, W/2)[0]\n",
    "\n",
    "Eff = 100*Auseful/Atot # Deposition efficiency\n",
    "\n",
    "# Calculating variation in deposition rate between the centre of the substrate and the edge\n",
    "\n",
    "Var = 100*(1-line_source_norm(W/2)) # Thickness variation\n",
    "\n",
    "# Printing relevant deposition metrics\n",
    "\n",
    "print('Source separation =', H*100, 'cm')\n",
    "print('Source width =', W_s, 'm')\n",
    "print('Substrate width =', W, 'm')\n",
    "print('Percentage thickness variation = ', Var, '%')\n",
    "print('Deposition efficiency =', Eff, '%')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c19c7848",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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
}
