(* :Title: Smith Chart *) (* :Summary: This package contains functions that will produce a Smith Chart (Impedance) graphics object. *) (* :Author: William Anklam Microwave Technology Division, 2US-X Hewlett-Packard Company 1412 Fountaingrove Parkway Santa Rosa, CA. 95403 email: billa@sr.hp.com *) (* :Copyright: Copyright (c) 1992 Hewlett-Packard Company Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies and that both the above copyright notice and this permission notice appear in supporting documentation. Hewlett-Packard Company makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. *) (* :History: Revised by William Anklam, February 1993. Version 1.0 by William Anklam, September 1992. *) (* :Dependencies: Requires Mathematica 2.X. Compatibility with Mathematica 1.2 can be achieved by changing the Module[] and Evaluate[] function calls to the appropriate equivalents defined in MMA 1.2, i.e. Block[] and Release[]. SmithChart uses the functions PolarPlot[] and ParametricPlot[] from the standard Graphics packages supplied with Mathematica. *) BeginPackage["SmithChart`", "Graphics`Graphics`"] (* ------------------------------------------------------------------------- *) (* USAGE STATEMENTS and an EXAMPLE *) (* ------------------------------------------------------------------------- *) SmithChartGraphics::usage = "SmithChartGraphics returns the -Graphics- primitives required to plot a Smith Chart. SmithChartGraphics is meant to be used within the Show[] function so that the Smith Chart can be displayed along with data." (* For example, the following snippet of code generates some data to be plotted, formats it as real and imaginary pairs, assigns to s11plot the graphics primitives that would plot the data (but the actual plotting is delayed through the use of DisplayFunction -> Identity), the starting frequency will be highlighted by a large dot, then finally all the graphics are displayed in one fell swoop using the Show[] function: data = Table[ someFunc[f], {f, fmin, fmax, fstep}]; data = Map[ {Re[#], Im[#]}&, data ] //N; s11plot = ListPlot[data, PlotJoined->True, DisplayFunction->Identity]; startPoint = Graphics[ {PointSize[0.02], Point[ data[[1]] ]} ]; Show[SmithChartGraphics, s11plot, startPoint, PlotLabel -> "S11", AspectRatio->Automatic, DisplayFunction->$DisplayFunction]; *) SmithChart::usage = "SmithChart displays a Smith Chart by issuing the command Show[SmithChartGraphics, DisplayFunction->$DisplayFunction]." (* ------------------------------------------------------------------------- *) (* Start Private Context and begin function definitions *) Begin["`Private`"] (* Parametrize the resistive r=R/Zo contours *) SmithR[r_, t_] := { (Cos[t] + r)/(1 + r), Sin[t]/(1 + r) } (* Parametrize the reactive x=X/Zo contours *) SmithX[x_, t_] := { Cos[t]/x +1, (Sin[t] + 1)/x } SmithChartGraphics := Module[ {unitcircle, r1, r2, r3, x1, x2, x3, x4, x5, x6}, unitcircle = PolarPlot[1, {phi, 0, 2Pi}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; r1 = ParametricPlot[Evaluate[SmithR[1/2, t]], {t, 0, 2Pi}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; r2 = ParametricPlot[Evaluate[SmithR[1, t]], {t, 0, 2Pi}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; r3 = ParametricPlot[Evaluate[SmithR[2, t]], {t, 0, 2Pi}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x1 = ParametricPlot[Evaluate[SmithX[2,t]], {t, 3Pi/2, 51Pi/64}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x2 = ParametricPlot[Evaluate[SmithX[1,t]], {t, 3Pi/2, Pi}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x3 = ParametricPlot[Evaluate[SmithX[1/2,t]], {t, 3Pi/2, 617Pi/512}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x4 = ParametricPlot[Evaluate[SmithX[-2,t]], {t, 13Pi/64, -Pi/2}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x5 = ParametricPlot[Evaluate[SmithX[-1,t]], {t, 0, -Pi/2}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; x6 = ParametricPlot[Evaluate[SmithX[-1/2,t]], {t, -105Pi/512, -Pi/2}, PlotStyle->{Thickness[0.001]}, DisplayFunction->Identity]; Show[unitcircle, r1, r2, r3, x1, x2, x3, x4, x5, x6, Graphics[{ Thickness[0.001], Line[{ {-1,0}, {1,0} }] }], Axes->None, AspectRatio->Automatic, DisplayFunction->Identity] ] SmithChart := Show[SmithChartGraphics, DisplayFunction->$DisplayFunction] (* ------------------------------------------------------------------------- *) End[] Protect[SmithChart, SmithChartGraphics] EndPackage[]