This commit is contained in:
Dane Sabo 2024-10-29 16:44:38 -04:00
parent 5b7b4a5a9e
commit 30aecda6dc

View File

@ -14,7 +14,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 28, "execution_count": 1,
"id": "af61cdf6-cb10-43e3-81b5-703acbc893a0", "id": "af61cdf6-cb10-43e3-81b5-703acbc893a0",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -52,7 +52,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 2,
"id": "ecaad9e9-6ee3-4096-8bc6-4d07dbbe3802", "id": "ecaad9e9-6ee3-4096-8bc6-4d07dbbe3802",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -83,7 +83,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 3,
"id": "9f577d98-27db-451c-a60e-bb03d24070af", "id": "9f577d98-27db-451c-a60e-bb03d24070af",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -131,7 +131,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 4,
"id": "cf574d6a-da52-4bc3-8691-df9314c52376", "id": "cf574d6a-da52-4bc3-8691-df9314c52376",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -179,7 +179,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 21, "execution_count": 5,
"id": "ab38a583-abac-40a5-934d-f09bd2db8e7f", "id": "ab38a583-abac-40a5-934d-f09bd2db8e7f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -198,7 +198,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 25, "execution_count": 6,
"id": "3119b774-40ab-4598-bfe1-517ab3cf549a", "id": "3119b774-40ab-4598-bfe1-517ab3cf549a",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -206,7 +206,6 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"0.02256498080663735\n",
"\n", "\n",
"=========FINAL ANSWER=========\n", "=========FINAL ANSWER=========\n",
"2A:\n", "2A:\n",
@ -234,7 +233,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 26, "execution_count": 7,
"id": "5a353c72-3a91-4eb2-a30c-65af14628be3", "id": "5a353c72-3a91-4eb2-a30c-65af14628be3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -269,7 +268,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 8,
"id": "35215138-3a47-42bc-b702-adba0373eace", "id": "35215138-3a47-42bc-b702-adba0373eace",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -319,7 +318,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 37, "execution_count": 9,
"id": "fce5c667-36be-46c9-8183-fafe4b3f28a3", "id": "fce5c667-36be-46c9-8183-fafe4b3f28a3",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@ -336,8 +335,9 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"id": "950dbab5-ece9-4f26-a8bf-8aca2a4cd947", "id": "478f0c67-cd5b-4323-940d-fdf3ced0e2f6",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Part A\n", "## Part A\n",
@ -346,41 +346,55 @@
"\n", "\n",
"But because we're steady state $\\frac{\\partial T}{\\partial t} = 0$:\n", "But because we're steady state $\\frac{\\partial T}{\\partial t} = 0$:\n",
"\n", "\n",
"$$ -q''' = k \\nabla^2 T $$\n", "$$ 0 = k \\nabla^2 T + q''' $$\n",
"\n", "\n",
"And because we're in one dimension...\n", "And because we're in one dimension...\n",
"\n", "\n",
"$$ k \\frac{d^2 T}{dx^2} = -q'''$$\n", "$$ k \\frac{d^2 T}{dx^2} + q''' = 0$$\n",
"\n", "\n",
"Now we integrate:\n", "Now we integrate:\n",
"\n", "\n",
"$$ k\\frac{dT}{dx} = -q'''x + C_1 $$\n", "$$ k\\frac{dT}{dx} + q'''x + C_1 = 0 $$\n",
"\n",
"$$ \\frac{dT}{dx} = -\\frac{ q'''x + C_1}{k} $$\n",
"\n", "\n",
"and integrate again:\n", "and integrate again:\n",
"\n", "\n",
"$$ kT(x) = -\\frac{q'''x^2}{2} + C_1 x + C_2 $$\n" "$$ T(x) = -(\\frac{ q'''}{2k} x^2 + \\frac{C_1}{k} x + C_2) $$\n"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "d00a9406-b75b-4227-a9c4-fe4cdc194e98", "id": "8bc55c33-7c5c-4596-ad22-b3482eac3a4f",
"metadata": {}, "metadata": {},
"source": [ "source": [
"This gives us our governing equation. Now we need to solve for our boundary conditions. We do this first on the left side:\n", "This gives us our governing equation. Now we need to solve for our boundary conditions. We do this first on the left side:\n",
"$$ k\\frac{dT}{dx}_{x=0} = h_\\text{left} (T(0) - T_\\text{left})$$\n", "$$ -k\\frac{dT}{dx}_{x=0} = h_\\text{left} ( T_\\text{left}- T(0))$$\n",
"\n", "\n",
"$$ C_1 = h_\\text{left} (C_2/k - T_\\text{left})$$\n", "$$ -k(-q''' \\times 0 / k - C_1/k) = h_\\text{left} (T_\\text{left} - C_2)$$\n",
"\n", "\n",
"$$ C_1 = h_\\text{left} (T_\\text{left} - C_2)$$"
]
},
{
"cell_type": "markdown",
"id": "40964535-3127-4082-bdc3-9226e7d5a780",
"metadata": {},
"source": [
"And now for our right side:\n", "And now for our right side:\n",
"\n", "\n",
"$$ k\\frac{dT}{dx}_{x=0.2/12 \\text{[ft]}} = h_\\text{right} (T(0.2/12)\\text{[ft]} - T_\\text{right})$$\n", "$$ -k\\frac{dT}{dx}_{x=0.2/12 \\text{[ft]}} = h_\\text{right} (T_\\text{right} - T(0.2/12)\\text{[ft]}) $$\n",
"\n",
"$$ -k \\left(-\\frac{q''' x_\\text{right}+ C_1}{k}\\right) = h_\\text{right} (T_\\text{right} + (\\frac{ q'''}{2k} x_\\text{right}^2 + \\frac{C_1}{k} x_\\text{right} + C_2)) $$\n",
"\n",
"$$ q''' x_\\text{right}+ C_1 = h_\\text{right} (T_\\text{right} + (\\frac{ q'''}{2k} x_\\text{right}^2 + \\frac{C_1}{k} x_\\text{right} + C_2)) $$\n",
"\n", "\n",
"Now at this point I'm going to introduce SymPy to do the algebra heavy lifting. We can get away with this because I've organized all the units to be compatible when writing the code cell above:" "Now at this point I'm going to introduce SymPy to do the algebra heavy lifting. We can get away with this because I've organized all the units to be compatible when writing the code cell above:"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 41, "execution_count": 37,
"id": "0766e4d9-1f49-4449-a35d-05de86a3580e", "id": "0766e4d9-1f49-4449-a35d-05de86a3580e",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -396,10 +410,10 @@
{ {
"data": { "data": {
"text/latex": [ "text/latex": [
"$\\displaystyle C_{1} = 40 C_{2} - 280000$" "$\\displaystyle - C_{1} = 280000 - 40 C_{2}$"
], ],
"text/plain": [ "text/plain": [
"Eq(C_1, 40*C_2 - 280000)" "Eq(-C_1, 280000 - 40*C_2)"
] ]
}, },
"metadata": {}, "metadata": {},
@ -417,10 +431,10 @@
{ {
"data": { "data": {
"text/latex": [ "text/latex": [
"$\\displaystyle C_{1} - 833333.333333333 = 0.5 C_{1} + 30 C_{2} - 418333.333333333$" "$\\displaystyle C_{1} + 833333.333333333 = 0.5 C_{1} + 300 C_{2} + 418333.333333333$"
], ],
"text/plain": [ "text/plain": [
"Eq(C_1 - 833333.333333333, 0.5*C_1 + 30*C_2 - 418333.333333333)" "Eq(C_1 + 833333.333333333, 0.5*C_1 + 300*C_2 + 418333.333333333)"
] ]
}, },
"metadata": {}, "metadata": {},
@ -430,10 +444,10 @@
"source": [ "source": [
"C_1, C_2 = sm.symbols('C_1, C_2')\n", "C_1, C_2 = sm.symbols('C_1, C_2')\n",
"\n", "\n",
"left_BC = sm.Eq(C_1, h_left*(C_2/k - T_left))\n", "left_BC = sm.Eq(C_1, h_left*(T_left - C_2/k ))\n",
"display('Left BC', left_BC)\n", "display('Left BC', left_BC)\n",
"\n", "\n",
"right_BC = sm.Eq(k*(-q_ppprime*x_right + C_1)/k, h_right*((-q_ppprime*x_right**2/2 + C_1*x_right + C_2)/k - T_right))\n", "right_BC = sm.Eq(q_ppprime*x_right + C_1, h_right*(T_right + (q_ppprime*x_right**2/2/k + C_1/k*x_right + C_2)))\n",
"display('Right BC', right_BC)" "display('Right BC', right_BC)"
] ]
}, },
@ -447,14 +461,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 51, "execution_count": 38,
"id": "765d2f17-7d1a-43a8-8b46-88ffed3ddaa3", "id": "765d2f17-7d1a-43a8-8b46-88ffed3ddaa3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"{C_1: -2500000.00000000, C_2: -55500.0000000000}" "{C_1: -240714.285714286, C_2: 982.142857142858}"
] ]
}, },
"metadata": {}, "metadata": {},
@ -476,12 +490,71 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 39,
"id": "736b23d6-b2b3-43fe-bc16-5b1e5ae5c07b", "id": "736b23d6-b2b3-43fe-bc16-5b1e5ae5c07b",
"metadata": {}, "metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle -997.420634920635$"
],
"text/plain": [
"-997.420634920635"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T = lambda x: (-q_ppprime*x**2/2 + soln[C_1]*x + soln[C_2])/k\n",
"T(0.2/12)"
]
},
{
"cell_type": "markdown",
"id": "38a944a7-43bd-425d-a5d9-b502f5fc1246",
"metadata": {},
"source": [
"Just trying some stuff"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "7af1e713-fc89-4679-99aa-f2bbacfb0c8e",
"metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"T = lambda x: -q_ppprime*x**2/2 + soln[C_1]*x + " "x = sm.symbols('x')\n",
"T = sm.Function('T')(x)\n",
"gov_eq = sm.Eq(0,T.diff(x)+q_ppprime)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "5edad66f-d4c8-4b51-8c92-343f83f65944",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle T{\\left(x \\right)} = C_{1} - 50000000.0 x$"
],
"text/plain": [
"Eq(T(x), C1 - 50000000.0*x)"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sm.dsolve(gov_eq)"
] ]
}, },
{ {
@ -500,6 +573,30 @@
"## Part C" "## Part C"
] ]
}, },
{
"cell_type": "code",
"execution_count": 24,
"id": "ca0c2b96-652e-4f67-81b0-f98aecfb1707",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"=========FINAL ANSWER=========\n",
"3C:\n",
"At the left face: -5550 F \n",
"At the right face:-10411 F\n",
"=========FINAL ANSWER=========\n",
"\n"
]
}
],
"source": [
"answer_print('3C',f'At the left face: {T(x_left):.0f} F \\nAt the right face:{T(x_right):.0f} F')"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "ea13e251-33e4-4578-9ba1-27c31caff0b7", "id": "ea13e251-33e4-4578-9ba1-27c31caff0b7",