{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "

Lossless Transmission Line Vpython

\n", "

\n", " The telegraph equation describing lossles propagation on a \n", " transmission line is solved and visualized with Vpython:\n", " \n", " $$\n", "\\frac{\\partial^2 V}{\\partial t^2}-v_p^2\\frac{\\partial^2 V}{\\partial x^2}=0, \\quad v_p= \\frac{1}{\\sqrt{LC}}.\n", "$$ " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "\"\"\" From \"COMPUTATIONAL PHYSICS\" & \"COMPUTER PROBLEMS in PHYSICS\"\n", " by RH Landau, MJ Paez, and CC Bordeianu (deceased)\n", " Copyright R Landau, Oregon State Unv, MJ Paez, Univ Antioquia, \n", " C Bordeianu, Univ Bucharest, 2017. \n", " Please respect copyright & acknowledge our work.\"\"\"\n", " \n", "# TelegraphViz.py: Lossless transmission line animation, Vpython\n", "\n", "%matplotlib notebook\n", "\n", "from vpython import *\n", "import numpy as np\n", "\n", "g = display(width = 600, height = 300, title='Telegrapher`s Eqnt')\n", "vibst = curve(x=list(range(0,101)), color=color.yellow,radius=0.5)\n", "L = 0.1; C = 2.5; c = 1/sqrt(L*C); dt = 0.025; dx = 0.05 \n", "R = (c*dt/dx)**2 # R = 1 for stabiity\n", "V = np.zeros( (101, 3), float) # Declare array\n", "xx = 0\n", "\n", "for i in arange (0,100):\n", " V[i,0] = 10*exp(-(xx**2)/0.1) \n", " xx = xx+dx \n", "for i in range(1, 100): V[i, 2] = V[i,0] + R*(V[i+1,1] + V[i-1,1] - 2*V[i,1])\n", " \n", "rate(100)\n", "vibst.visible=True\n", "V[: ,0] = V[: ,1]; V[: ,1] = V[: ,2] # Recycle array#\n", " \n", "for j in range(0,250):\n", " rate(20) # Delay plot, large = slow\n", " vibst.clear()\n", " for i in range(1, 100): \n", " V[i, 2] = 2.*V[i,1]-V[i,0]+R*(V[i+1,1]+V[i-1,1]-2*V[i,1])\n", " vibst.append(pos=vec( 2.*i - 100.0 , V[i, 2],0))\n", " vibst.visible=True\n", " V[: ,0] = V[: ,1]; V[: ,1] = V[: ,2] # Recycle array" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.13" } }, "nbformat": 4, "nbformat_minor": 2 }