{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "82e7156b-15bb-4000-928d-a904e76fe1fe",
   "metadata": {},
   "source": [
    "Homework 7 - NUCE 2100\n",
    "\n",
    "**Dane Sabo**\n",
    "\n",
    "*November 5th, 2024*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "af61cdf6-cb10-43e3-81b5-703acbc893a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import sympy as sm\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": {
    "157098bb-2458-4cb5-87e1-6691918ea097.png": {
     "image/png": "[encoded data, 75304 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "85659983-530e-4882-bf0b-13c15a1b05b6",
   "metadata": {},
   "source": [
    "![image.png](attachment:157098bb-2458-4cb5-87e1-6691918ea097.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "517f0fc3-ddd4-4713-adf7-c30d0649b851",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Given Information\n",
    "n = 0.03\n",
    "D = 0.37/12 #in to ft\n",
    "t_cladding = 0.026/12 #in to ft\n",
    "t_gap = 2e-3/12 #in to ft\n",
    "q_prime = 13.5*3.412e3 #kW/ft to BTU/hr/ft\n",
    "T_bulk = 580 #F\n",
    "k_fuel = 1.2 #BTU/hr/ft/F\n",
    "k_cladding = 10.5 #BTU/hr/ft/F\n",
    "k_gap = 0.19 #BTU/hr/ft/F\n",
    "h = 6500 #BTU/hr/ft^2/F"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "15a7a1c5-f424-46d9-8c59-2e9a6e6243d7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "=========FINAL ANSWER=========\n",
      "Problem 1:\n",
      " The centerline temperature is 4095.69 F\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Assuming constant heat generation and fuel thermal conductivity:\n",
    "R_cladding_outer = D/2 + t_gap + t_cladding #ft\n",
    "R_cladding_inner = D/2 + t_gap #ft\n",
    "R_pellet = D/2 #ft\n",
    "h_gap = k_gap / (R_cladding_inner - D/2 + 14.4e-6) #BTU/hr/ft^2/F\n",
    "\n",
    "#Find f\n",
    "f = 0.96 #From slides\n",
    "\n",
    "\n",
    "T_max = f*q_prime*(1/2/np.pi/R_cladding_outer/h + \\\n",
    "                   np.log(R_cladding_outer/R_cladding_inner)/2/np.pi/k_cladding + \\\n",
    "                   1/2/np.pi/R_pellet/h_gap + \\\n",
    "                   1/4/np.pi/k_fuel) \\\n",
    "+ T_bulk\n",
    "\n",
    "answer_print('Problem 1', f' The centerline temperature is {T_max:.2f} F')"
   ]
  },
  {
   "attachments": {
    "650c587e-4e69-4294-8fa1-5139a4365804.png": {
     "image/png": "[encoded data, 22380 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "0e7e0092-2b89-466f-85fb-09862610a0f2",
   "metadata": {},
   "source": [
    "# Problem 2\n",
    "![image.png](attachment:650c587e-4e69-4294-8fa1-5139a4365804.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c7a6e14a-5694-4aa8-bd44-5b1ea1c095a8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The surface temperature is 628.50 C\n"
     ]
    }
   ],
   "source": [
    "#First, let's get to the temperature at the fuel pellet surface\n",
    "\n",
    "T_surf = f*q_prime*(1/2/np.pi/R_cladding_outer/h +\\\n",
    "                    np.log(R_cladding_outer/R_cladding_inner)/2/np.pi/k_cladding +\\\n",
    "                    1/2/np.pi/R_pellet/h_gap) +\\\n",
    "T_bulk\n",
    "\n",
    "print(f'The surface temperature is {(T_surf-32)*5/9:.2f} C')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7a4b53f-d223-46f6-82e4-468c9c664e34",
   "metadata": {},
   "source": [
    "$$ \\int_{T_{surf}}^{T_{max}} k_f dT = \\frac{f q'}{4 \\pi} $$\n",
    "\n",
    "$$ \\int_{0}^{T_{max}} k_f dT - \\int_0^{T_{surf}} k_f dT = \\frac{f q'}{4 \\pi} $$\n",
    "\n",
    "$$ \\int_{0}^{T_{max}} k_f dT  = \\frac{f q'}{4 \\pi} + \\int_0^{T_{surf}} k_f dT$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2db67093-bec9-495d-8250-9b401e44d2b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Lyon integral value for the maximum temperature is 98 W/cm\n",
      "\n",
      "=========FINAL ANSWER=========\n",
      "Problem 2:\n",
      "The max temperature is approximately 5072 F\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Lyon's Integral Values pulled from the slides given T_surf\n",
    "lyon_surf = 37.5*57.818 #W/cm -> BTU/hr/ft\n",
    "lyon_max = f*q_prime/4/np.pi + lyon_surf\n",
    "print(f'The Lyon integral value for the maximum temperature is {lyon_max/57.818:.0f} W/cm')\n",
    "\n",
    "answer_print('Problem 2', f'The max temperature is approximately {2800*9/5+32:.0f} F') #From slides, converted to F"
   ]
  },
  {
   "attachments": {
    "802911f2-5ab1-4743-8183-a4c3cf5e52fc.png": {
     "image/png": "[encoded data, 25108 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "db5b8c2b-fef7-4704-b435-453cd75a1191",
   "metadata": {},
   "source": [
    "# Problem 3\n",
    "![image.png](attachment:802911f2-5ab1-4743-8183-a4c3cf5e52fc.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "196cdf97-6ef8-467b-8f7e-564db35115c9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The surface temperature is 405.09 C\n",
      "The lyon integral value for the maximum temperature is 86 W/cm\n",
      "\n",
      "=========FINAL ANSWER=========\n",
      "Problem 3:\n",
      "The max temperature is approximately 4667 F\n",
      "=========FINAL ANSWER=========\n",
      "\n"
     ]
    }
   ],
   "source": [
    "h_gap_closed = 0.68*1e3 + k_gap/14.4e-6\n",
    "\n",
    "T_surf = f*q_prime*(1/2/np.pi/R_cladding_outer/h +\\\n",
    "                    np.log(R_cladding_outer/R_cladding_inner)/2/np.pi/k_cladding +\\\n",
    "                    1/2/np.pi/R_pellet/h_gap_closed) +\\\n",
    "T_bulk\n",
    "\n",
    "print(f'The surface temperature is {(T_surf-32)*5/9:.2f} C')\n",
    "\n",
    "lyon_surf = 24.75*57.818 #W/cm -> BTU/hr/ft\n",
    "lyon_max = f*q_prime/4/np.pi + lyon_surf\n",
    "print(f'The lyon integral value for the maximum temperature is {lyon_max/57.818:.0f} W/cm')\n",
    "\n",
    "answer_print('Problem 3', f'The max temperature is approximately {2575*9/5+32:.0f} F')"
   ]
  }
 ],
 "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
}
