{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "40aefd93-ffbb-4a7f-9cdf-df0b371de0d1",
   "metadata": {},
   "source": [
    "# Exemplos de Análise dimensional usando o pacote Python BuckinghamPi"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a565a198-ed48-41c7-9630-5dd1631cd50d",
   "metadata": {},
   "outputs": [],
   "source": [
    "from buckinghampy import BuckinghamPi"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e056712-3843-419e-bb71-fa0cd59bf296",
   "metadata": {},
   "source": [
    "## Transferência de calor de um corpo aquecido\n",
    "\n",
    "Um corpo com dimensão característica $a$ submetido a um fluido com capacidade térmica $c$ e condutividade térmica $k$ é mantido a uma temperatura $\\theta$ acima da temperatura do fluido. Qual a taxa de transferência de calor deste corpo?\n",
    "\n",
    "| Nome da grandeza  |  Símbolo  | Dimensões |\n",
    "|:----------------  | --------  | --------- |\n",
    "| Taxa de transferência de calor | $h$ | $HT^{-1}$ |\n",
    "| Dimensão linear do corpo       | $a$ | $L$ |\n",
    "| Velocidade do escoamento       | $v$ | $LT^{-1}$ |\n",
    "| Diferença de temperatura       | $\\theta$ | $\\Theta$ |\n",
    "| Capacidade de calor do fluido  | $c$  | $HL^{-3}\\Theta^{-1}$ |\n",
    "| Condutividade térmica do fluido | $k$ | $HL^{-1}T^{-1}\\Theta^{-1}$ |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e9e644c5-1c46-48fb-88e3-522d10e38465",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }1: \\quad\\pi_1 = \\frac{a \\sqrt{c} \\sqrt{v} \\sqrt{θ}}{\\sqrt{h}}\\quad\\pi_2 = \\frac{k \\sqrt{θ}}{\\sqrt{c} \\sqrt{h} \\sqrt{v}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }2: \\quad\\pi_1 = \\frac{a k θ}{h}\\quad\\pi_2 = \\frac{c h v}{k^{2} θ}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }3: \\quad\\pi_1 = \\frac{a c v}{k}\\quad\\pi_2 = \\frac{k^{2} θ}{c h v}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }4: \\quad\\pi_1 = \\frac{a^{2} c v θ}{h}\\quad\\pi_2 = \\frac{a k θ}{h}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }5: \\quad\\pi_1 = \\frac{a c v}{k}\\quad\\pi_2 = \\frac{a k θ}{h}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }6: \\quad\\pi_1 = \\frac{a^{2} c v θ}{h}\\quad\\pi_2 = \\frac{k}{a c v}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "calor = BuckinghamPi()\n",
    "calor.add_variable(name=\"h\", dimensions='H*T^(-1)')\n",
    "calor.add_variable(name=\"a\", dimensions='L')\n",
    "calor.add_variable(name=\"v\", dimensions='L*T^(-1)')\n",
    "calor.add_variable(name=\"θ\", dimensions='Θ')\n",
    "calor.add_variable(name=\"c\", dimensions='H*L^(-3)*Θ^(-1)')\n",
    "calor.add_variable(name=\"k\", dimensions='H*L^(-1)*T^(-1)*Θ^(-1)')\n",
    "calor.generate_pi_terms()\n",
    "calor.print_all()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "185bf0e7-5bd0-4e85-b704-1db06535ff64",
   "metadata": {},
   "source": [
    "### Escolhemos um conjunto\n",
    "\n",
    "Conjunto 5:\n",
    "\n",
    "$$\\Pi_1 = \\frac{a c v}{k} \\qquad \\Pi_2 = \\frac{a k \\theta}{h}$$\n",
    "\n",
    "$$\\Pi_2 = \\Pi_2\\left(\\Pi_1\\right)$$\n",
    "\n",
    "\n",
    "Ou seja: \n",
    "$$ h = k a \\theta F\\left(\\frac{a c v}{k} \\right) $$\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6b780449-90eb-4a3f-bd2f-cb3231766622",
   "metadata": {},
   "source": [
    "### Problemas: aqui consideramos 4 grandezas independentes\n",
    "\n",
    "Mas e se considerarmos apenas 3 independentes?\n",
    "\n",
    "Como? Temperatura como energia cinética média, então temos um resultado diferente!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "008fb322-0c45-4b0f-9f23-f29ba3cc64f0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }1: \\quad\\pi_1 = \\frac{a h}{v θ}\\quad\\pi_2 = c θ^{3}\\quad\\pi_3 = \\frac{a^{2} k}{v}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }2: \\quad\\pi_1 = \\frac{a \\sqrt[3]{c} h}{v}\\quad\\pi_2 = \\sqrt[3]{c} θ\\quad\\pi_3 = \\frac{a^{2} k}{v}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }3: \\quad\\pi_1 = \\frac{h}{a k θ}\\quad\\pi_2 = \\frac{v}{a^{2} k}\\quad\\pi_3 = c θ^{3}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }4: \\quad\\pi_1 = \\frac{\\sqrt[3]{c} h}{a k}\\quad\\pi_2 = \\frac{v}{a^{2} k}\\quad\\pi_3 = \\sqrt[3]{c} θ\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }5: \\quad\\pi_1 = \\frac{h}{\\sqrt{k} \\sqrt{v} θ}\\quad\\pi_2 = \\frac{a \\sqrt{k}}{\\sqrt{v}}\\quad\\pi_3 = c θ^{3}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }6: \\quad\\pi_1 = \\frac{\\sqrt[3]{c} h}{\\sqrt{k} \\sqrt{v}}\\quad\\pi_2 = \\frac{a \\sqrt{k}}{\\sqrt{v}}\\quad\\pi_3 = \\sqrt[3]{c} θ\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }7: \\quad\\pi_1 = \\frac{a h}{v θ}\\quad\\pi_2 = c θ^{3}\\quad\\pi_3 = \\frac{k v θ^{2}}{h^{2}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }8: \\quad\\pi_1 = \\frac{a \\sqrt[3]{c} h}{v}\\quad\\pi_2 = \\sqrt[3]{c} θ\\quad\\pi_3 = \\frac{k v}{c^{\\frac{2}{3}} h^{2}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }9: \\quad\\pi_1 = \\frac{a \\sqrt{k}}{\\sqrt{v}}\\quad\\pi_2 = \\frac{\\sqrt{k} \\sqrt{v} θ}{h}\\quad\\pi_3 = \\frac{c h^{3}}{k^{\\frac{3}{2}} v^{\\frac{3}{2}}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }10: \\quad\\pi_1 = \\frac{a k θ}{h}\\quad\\pi_2 = \\frac{k v θ^{2}}{h^{2}}\\quad\\pi_3 = c θ^{3}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }11: \\quad\\pi_1 = \\frac{a k}{\\sqrt[3]{c} h}\\quad\\pi_2 = \\frac{k v}{c^{\\frac{2}{3}} h^{2}}\\quad\\pi_3 = \\sqrt[3]{c} θ\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }12: \\quad\\pi_1 = \\frac{v θ}{a h}\\quad\\pi_2 = c θ^{3}\\quad\\pi_3 = \\frac{a k θ}{h}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }13: \\quad\\pi_1 = \\frac{v}{a \\sqrt[3]{c} h}\\quad\\pi_2 = \\sqrt[3]{c} θ\\quad\\pi_3 = \\frac{a k}{\\sqrt[3]{c} h}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }14: \\quad\\pi_1 = \\frac{v}{a^{2} k}\\quad\\pi_2 = \\frac{a k θ}{h}\\quad\\pi_3 = \\frac{c h^{3}}{a^{3} k^{3}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }15: \\quad\\pi_1 = \\frac{v θ}{a h}\\quad\\pi_2 = \\frac{a^{3} c h^{3}}{v^{3}}\\quad\\pi_3 = \\frac{a^{2} k}{v}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "calor1 = BuckinghamPi()\n",
    "calor1.add_variable(name=\"h\", dimensions='H*T^(-1)')\n",
    "calor1.add_variable(name=\"a\", dimensions='L')\n",
    "calor1.add_variable(name=\"v\", dimensions='L*T^(-1)')\n",
    "calor1.add_variable(name=\"θ\", dimensions='H')  # SÓ MODIFIQUEI AQUI!!!!\n",
    "calor1.add_variable(name=\"c\", dimensions='H^(-3)')\n",
    "calor1.add_variable(name=\"k\", dimensions='L^(-1)*T^(-1)')\n",
    "calor1.generate_pi_terms()\n",
    "calor1.print_all()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "83332066-f8c9-4f56-b9c6-d101b40642fc",
   "metadata": {},
   "source": [
    "### Selecionando o conjunto 3:\n",
    "\n",
    "$$\\Pi_1 = \\frac{h}{k a \\theta} \\qquad \\Pi_2 = \\frac{v}{k a^2} \\qquad \\Pi_3 = c a^3 $$\n",
    "\n",
    "ou seja:\n",
    "\n",
    "$$ h = k a \\theta F\\left(\\frac{v}{k a^2}, c a^3\\right) $$"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19dcbdd6-a53d-4c57-b50c-84fc907d74ad",
   "metadata": {},
   "source": [
    "## Aplicações em Remo\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bdbcfb3d-c51b-45ba-a410-3b664b3af30e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }1: \\quad\\pi_1 = \\frac{G^{\\frac{2}{9}} \\sqrt[3]{\\rho} v}{\\sqrt[3]{A} \\sqrt[9]{N}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }2: \\quad\\pi_1 = \\frac{G \\rho^{\\frac{3}{2}} v^{\\frac{9}{2}}}{A^{\\frac{3}{2}} \\sqrt{N}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }3: \\quad\\pi_1 = \\frac{G^{\\frac{2}{3}} \\rho v^{3}}{A \\sqrt[3]{N}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\text{Set }4: \\quad\\pi_1 = \\frac{A^{3} N}{G^{2} \\rho^{3} v^{9}}\\quad$"
      ],
      "text/plain": [
       "<IPython.core.display.Math object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "---"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "remo = BuckinghamPi()\n",
    "remo.add_variable(name='v', dimensions='V')\n",
    "remo.add_variable(name='G', dimensions='L^3*N^(-1)')\n",
    "remo.add_variable(name='A', dimensions='R*V^3*L^2*N^(-1)')\n",
    "remo.add_variable(name='rho', dimensions='R')\n",
    "remo.add_variable(name='N', dimensions='N')\n",
    "remo.generate_pi_terms()\n",
    "remo.print_all()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fa65507c-583c-4e14-8672-c99ff96402d3",
   "metadata": {},
   "source": [
    "### Escolhendo o conjunto 1\n",
    "\n",
    "$$\\Pi = \\frac{G^{2/9}\\rho^{1/3} v }{A^{1/3} N^{1/9}} \\quad\\longrightarrow\\quad v = const \\cdot \\frac{A^{1/3}}{\\rho^{1/3}G^{2/9}}\\cdot N^{1/9}$$\n",
    "\n",
    "Para uma distância fixa, 2000 m por exemplo, o tempo deve ser proporcional a $N^{-1/9}$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "98355c6e-ed1a-40f7-913b-af7ae53b89b8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c176d8d5-2305-4dc0-ba6e-e0ea62f10eda",
   "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.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
