Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "name": "stdout",
  10. "output_type": "stream",
  11. "text": [
  12. "Populating the interactive namespace from numpy and matplotlib\n"
  13. ]
  14. }
  15. ],
  16. "source": [
  17. "# Imports & Constantes universelles\n",
  18. "%pylab inline\n",
  19. "from matplotlib import animation\n",
  20. "from IPython.display import HTML\n",
  21. "from ipywidgets import interact\n",
  22. "π = np.pi\n",
  23. "μ_0 = 4 * π * 10 ** (-7)"
  24. ]
  25. },
  26. {
  27. "cell_type": "code",
  28. "execution_count": 2,
  29. "metadata": {},
  30. "outputs": [
  31. {
  32. "data": {
  33. "application/vnd.jupyter.widget-view+json": {
  34. "model_id": "51eea72db3d546ecb70735d9d0c0b1e3",
  35. "version_major": 2,
  36. "version_minor": 0
  37. },
  38. "text/plain": [
  39. "interactive(children=(FloatSlider(value=0.2, description='E_0', max=0.6000000000000001, min=-0.2), IntSlider(v…"
  40. ]
  41. },
  42. "metadata": {},
  43. "output_type": "display_data"
  44. },
  45. {
  46. "data": {
  47. "text/plain": [
  48. "<function __main__.effet_de_peau(E_0, f, γ, N, Z, duree)>"
  49. ]
  50. },
  51. "execution_count": 2,
  52. "metadata": {},
  53. "output_type": "execute_result"
  54. }
  55. ],
  56. "source": [
  57. "def effet_de_peau(E_0, f, γ, N, Z, duree):\n",
  58. " \"\"\"\n",
  59. " Anime l’évolution temporelle de la pénétration d’un champ dans un matériau:\n",
  60. " - E_0: Amplitude du champ\n",
  61. " - f: fréquence du champ\n",
  62. " - γ: conductivité du matériau\n",
  63. " - N: nombre de vecteurs à afficher\n",
  64. " - Z: profondeur du dernier vecteur dans le matériau\n",
  65. " - duree : intervale de temps écoulé entre deux images successives, en ms\n",
  66. " \"\"\"\n",
  67. " \n",
  68. " def amplitude(t, z):\n",
  69. " \"\"\"\n",
  70. " Calcul de l’amplitude du champ à l’instant t et à une distance z de la surface\n",
  71. " \"\"\"\n",
  72. " ω = 2 * π * f # Pulsation du champ, en rad/s\n",
  73. " δ = sqrt(2 / (μ_0 * γ * ω)) # Épaisseur de peau, en m\n",
  74. " return E_0 * exp(-z / δ) * cos(ω * t + z / δ)\n",
  75. "\n",
  76. " def amplitudes(i, X):\n",
  77. " \"\"\"\n",
  78. " Calcule l’amplitude du champ à une liste de lieux de plus en plus profonds dans le matériau pour l’image i\n",
  79. " \"\"\"\n",
  80. " return [amplitude(i * duree / 1000, z) for z in X]\n",
  81. "\n",
  82. " X = np.linspace(0, Z, N) # Abscisses des vecteurs\n",
  83. " Y = np.zeros(N) # Ordonnées des vecteurs\n",
  84. " U = np.zeros(N) # Amplitude horizontale des vecteurs\n",
  85. " V = amplitudes(0, X) # Amplitude initiale verticale des vecteurs\n",
  86. " fig, ax = plt.subplots()\n",
  87. " Q = ax.quiver(X, Y, U, V, scale=1)\n",
  88. "\n",
  89. " def update_quiver(i, Q):\n",
  90. " V = amplitudes(i, X)\n",
  91. " Q.set_UVC(U, V)\n",
  92. " return Q,\n",
  93. "\n",
  94. " anim = animation.FuncAnimation(fig, update_quiver, fargs=(Q,), interval=50, blit=False)\n",
  95. " return HTML(anim.to_html5_video())\n",
  96. "\n",
  97. "\n",
  98. "interact(effet_de_peau, E_0=0.2, f=10, γ=60*10**6, N=10, Z=0.05, duree=1)"
  99. ]
  100. }
  101. ],
  102. "metadata": {
  103. "kernelspec": {
  104. "display_name": "Python 3",
  105. "language": "python",
  106. "name": "python3"
  107. },
  108. "language_info": {
  109. "codemirror_mode": {
  110. "name": "ipython",
  111. "version": 3
  112. },
  113. "file_extension": ".py",
  114. "mimetype": "text/x-python",
  115. "name": "python",
  116. "nbconvert_exporter": "python",
  117. "pygments_lexer": "ipython3",
  118. "version": "3.7.3"
  119. }
  120. },
  121. "nbformat": 4,
  122. "nbformat_minor": 2
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement