{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Joule heating model\n", "The thoretical information comes from [here](https://reference.wolfram.com/language/PDEModels/tutorial/Multiphysics/ModelCollection/JouleHeating.html). \n", "\n", "## Electroestatic model\n", "In this model the electric potential field $V(x,y,z)$ is assumed to be independent of the temperature $T$. That is, the electrical conductivity $G$ is kept at a constant value at all time. By Guass's law the stationary potential field satisfies Poisson's equation:\n", "\n", "$$\\nabla \\cdot (-G \\cdot \\nabla V)=0$$\n", "\n", "## Heat transfer model\n", "The heat equation is used to solve for the temperature field in a heat transfer model:\n", "\n", "$$\\rho C_p \\frac{dT}{dt}+\\rho C_p v\\cdot \\nabla T + \\nabla \\cdot(-k \\nabla T) = Q$$\n", " \n", "For a steady-state heat transfer model the transient term in the equation are set to zero. Since a solid is modeled, the internal velocity also vanishes and the heat equation simplifies to:\n", "\n", "$$ \\nabla \\cdot(-k \\nabla T) = Q $$\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Solving the PDE Model\n", "In order to solve the PDE model, first the electroestatic model will be solved first to simulate/obtain the potential field $V$ of the wire. The heat transfer model is then constructed to show the heating effect of the electric current.\n", "\n", "## The electroestatic model\n", "There are two types of the boundary conditions involved in the electrostatics model. At both ends of the wire an electric potential difference $V_0=0.2$ is applied.\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "from fenics import *" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAABJCAYAAAA9vFENAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAHCpJREFUeJztn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UC2sjaRhYLBY7JZSzkspDwOuBE5CiFYgIqU8Ji3P+l3gQ5rtDsR2KeWClPLf7ddJ4CWsDblFRSl2CLlyK2U7QFduJcCZWynXb70cUwdB2J7BnrbeBLyo0eZldq1UP4XZ/i3gUaDwdKX5CcL2LcAY8L/scNeTQoiaUrBdSjkAfBPoBYaAaSnlvxSR3asd05lVsRjv07wIIeqB3wee922pZkqxQzDkQAixGXga+KyUMv8Dd4sAIcQHgVEpZc9G21IAFcDNwD9IKW8C5rGz+xY7QogGrBHuFqwMAjVCiP+ysVZdHdgzsh8AfyelfHuj7cmmFDuEteRWUv+AfLmVvBxTB0HYjhCiEqsz+Ecp5U8DsNtlV3b9ucp4tP23gPuEEO9gTcvvEkL83xKxvR/ol1Kq2dhPsDoI3QRh+38Czkspx6SUKeCnwB1FZPdqx3SGWYrxPs3Ht4E3pZTf0mCnfjZ6EWOtf1gjs7exRjdqwWdPVplP417w+bH9eg/uRba3sRaQ8h6ziG0XWLHUb5Xaec/67Z0Et6gciO1YC4M77ddfBf66FGzHSjV/GmvtQGDFwv97sdjt+P6Pyb+o/HvFdM7z2P7nWAO3siCucy1t32gDCvyH/R6WmuYt4M/sz74O3Ge/3gT8P6xFtOPAtY7f/pn9u7M4VvlzHbMUbMdSNEjgFeBl+0/7TRLUeXd8fycBdQgBXjPvAU7a5/7/Aw0lZPvXgNeBV4HvAVVFZvc7WHnR5rBmY7vtz/fbNr8FPIG9ubbYbceaZUgs0Ye6Tz8e1PVe6J/ZqWwwGAwGoDTXEAwGg8EQAKZDMBgMBgNgOgSDwWAw2JgOwWAwGAyA6RAMBoPBYGM6BIPBYDAApkMwGAwGg43pEAwGg8EAwH8AaDlVDbUtrc4AAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "#Creating mesh and define function space\n", "Nx = 0.013\n", "Ny = 0.0015\n", "eleX = 10\n", "eleY = 5\n", "mesh = RectangleMesh(Point(0,0),Point(Nx,Ny),eleX, eleY,'left')\n", "V = FunctionSpace(mesh, 'P', 1)\n", "plot(mesh)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "#Boundary conditions\n", "tol = 1E-14 # tolerance for coordinate comparisons\n", "#at y=1\n", "def Dirichlet_boundary1(x, on_boundary):\n", " return on_boundary and abs(x[1] - Ny) < tol\n", "#at y=0\n", "def Dirichlet_boundary0(x, on_boundary):\n", " return on_boundary and abs(x[1] - 0) < tol\n", "#at x=0\n", "def Dirichlet_boundarx0(x, on_boundary):\n", " return on_boundary and abs(x[0] - 0) < tol\n", "#at x=20\n", "def Dirichlet_boundarx1(x, on_boundary):\n", " return on_boundary and abs(x[0] - Nx) < tol\n", "\n", "#bc0 = DirichletBC(V, Constant(0), Dirichlet_boundary0)\n", "#bc1 = DirichletBC(V, Constant(0), Dirichlet_boundary1) \n", "bc2 = DirichletBC(V, Constant(0), Dirichlet_boundarx0)\n", "bc3 = DirichletBC(V, Constant(0.003), Dirichlet_boundarx1)\n", "bcs = [bc2,bc3]" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAABJCAYAAAA9vFENAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAACO1JREFUeJzt3WuIXGcdx/Hvb++bxCZx9UXbBLulobB5Y2uo9YJUKySpmviiQgJCCylBTEXtC0kpiAYLFoWGklYJbTVWzcVYJNRqFVtQQZPGVmsujW4u2o2FXo0mNdf9++I8KZPJZs+zyZzZneH3gYUz5/yf5zz/PWfnP2eembOKCMzMzDomewBmZjY1uCCYmRnggmBmZokLgpmZAS4IZmaWuCC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Hwb+CfwMnAkIn5VyejPdyn5jNfnSEmfVagil7dJmgV8CvjNJY90HJ5UnuIkzQB+CnwpIv4z2eO5GJI+CbwSEX+a7LE0SBdwPfCdiLgOOAa05C3cJc2meOU6CFwBTJf02ckdldVKV24bgQci4kCV+5qsgjCR22Gc/YWU3Q4jp8+qVJEPkropisGPIuLxSkZ+vipy+RCwRNIhikvpj0n6YRWDH0MV+YwAIxFx9optK0WBqFoVuXwcOBgRr0bEKeBx4IOVjP58l5LPeH3Wvq3SrOeBKnI5az3w94hY24Bxjq/qyZYLTMB0AQcoXpWcnYCZXxezinMnYLak5fmcOzl2gGJCp7TPFstHFO9/rm31Y1PX9iaaO6lcST4UE3zXpuWvAd9qxVyA9wO7KeYORPEe9xem+rGp2X475ZPKt7RwLt+geFHY0ZRj0oydXOAXeAvFJ2f2A/ekdWuAJWm5D/gJxeTXDuDqmrb3pHb7qJl1H6vPVs2H4lMHAbwA/Dn9VH5iV3VsarbfRBMLQoXn2nuBnen4/AyY3cK5fB14EdgFPAb0tsixOURxq5yjFFdtQ2n9gpTLfmAd6Qu4rZYLxVVGUHyg5OxzwB1V5uBvKpuZGeBJZTMzS1wQzMwMcEEwM7PEBcHMzAAXBDMzS1wQzMwMcEEwM7PEBcHMzAD4P2YY2EixWfAwAAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "#4 Defining variational problem and its solution\n", "rho = 1.43E-7 #ohm*m\n", "G = 1/rho\n", "voltage = TrialFunction(V)\n", "v = TestFunction(V)\n", "f = Constant(0)\n", "a = dot(G*grad(voltage), grad(v))*dx\n", "L = f*v*dx\n", "\n", "# Compute solution\n", "voltage = Function(V)\n", "solve(a == L, voltage, bcs)\n", "\n", "# Plot solution and mesh\n", "plot(voltage,)\n", "#plot(mesh)\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "#saving the solution to a VTK file\n", "vtkfile = File('solution/sol.pvd')\n", "vtkfile << u" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Heat Transfer Model\n", "The electrical heat generation is coupled to the stationary heat equation as the source term $Q$ on the right hand side, which is known as the electromagnetic heat source.\n", "\n", "$$\\nabla \\cdot(-k\\nabla T)=0$$\n", "\n", "Joule's first law states that the heat generated within an object is equivalent to the product of its conductivity $G$ and the square of the potential gradient:\n", "\n", "$$Q=G|\\nabla V|^2$$" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([ Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(0),))))),\n", " Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(1),)))))], dtype=object)" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "Q = 1/rho*np.abs(grad(dot(voltage,voltage)))\n", "Q" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "ename": "RuntimeError", "evalue": "Don't know how to plot given object:\n [ Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(0),)))))\n Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(1),)))))]\nand projection failed:\n 'numpy.ndarray' object has no attribute 'ufl_domain'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/dolfin/common/plotting.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(object, *args, **kwargs)\u001b[0m\n\u001b[1;32m 427\u001b[0m \"piecewise linears.\")\n\u001b[0;32m--> 428\u001b[0;31m \u001b[0mobject\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mproject\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmesh\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmesh\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 429\u001b[0m \u001b[0mmesh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunction_space\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmesh\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/dolfin/fem/projection.py\u001b[0m in \u001b[0;36mproject\u001b[0;34m(v, V, bcs, mesh, function, solver_type, preconditioner_type, form_compiler_parameters)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[0;31m# Otherwise try extracting function space from expression\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 95\u001b[0;31m \u001b[0mV\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_extract_function_space\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmesh\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 96\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/dolfin/fem/projection.py\u001b[0m in \u001b[0;36m_extract_function_space\u001b[0;34m(expression, mesh)\u001b[0m\n\u001b[1;32m 150\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmesh\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 151\u001b[0;31m \u001b[0mdomain\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexpression\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mufl_domain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 152\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdomain\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mAttributeError\u001b[0m: 'numpy.ndarray' object has no attribute 'ufl_domain'", "\nDuring handling of the above exception, another exception occurred:\n", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mQ\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/dolfin/common/plotting.py\u001b[0m in \u001b[0;36mplot\u001b[0;34m(object, *args, **kwargs)\u001b[0m\n\u001b[1;32m 432\u001b[0m \u001b[0mmsg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Don't know how to plot given object:\\n %s\\n\"\u001b[0m\u001b[0;31m \u001b[0m\u001b[0;31m\\\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 433\u001b[0m \u001b[0;34m\"and projection failed:\\n %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 434\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 435\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 436\u001b[0m \u001b[0;31m# Plot\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mRuntimeError\u001b[0m: Don't know how to plot given object:\n [ Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(0),)))))\n Product(FloatValue(6993006.993006993), Abs(Indexed(Grad(Product(Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196), Coefficient(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 156), FiniteElement('Lagrange', triangle, 1)), 196))), MultiIndex((FixedIndex(1),)))))]\nand projection failed:\n 'numpy.ndarray' object has no attribute 'ufl_domain'" ] } ], "source": [] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting vtkplotter\n", "\u001b[31m ERROR: Could not find a version that satisfies the requirement vtkplotter (from versions: none)\u001b[0m\n", "\u001b[31mERROR: No matching distribution found for vtkplotter\u001b[0m\n", "\u001b[33mWARNING: You are using pip version 19.1, however version 21.2.1 is available.\n", "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n" ] } ], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }