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

Lossless Transmission Line

\n", "

\n", " The telegraph equation describing lossles propagation on a \n", " transmission line is solved and visualized with MatPlotLib:\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, 2021. \n", " Please respect copyright & acknowledge our work.\"\"\"\n", " \n", "# TelehMat.py: Lossless transmission line animation, Matplotlib\n", "\n", "%matplotlib notebook\n", "\n", "from numpy import *; from matplotlib import animation\n", "import numpy as np, matplotlib.pyplot as plt\n", "\n", "L = 0.1; C = 2.5; c = 1/sqrt(L*C); dt = 0.025;dx = 0.05\n", "R = (c*dt/dx)**2 \n", "V = np.zeros( (101, 3), float) # V(Nx, Nt)\n", "xx = 0\n", "fig = plt.figure() \n", "ax = fig.add_subplot(111,autoscale_on=False,xlim=(0,100), ylim=(-40,40))\n", "ax.grid() \n", "plt.title(\"Wave Transmission Via Telegrapher's Equations\")\n", "plt.xlabel(\"x\"); plt.ylabel (\"V(x,t)\")\n", "line, = ax.plot([],[], lw=2) # x axis, y values, linewidth=2\n", " \n", "def init(): \n", " line.set_data([],[])\n", " return line,\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", "V[:,0] = V[:,1]; V[:,1] = V[:,2] # Recycle array\n", " \n", "def animate(dum): \n", " i = arange(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", " line.set_data(i,V[i,2])\n", " V[:,0] = V[:,1]; V[:,1] = V[:,2] # Recycle array\n", " return line,\n", "ani = animation.FuncAnimation(fig, animate,init_func=init,frames=10000,\n", "\tinterval=20,blit=True) \n", "plt.show()" ] } ], "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 }