[ANN] SmithChart.jl: Visualize Smith charts with Makie.jl

Hello, I’m excited to announce the release of SmithChart.jl, a new package that brings interactive Smith charts to the Makie.jl ecosystem. This project was developed as a way to learn and explore the powerful capabilities of Makie.jl, so it may have many aspects to improve. As this is my first Julia (and no Julia) package, I welcome all feedback and suggestions!

What is a Smith Chart?

For those unfamiliar, the Smith chart is a tool for visualizing impedance, admitance, reflection coefficients and more in RF engineering. It’s widely used for designing matching networks, transmission lines, and other RF components. You can learn more about it here (Wikipedia).

What SmithChart.jl Offers

  • Interactive Smith Charts: Built on Makie.jl, SmithChart.jl allows for visualization and exploration of impedance and reflection data.
  • SmithAxis Block: Provides a dedicated SmithAxis block, similar to Axis or PolarAxis, for drawing the Smith chart grid.
  • smithplot! and smithscatter! Functions: These functions are used to plot data on the Smith chart and have the same attributes as Makie’s lines! and scatter! respectively. They also include a convenient reflection keyword, allowing you to plot reflection data directly without manual conversion. Both functions feature a customised DataInspector (see examples below).
  • vswr! Function: plot constant VSWR circles on the Smith chart using vswr!.
  • Normalized Data: Currently, the package assumes that impedance or admittance values are already normalized.
  • Interactive Data Markers: Add and remove data markers with a double-click directly on the plots using the datamarkers function.
  • Customizable Grid: Offers extensive customization options for the Smith chart grid, including:
    • Tick positions for constant resistance and reactance circles.
    • Color and linestyle control for the grid lines.
    • Line cutting at intersections to prevent visual clutter.
  • Dynamic Text Annotations: An optional feature allows tick annotations to move dynamically while zooming to keep them visible. This functionality is still under development and may need further refinement.

Examples

smithplot! behaves like lines! for styling. This example shows how the color attribute can be used to create a color gradient along the line. The DataInspector displays the value and frequency if specified.

using SmithChart
using GLMakie # Select Backend 
fig = Figure()
ax = SmithAxis(fig[1, 1]; cutgrid = true, subgrid = true, title = "Variable Length Lossy Transmission Line")
# Lossy transmission line
Zo = 50
Zl = 100 + 50im
f = 3.0e9
λ = 3.0e8/f
σ = 6.5
β = 2*pi/λ
s = σ + β*im
l = range(0,λ,101)
# Normalized Impedance
z = [(Zl+(Zo*tanh(s*li)))/(Zo+(Zl*tanh(s*li))) for li in l]
# Draw lines on the Smith Chart
smithplot!(ax, z, reflection = false, color = 1:101, freq = 3.0e9 * ones(length(z)))
# Scatter points on the origin and end points
smithscatter!(ax, [z[1]], markersize = 12.0)
smithscatter!(ax, [z[end]], markersize = 12.0, marker = :cross)
# Colorbar representing the length of the line
Colorbar(fig[1,2], limits = (l[1]/λ, l[end]/λ), ticks = ([0.0, 0.5, 1.0], ["0.0", "λ/2", "λ"]))
# Activate Data Inspector
DataInspector(fig)
fig

Easy integration of the Smith chart with Makie.jl’s interactive functionalities

fig = Figure()
ax = SmithAxis(fig[1, 1], title = "Stub Matching")

Zl = 50.0
Ri = 50.0
Xi = 100.0
zi = Ri + Xi*im
zi = zi / Zl

function simline(z, l)
    bl = 2 * pi * l # Electrical length
    return (z + im * tan(bl)) / (1 + im * z * tan(bl))
end

function simstub(z, l)
    bl = 2 * pi * l
    y_stub = im * tan(-bl)
    return 1 / ((1 / z) + y_stub) 
end

N = 101
sg = SliderGrid(
    fig[2, 1],
    (label = "Line", range = range(0.0, 0.5, 151), format = "{:.3f}λ", startvalue = 0.0),
    (label = "Stub", range = range(0.0, 0.5, 151), format = "{:.3f}λ", startvalue = 0.0))

sliderobservables = [s.value for s in sg.sliders]
z = lift(sliderobservables...) do slvalues...
    line_index, stub_index = [slvalues...]
    line_p = range(0.0, line_index, N)
    stub_p = range(0.0, stub_index, N)
    z_line = simline.(zi, line_p)
    z_stub = simstub.(z_line[end], stub_p)
    return [zi; z_line; z_stub]
end

zend = lift(x->x[end], z)
smithscatter!(zi)
smithplot!(z)
smithscatter!(zend)
fig

sliders

Add data markers using the datamarkers(sc::SmithAxis, gp::GridPosition) function. Double-click on lines or scatter plots to place a marker. To remove a marker, double-click on it.

datamarkers

For more examples you can visit the github link.

Development Notes

During development, I aimed to make SmithChart.jl as customizable as Makie’s built-in axes. However, I couldn’t find clear documentation on best practices for creating custom blocks like SmithAxis. If anyone has insights on this, I’d love to hear your thoughts!

Although still a work in progress, I believe the package is at a stage where it can be useful to others. I would greatly appreciate any feedback on its functionality, API design, or visual presentation.

SmithChart.jl is not yet registered in the General registry. For now, you can install it by adding the package repository. I’m working on registering the package, which will make installation easier in the future once I figure out the registration process.

Thanks for your interest!

33 Likes

The plots and interactivity look terrific! It’s great to see more RF/microwave packages in the Julia ecosystem.

3 Likes

Very cool, pretty impressive for your first package! You even made a custom block and that’s not documented at all :grinning_face_with_smiling_eyes:

1 Like

Amazing work! :smiley:

1 Like

Very cool and inspiring!

As there are more and more RF/microwave related packages, I hope that soon there will be a Github Organization that encompasses them all.