You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
27 KiB

  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# Joule heating model\n",
  8. "The thoretical information comes from [here](https://reference.wolfram.com/language/PDEModels/tutorial/Multiphysics/ModelCollection/JouleHeating.html). \n",
  9. "\n",
  10. "## Electroestatic model\n",
  11. "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",
  12. "\n",
  13. "$$\\nabla \\cdot (-G \\cdot \\nabla V)=0$$\n",
  14. "\n",
  15. "## Heat transfer model\n",
  16. "The heat equation is used to solve for the temperature field in a heat transfer model:\n",
  17. "\n",
  18. "$$\\rho C_p \\frac{dT}{dt}+\\rho C_p v\\cdot \\nabla T + \\nabla \\cdot(-k \\nabla T) = Q$$\n",
  19. " \n",
  20. "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",
  21. "\n",
  22. "$$ \\nabla \\cdot(-k \\nabla T) = Q $$\n",
  23. "\n"
  24. ]
  25. },
  26. {
  27. "cell_type": "markdown",
  28. "metadata": {},
  29. "source": [
  30. "# Solving the PDE Model\n",
  31. "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",
  32. "\n",
  33. "## The electroestatic model\n",
  34. "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",
  35. "\n",
  36. "\n"
  37. ]
  38. },
  39. {
  40. "cell_type": "code",
  41. "execution_count": 26,
  42. "metadata": {},
  43. "outputs": [],
  44. "source": [
  45. "from fenics import *"
  46. ]
  47. },
  48. {
  49. "cell_type": "code",
  50. "execution_count": 27,
  51. "metadata": {},
  52. "outputs": [
  53. {
  54. "data": {
  55. "text/plain": [
  56. "[<matplotlib.lines.Line2D at 0x7f2daacc7f98>,\n",
  57. " <matplotlib.lines.Line2D at 0x7f2daacb1128>]"
  58. ]
  59. },
  60. "execution_count": 27,
  61. "metadata": {},
  62. "output_type": "execute_result"
  63. },
  64. {
  65. "data": {
  66. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAABJCAYAAAA9vFENAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAHCpJREFUeJztnXtsXNd95z+Hj6E4FIfkDMnh25T1sh62Y0u2bLcpHHsLO01qB029dopFtoESx9lku2kehpwCeaFBWzQu0sJFF4Gd3U22eW0cLAw3hYu6zUOWZEl0HMuSLVu2LL7fFN/DGY1O/7j3jO8dDjmXc88lZ6TzAQjM48w9v3N57++c8zvf87tCSonBYDAYDGUbbYDBYDAYigPTIRgMBoMBMB2CwWAwGGxMh2AwGAwGwHQIBoPBYLAxHYLBYDAYANMhGAwGg8HGdAgGg8FgAEyHYDAYDAabio02YC00NjbK7u7ujTbDYDAYSoaenp5xKWWTl7Il1SF0d3dz8uTJNf/ua1/7mut9NBqloiL4po+Ojrreh8NhNm/evO71AjQ2NlJWFvyEMLvu2tpaqqur171eIQSNjY0IIda97vr6ekKh0LrXW1lZSX19/Ya0eaPuqU2bNhGJRAKvN5FIMDMz4/osFotRXl4eeN2qzV/5ylcK+r0Q4oLXsiXVIRTCpUuXln02OTmZeV1eXk5nZ2cgTiv74l1YWGBhYSHzPhaL0dTUpP0Gnpubc9UDMD4+nnkdCoXo6OigqqpKa72wvM2zs7PMzs5m3sfjcRoaGrS3ObteKSVjY2OZ9+FwmLa2NiorK7XWm6vuixcvut63t7cH4rSy602lUq42RyIRWlpatDstKeWyup33lBCCzs5OampqtNYLy9ucSCRIJBKZ99Fol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bbFyFmVKpVN6ykUhEq5opkUgwNTWVt5wKgeryIyrMtJo//vKXv1zQ9SyE6JFS7vdU9krvEJQ6YCXUSFyn05qbm2NwcDBvuVgspkXNpFBhpmzJaTahUEiLmsnJ9PS0p04iHo9rUTMpVJgp32g5HA5rUTMpVJjJi8Nsb2/X7rT6+/vzzsYikYhWp6XkptPT06uWE0JoUzMp1BpbPqLRqBY1k0KFmebn51ctp9YGdO4/mZmZYXh4OPPexz4Ezx2Cp5CREOJe4G+BcuBJKeVfZn1fBXwX2AdMAA9KKd+xv3sMOAikgT+RUj5nf/4d4IPAqJRyrxc7CsEpOz1w4IBrejgyMpKRyGXH8erq6rTJTg8dOuQKM/X19ZFIJJiYmCCRSGhTMymcstOtW7e62jw+Pk4ymeTChQva1ExOlOz04YcfdoWZ+vv7SaVSjIyMsLi46JoS65ixOWWn9fX1rnM9NTXFwsICFy5c0KZmcqJkpx/+8Idd51pJMAcGBrSqmRRKdvrII49krmPV5tnZWWZmZkgkEq4wU0dHhxanpWSnd955p6veoaEhpJT09fVpVTMplOz00UcfXbYGsri4yOTkJIuLi9rUTAo1sLzrrrvYu3fvMil3KpXiwoULWtVMiqKSnQohyoG/B34X6AdOCCGekVKecRQ7CExJKbcJIR4C/gp4UAixG3gI2AO0Af8qhNghpUwD/xt4AqsjWRfq6uqoq6tj716r/1laWnLF8V555ZXMTuja2tplcjE/EsyNUjOp2HixqZl6e3tzxsaNmmntqPUAo2a6stVM64GXbvNW4JyU8m0AIcQPgfsBZ4dwP/BV+/VPgCeEdVfdD/xQSrkEnBdCnLOPd1RK+UshRLeORhRKVVVVTrmY02kpCabaieh01H6cViFqJnVBX2lqJnUjGTXTladmUmEmo2bSr2YKAi8dQjvQ53jfDxxYqYyU8pIQYhqI2Z8fy/pte8HWBox
  67. "text/plain": [
  68. "<Figure size 432x288 with 1 Axes>"
  69. ]
  70. },
  71. "metadata": {
  72. "needs_background": "light"
  73. },
  74. "output_type": "display_data"
  75. }
  76. ],
  77. "source": [
  78. "#Creating mesh and define function space\n",
  79. "Nx = 0.013\n",
  80. "Ny = 0.0015\n",
  81. "eleX = 10\n",
  82. "eleY = 5\n",
  83. "mesh = RectangleMesh(Point(0,0),Point(Nx,Ny),eleX, eleY,'left')\n",
  84. "V = FunctionSpace(mesh, 'P', 1)\n",
  85. "plot(mesh)"
  86. ]
  87. },
  88. {
  89. "cell_type": "code",
  90. "execution_count": 28,
  91. "metadata": {},
  92. "outputs": [],
  93. "source": [
  94. "#Boundary conditions\n",
  95. "tol = 1E-14 # tolerance for coordinate comparisons\n",
  96. "#at y=1\n",
  97. "def Dirichlet_boundary1(x, on_boundary):\n",
  98. " return on_boundary and abs(x[1] - Ny) < tol\n",
  99. "#at y=0\n",
  100. "def Dirichlet_boundary0(x, on_boundary):\n",
  101. " return on_boundary and abs(x[1] - 0) < tol\n",
  102. "#at x=0\n",
  103. "def Dirichlet_boundarx0(x, on_boundary):\n",
  104. " return on_boundary and abs(x[0] - 0) < tol\n",
  105. "#at x=20\n",
  106. "def Dirichlet_boundarx1(x, on_boundary):\n",
  107. " return on_boundary and abs(x[0] - Nx) < tol\n",
  108. "\n",
  109. "#bc0 = DirichletBC(V, Constant(0), Dirichlet_boundary0)\n",
  110. "#bc1 = DirichletBC(V, Constant(0), Dirichlet_boundary1) \n",
  111. "bc2 = DirichletBC(V, Constant(0), Dirichlet_boundarx0)\n",
  112. "bc3 = DirichletBC(V, Constant(0.003), Dirichlet_boundarx1)\n",
  113. "bcs = [bc2,bc3]"
  114. ]
  115. },
  116. {
  117. "cell_type": "code",
  118. "execution_count": 31,
  119. "metadata": {},
  120. "outputs": [
  121. {
  122. "data": {
  123. "text/plain": [
  124. "<matplotlib.tri.tricontour.TriContourSet at 0x7f2daaa6a390>"
  125. ]
  126. },
  127. "execution_count": 31,
  128. "metadata": {},
  129. "output_type": "execute_result"
  130. },
  131. {
  132. "data": {
  133. "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAABJCAYAAAA9vFENAAAABHNC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. "<Figure size 432x288 with 1 Axes>"
  136. ]
  137. },
  138. "metadata": {
  139. "needs_background": "light"
  140. },
  141. "output_type": "display_data"
  142. }
  143. ],
  144. "source": [
  145. "#4 Defining variational problem and its solution\n",
  146. "rho = 1.43E-7 #ohm*m\n",
  147. "G = 1/rho\n",
  148. "voltage = TrialFunction(V)\n",
  149. "v = TestFunction(V)\n",
  150. "f = Constant(0)\n",
  151. "a = dot(G*grad(voltage), grad(v))*dx\n",
  152. "L = f*v*dx\n",
  153. "\n",
  154. "# Compute solution\n",
  155. "voltage = Function(V)\n",
  156. "solve(a == L, voltage, bcs)\n",
  157. "\n",
  158. "# Plot solution and mesh\n",
  159. "plot(voltage,)\n",
  160. "#plot(mesh)\n"
  161. ]
  162. },
  163. {
  164. "cell_type": "code",
  165. "execution_count": 22,
  166. "metadata": {},
  167. "outputs": [],
  168. "source": [
  169. "#saving the solution to a VTK file\n",
  170. "vtkfile = File('solution/sol.pvd')\n",
  171. "vtkfile << u"
  172. ]
  173. },
  174. {
  175. "cell_type": "markdown",
  176. "metadata": {},
  177. "source": [
  178. "# Heat Transfer Model\n",
  179. "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",
  180. "\n",
  181. "$$\\nabla \\cdot(-k\\nabla T)=0$$\n",
  182. "\n",
  183. "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",
  184. "\n",
  185. "$$Q=G|\\nabla V|^2$$"
  186. ]
  187. },
  188. {
  189. "cell_type": "code",
  190. "execution_count": 35,
  191. "metadata": {},
  192. "outputs": [
  193. {
  194. "data": {
  195. "text/plain": [
  196. "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",
  197. " 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)"
  198. ]
  199. },
  200. "execution_count": 35,
  201. "metadata": {},
  202. "output_type": "execute_result"
  203. }
  204. ],
  205. "source": [
  206. "import numpy as np\n",
  207. "Q = 1/rho*np.abs(grad(dot(voltage,voltage)))\n",
  208. "Q"
  209. ]
  210. },
  211. {
  212. "cell_type": "code",
  213. "execution_count": 34,
  214. "metadata": {},
  215. "outputs": [
  216. {
  217. "ename": "RuntimeError",
  218. "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'",
  219. "output_type": "error",
  220. "traceback": [
  221. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  222. "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
  223. "\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",
  224. "\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",
  225. "\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",
  226. "\u001b[0;31mAttributeError\u001b[0m: 'numpy.ndarray' object has no attribute 'ufl_domain'",
  227. "\nDuring handling of the above exception, another exception occurred:\n",
  228. "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
  229. "\u001b[0;32m<ipython-input-34-86a109355051>\u001b[0m in \u001b[0;36m<module>\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",
  230. "\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",
  231. "\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'"
  232. ]
  233. }
  234. ],
  235. "source": []
  236. },
  237. {
  238. "cell_type": "code",
  239. "execution_count": 20,
  240. "metadata": {},
  241. "outputs": [
  242. {
  243. "name": "stdout",
  244. "output_type": "stream",
  245. "text": [
  246. "Collecting vtkplotter\n",
  247. "\u001b[31m ERROR: Could not find a version that satisfies the requirement vtkplotter (from versions: none)\u001b[0m\n",
  248. "\u001b[31mERROR: No matching distribution found for vtkplotter\u001b[0m\n",
  249. "\u001b[33mWARNING: You are using pip version 19.1, however version 21.2.1 is available.\n",
  250. "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
  251. ]
  252. }
  253. ],
  254. "source": []
  255. },
  256. {
  257. "cell_type": "code",
  258. "execution_count": null,
  259. "metadata": {},
  260. "outputs": [],
  261. "source": []
  262. }
  263. ],
  264. "metadata": {
  265. "kernelspec": {
  266. "display_name": "Python 3",
  267. "language": "python",
  268. "name": "python3"
  269. },
  270. "language_info": {
  271. "codemirror_mode": {
  272. "name": "ipython",
  273. "version": 3
  274. },
  275. "file_extension": ".py",
  276. "mimetype": "text/x-python",
  277. "name": "python",
  278. "nbconvert_exporter": "python",
  279. "pygments_lexer": "ipython3",
  280. "version": "3.6.7"
  281. }
  282. },
  283. "nbformat": 4,
  284. "nbformat_minor": 2
  285. }