{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "82e7156b-15bb-4000-928d-a904e76fe1fe",
   "metadata": {},
   "source": [
    "Homework 6 - NUCE 2100\n",
    "\n",
    "**Dane Sabo**\n",
    "\n",
    "*October 29th, 2024*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "af61cdf6-cb10-43e3-81b5-703acbc893a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "def answer_print(question,string):\n",
    "    print('\\n=========FINAL ANSWER=========')\n",
    "    print(question+':')\n",
    "    print(string)\n",
    "    print('=========FINAL ANSWER=========\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd8f8915-17e4-414a-8465-b8b66d66c673",
   "metadata": {},
   "source": [
    "# Problem 1"
   ]
  },
  {
   "attachments": {
    "058eac28-5359-452f-a3af-cc45ec1a919c.png": {
     "image/png": "[encoded data, 136524 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "85659983-530e-4882-bf0b-13c15a1b05b6",
   "metadata": {},
   "source": [
    "![image.png](attachment:058eac28-5359-452f-a3af-cc45ec1a919c.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ecaad9e9-6ee3-4096-8bc6-4d07dbbe3802",
   "metadata": {},
   "outputs": [],
   "source": [
    "pitch = 0.563 #in\n",
    "od = 0.422 #in\n",
    "d_pellet = 0.367 #in\n",
    "r = 0.04\n",
    "t_water = 585 #f\n",
    "p_water = 2250 #psia\n",
    "phi = 1e14 #neutrons/cm/sec\n",
    "rho_fm = 10.5 #g/cm^3\n",
    "sigma_f = 230 #barns\n",
    "m_u235 = 235.0439 #amu\n",
    "m_u238 = 238.0508 #amu\n",
    "m_o = 15.994 #amu\n",
    "avo = 0.60225e24 #atoms/mol\n",
    "Q_fission = 200*0.95 #MeV"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "944868be-de1a-4cbd-9619-7eac8f07b152",
   "metadata": {},
   "source": [
    "## Part A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "9f577d98-27db-451c-a60e-bb03d24070af",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The fuel mass fraction is 0.937\n",
      "The fuel number density is 1.008e+21 atoms/cm^3\n",
      "\n",
      "=========FINAL ANSWER=========\n",
      "1A:\n",
      "The local volumetric heat generation rate is 1.554e+04 BTU/ft^3-hr\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#First, find f (fuel mass fraction)\n",
    "M_ff = m_u235\n",
    "M_nf = m_u238\n",
    "M_other = m_o\n",
    "\n",
    "f = (r*M_ff+(1-r)*M_nf)/(r*M_ff+(1-r)*M_nf+M_other) \n",
    "print(f'The fuel mass fraction is {f:.3f}')\n",
    "\n",
    "#Now, find the number density:\n",
    "i = 1 #one uranium for every UO2\n",
    "N_ff = avo/M_ff*(r*f*rho_fm)*i #atoms/cm^3\n",
    "print(f'The fuel number density is {N_ff:.3e} atoms/cm^3')\n",
    "\n",
    "#Now calculate volumetric heat rate (with unit conversions)\n",
    "q_ppprime = (N_ff*2.54**3) * (sigma_f/6.452e+24) * (phi*2.54*60*60) * (Q_fission*1.51857e-16)\n",
    "answer_print('1A',f'The local volumetric heat generation rate is {q_ppprime:.3e} BTU/ft^3-hr')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "442ee12b-da61-4bd5-8ba0-b0027012ac96",
   "metadata": {},
   "source": [
    "## Part B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "cf574d6a-da52-4bc3-8691-df9314c52376",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=========FINAL ANSWER=========\n",
      "1B:\n",
      "The local linear power is 3.346e-03 kW/ft\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Calculate area of fuel pellet\n",
    "A_pellet = (d_pellet/12)**2*np.pi/4 #ft^2\n",
    "q_eng = q_ppprime * A_pellet #BTU/ft-hr\n",
    "q = q_eng * 0.000293071 #kW/ft\n",
    "answer_print('1B',f'The local linear power is {q:.3e} kW/ft')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "43d9005c-2e91-48e7-ac77-efcaa886c36b",
   "metadata": {},
   "source": [
    "## Part C"
   ]
  },
  {
   "attachments": {
    "546a6454-5f52-4874-b291-f7ce3fa787f4.png": {
     "image/png": "[encoded data, 72680 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "a5c11675-0349-4779-b02a-9e590d6c9a2a",
   "metadata": {},
   "source": [
    "![image.png](attachment:546a6454-5f52-4874-b291-f7ce3fa787f4.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "ab38a583-abac-40a5-934d-f09bd2db8e7f",
   "metadata": {},
   "outputs": [],
   "source": [
    "def decay_heat_ratio(t_shutdown, t_operation):\n",
    "    return 0.066*(t_shutdown**(-0.2)-(t_operation+t_shutdown)**(-0.2))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a42b63d-dc53-455f-9c1e-6b3f55f89c30",
   "metadata": {},
   "source": [
    "## Part A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "3119b774-40ab-4598-bfe1-517ab3cf549a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.02256498080663735\n",
      "\n",
      "=========FINAL ANSWER=========\n",
      "2A:\n",
      " The decay heat formula yields 8.527e+01 MW.\n",
      " The graph from the ANS indicates about 1.512e+02 MW.\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "ratio_eq = decay_heat_ratio(2*60, 89*24*60*60)\n",
    "ratio_ans = 0.04\n",
    "power = 3779 #MW\n",
    "answer_print('2A', f' The decay heat formula yields {ratio_eq*power:.3e} MW.\\n The graph from the ANS indicates about {ratio_ans*power:.3e} MW.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4993f3ec-ba09-4634-aac3-4f39cf382b31",
   "metadata": {},
   "source": [
    "## Part B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "5a353c72-3a91-4eb2-a30c-65af14628be3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=========FINAL ANSWER=========\n",
      "2A:\n",
      " The decay heat formula yields 3.047e+01 MW.\n",
      " The graph from the ANS indicates about 3.401e+01 MW.\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "ratio_eq = decay_heat_ratio(140*60, 89*24*60*60)\n",
    "ratio_ans = 0.009\n",
    "power = 3779 #MW\n",
    "answer_print('2A', f' The decay heat formula yields {ratio_eq*power:.3e} MW.\\n The graph from the ANS indicates about {ratio_ans*power:.3e} MW.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddc77778-bed6-489e-bec7-1070c928f068",
   "metadata": {},
   "source": [
    "## Part C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "35215138-3a47-42bc-b702-adba0373eace",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=========FINAL ANSWER=========\n",
      "2A:\n",
      " The decay heat formula yields 1.563e-01 MW.\n",
      " The graph from the ANS indicates about 7.558e-02 MW.\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "ratio_eq = decay_heat_ratio(2*365*24*60*60, 89*24*60*60)\n",
    "ratio_ans = 2e-5 # Roughly... hard to estimate\n",
    "power = 3779 #MW\n",
    "answer_print('2A', f' The decay heat formula yields {ratio_eq*power:.3e} MW.\\n The graph from the ANS indicates about {ratio_ans*power:.3e} MW.')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bd7306c4-2240-48fd-b8b1-b9f793edc559",
   "metadata": {},
   "source": [
    "**EXPLANATION**:\n",
    "\n",
    "The ANS chart is experimental results and accounts for actinides effects on decay heat. The empirical estimate that is the curve fit is only that, an estimate. That being said, there may be some discrepancy in results here because the ANS chart can only be read so accurately. Some estimation of the power ratio has to happen that might not be perfect. "
   ]
  },
  {
   "attachments": {
    "26c90e40-c28e-45ed-86c8-4480887005a2.png": {
     "image/png": "[encoded data, 106564 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "94679fc0-2836-4973-8f29-0a97c8a95899",
   "metadata": {},
   "source": [
    "![image.png](attachment:26c90e40-c28e-45ed-86c8-4480887005a2.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fce5c667-36be-46c9-8183-fafe4b3f28a3",
   "metadata": {},
   "outputs": [],
   "source": [
    "t = 0.2 #in\n",
    "k = 10 #BTU/hr/ft/F\n",
    "q_ppprime = 5e7 #BTU/hr/ft^3\n",
    "h_left = 400 #BTU/hr/ft^2/F\n",
    "T_left = 700 #F\n",
    "h_right = 300 #BTU/hr/ft^2/F\n",
    "T_right = 700 #F\n",
    "x_left = 0 #ft\n",
    "x_right = 0.2/12 #ft"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "950dbab5-ece9-4f26-a8bf-8aca2a4cd947",
   "metadata": {},
   "source": [
    "## Part A\n",
    "\n",
    "$$ \\rho c_p \\frac{\\partial T}{\\partial t} = k \\nabla^2 T + q''' $$\n",
    "\n",
    "But because we're steady state $\\frac{\\partial T}{\\partial t} = 0$:\n",
    "\n",
    "$$ \\frac{-q'''}{k} = \\nabla^2 T $$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "85cf7fed-e3cd-41cf-ab69-c790f972c212",
   "metadata": {},
   "source": [
    "## Part B"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2992a36f-6bed-4245-acc1-675f31312a27",
   "metadata": {},
   "source": [
    "## Part C"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea13e251-33e4-4578-9ba1-27c31caff0b7",
   "metadata": {},
   "source": [
    "## Part D"
   ]
  }
 ],
 "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.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
