Bland.Smith (Elixir Technical Drawing v0.3.0)

Copy Markdown View Source

Smith chart helpers.

S11 sweep on a Smith chart

A Smith chart plots the reflection coefficient Γ = (Z - 1) / (Z + 1) on the unit disk, where Z = r + jx is a normalized complex impedance (usually normalized to Z₀ = 50 Ω). Constant-resistance circles and constant-reactance arcs form the classical grid.

BLAND's approach: use a Cartesian figure where the x-axis is Re(Γ) and the y-axis is Im(Γ). Bland.smith_figure/1 sets the plot area up as a unit disk; Bland.smith_grid/2 draws the resistance circles and reactance arcs. User data is plotted as reflection coefficients (Γ values) directly — convert from impedance via gamma_from_z/1.

Examples

iex> {re, im} = Bland.Smith.gamma_from_z({1.0, 0.0})
iex> {Float.round(re, 6), Float.round(im, 6)}
{0.0, 0.0}

iex> {re, im} = Bland.Smith.gamma_from_z({0.0, 0.0})
iex> {Float.round(re, 6), Float.round(im, 6)}
{-1.0, 0.0}

Summary

Functions

Default resistance values (normalized) at which to draw the constant-R circles: [0.2, 0.5, 1.0, 2.0, 5.0].

Default reactance magnitudes at which to draw the constant-X arcs. Each positive value also draws its negative counterpart: [±0.2, ±0.5, ±1.0, ±2.0, ±5.0].

Converts normalized impedance {r, x} to reflection coefficient {Re(Γ), Im(Γ)}.

Full circle of constant normalized resistance r, traced in the Γ-plane. Returns {xs, ys} with n + 1 points.

Full circle of constant normalized reactance x in the Γ-plane. Returns {xs, ys} with n + 1 points.

Inverse: reflection coefficient {Γ_re, Γ_im} to normalized impedance {r, x}. Z = (1 + Γ) / (1 − Γ).

Functions

default_r_values()

@spec default_r_values() :: [float()]

Default resistance values (normalized) at which to draw the constant-R circles: [0.2, 0.5, 1.0, 2.0, 5.0].

default_x_values()

@spec default_x_values() :: [float()]

Default reactance magnitudes at which to draw the constant-X arcs. Each positive value also draws its negative counterpart: [±0.2, ±0.5, ±1.0, ±2.0, ±5.0].

gamma_from_z(arg)

@spec gamma_from_z({number(), number()}) :: {float(), float()}

Converts normalized impedance {r, x} to reflection coefficient {Re(Γ), Im(Γ)}.

For Z = r + jx, Γ = (Z − 1) / (Z + 1).

r_circle(r, n \\ 120)

@spec r_circle(number(), pos_integer()) :: {[float()], [float()]}

Full circle of constant normalized resistance r, traced in the Γ-plane. Returns {xs, ys} with n + 1 points.

The circle has center (r/(r+1), 0) and radius 1/(r+1); it sits entirely inside the unit disk, tangent at (1, 0).

x_arc(x, n \\ 120)

@spec x_arc(number(), pos_integer()) :: {[float()], [float()]}

Full circle of constant normalized reactance x in the Γ-plane. Returns {xs, ys} with n + 1 points.

Center is (1, 1/x), radius is 1/|x|. Only the portion inside the unit disk is meaningful on a Smith chart; the series-layer clip (clip: :circle) masks the rest.

z_from_gamma(arg)

@spec z_from_gamma({number(), number()}) :: {float(), float()}

Inverse: reflection coefficient {Γ_re, Γ_im} to normalized impedance {r, x}. Z = (1 + Γ) / (1 − Γ).