Skip to content

Commit b2bf4c2

Browse files
committed
Add docs
1 parent fc43393 commit b2bf4c2

27 files changed

+983
-192
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
matrix:
2525
version:
2626
- '1.10'
27-
- '1.6'
2827
- 'pre'
2928
os:
3029
- ubuntu-latest

.github/workflows/Documenter.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main # update to match your development branch (master, main, dev, trunk, ...)
7+
tags: '*'
8+
pull_request:
9+
10+
# Cancel previous runs if a new one is triggered (by push on PR)
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build:
17+
permissions:
18+
contents: write
19+
statuses: write
20+
runs-on: ubuntu-20.04
21+
environment: production
22+
steps:
23+
- name: Install system dependencies
24+
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev xsettingsd x11-xserver-utils
25+
26+
- uses: actions/checkout@v4
27+
- uses: julia-actions/setup-julia@latest
28+
with:
29+
version: '1.10'
30+
31+
- name: Install Julia dependencies
32+
run: |
33+
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
34+
35+
- name: Build and Deploy Docs
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
39+
GKSwstype: "100"
40+
run: |
41+
DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --color=yes docs/make.jl

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/Manifest.toml
2+
/docs/Manifest.toml
3+
/docs/build

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SmithChart"
22
uuid = "0c39085a-4a17-4c0c-9861-c4c53bcea38a"
33
authors = [""]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
@@ -10,8 +10,10 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1010
[compat]
1111
julia = "1.8.5"
1212
Makie = "0.20.10"
13+
1314
[extras]
15+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1416
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1517

1618
[targets]
17-
test = ["Test"]
19+
test = ["Test", "Documenter"]

README.md

Lines changed: 3 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This project originated as an exploration of the interactive possibilities that
77

88
**Note**: Some of the features are experimental. They might not function fully as expected or could be subject to changes in future versions.
99

10+
Some examples are shown below. For more information and other examples, visit the documentation.
11+
1012
## Usage
1113

1214
```julia
@@ -39,7 +41,6 @@ fig
3941

4042
![SmithChartExample](Images/smithplot_color.png)
4143

42-
4344
## Integration with Makie
4445

4546
This example showcases the seamless integration of the Smith chart with Makie.jl's interactive functionalities. It demonstrates a typical scenario used to teach impedance matching, where we aim to transform a source impedance of 50+100j $\Omega$ to a load impedance of 50 $\Omega$. To achieve this, we utilize a transmission line and a parallel stub, and control their lengths via sliders. By dynamically adjusting these lengths, users can observe how the source impedance seen by the load evolves on the Smith chart, visually illustrating the impedance matching process.
@@ -91,190 +92,8 @@ fig
9192

9293
![slidergif](Images/sliders.gif)
9394

94-
## Plot Reflection Coefficientes
95-
96-
You can also draw reflection data with the `reflection = true` keyword. This is useful, for example, when you want to visualize the S-parameters of a simulation or measurement.
97-
98-
```julia
99-
zi = 3.8 - 1.9im
100-
function simline(z, l)
101-
bl = 2 * pi * l
102-
return (z + im * tan(bl)) / (1 + im * z * tan(bl))
103-
end
104-
l = range(0.0, 0.22, 101)
105-
z = simline.(zi, l)
106-
fig = Figure(size = (900,600))
107-
ax = SmithAxis(fig[1,1])
108-
smithplot!(ax, z, label = "Impedance")
109-
# Convert impedance z to reflection
110-
Γ = @. (z-1)/(z+1)
111-
# Plot with `reflection = true`
112-
smithscatter!(ax, Γ[1:5:end], reflection = true, markersize = 11, color = :orange, marker = :cross, label = "Reflection\nreflection = true")
113-
fig[1,2] = Legend(fig, ax)
114-
fig
115-
```
116-
![ReflectionExample](Images/Reflectionkeyword.png)
117-
118-
11995
## Interactive Data Markers
12096

12197
Interactive data markers can be added to your Smith chart 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. It is possible to move the marker by dragging it with the left click.
12298

123-
![datamarkergif](Images/datamarker_drag.gif)
124-
125-
126-
## Stability, Gain and Noise Circles
127-
128-
SmithChart.jl allows visualization of constant gain circles, constant noise circles, and stability regions, essential for amplifier design and stability analysis. These features can be useful for tasks such as designing low-noise amplifiers (LNAs), power amplifiers, and ensuring the stability of circuits over a range of frequencies and impedances.
129-
130-
This example shows how to use the `NFCircle` and `CGCircle`. This functions returns an array of `Point2f` that can be used with Makie functions like `lines!` or `poly!`.
131-
132-
```julia
133-
using CairoMakie
134-
f = Figure(size = (1200, 660))
135-
sc = SmithAxis(f[1,1], cutgrid = true, title = "Constant NF Circles")
136-
137-
NF_to_F(nf) = 10.0^(nf/10.0)
138-
Γopt = 0.5 * cis(130 * pi / 180)
139-
NFmin = 1.6 # dB
140-
Fmin = NF_to_F(NFmin)
141-
F2dB = NF_to_F(2.0)
142-
F2_5dB = NF_to_F(2.5)
143-
F3dB = NF_to_F(3.0)
144-
nf2 = NFCircle(F2dB, Fmin, Γopt, 20.0, 50.0, 361)
145-
nf2_5 = NFCircle(F2_5dB, Fmin, Γopt, 20.0, 50.0, 361)
146-
nf3 = NFCircle(F3dB, Fmin, Γopt, 20.0, 50.0, 361)
147-
148-
smithscatter!(sc, [Γopt], reflection = true, color = :blue, linewidth = 1.9)
149-
text!(sc, "Γopt", position = Point2f(real(Γopt), imag(Γopt)), offset = (3, 3), color = :blue, font = :bold)
150-
text!(sc, "$NFmin dB", position = Point2f(real(Γopt), imag(Γopt)), offset = (0, -16), color = :blue, font = :bold)
151-
152-
lines!(sc, nf2, color = :green, linewidth = 1.9)
153-
text!(sc, "2.0 dB", position = nf2[45], offset = (2, 0), color = :green, font = :bold)
154-
155-
lines!(sc, nf2_5, color = :purple, linewidth = 1.9)
156-
text!(sc, "2.5 dB", position = nf2_5[120], offset = (-35, 2), color = :purple, font = :bold)
157-
158-
lines!(sc, nf3, color = :orange, linewidth = 1.9)
159-
text!(sc, "3.0 dB", position = nf3[260], offset = (2, 2), color = :orange, font = :bold)
160-
161-
# https://www.allaboutcircuits.com/technical-articles/designing-a-unilateral-rf-amplifier-for-a-specified-gain/
162-
sc = SmithAxis(f[1,2], cutgrid = true, title = "Constant Gs Circles")
163-
164-
S11 = 0.533 * cis(176.6 / 180 * π)
165-
S22 = 0.604 * cis(-58.0 / 180 * π)
166-
Go = abs2(S11)
167-
Gs_max = 1 / (1 - abs2(S11))
168-
gain(dB) = 10.0^(dB/10.0)
169-
170-
g1 = gain(0.0) / Gs_max
171-
g2 = gain(0.5) / Gs_max
172-
g3 = gain(1.0) / Gs_max
173-
g4 = gain(1.4) / Gs_max
174-
175-
c1 = CGCircle(g1, S11, 361)
176-
c2 = CGCircle(g2, S11, 361)
177-
c3 = CGCircle(g3, S11, 361)
178-
c4 = CGCircle(g4, S11, 361)
179-
180-
smithscatter!(sc, [conj(S11)], reflection = true, color = :blue, linewidth = 1.9)
181-
text!(sc, "S11*", position = Point2f(real(S11), -imag(S11)),
182-
offset = (-5, 7), color = :blue, font = :bold, fontsize = 9)
183-
184-
poly!(sc, c1, color = (:green, 0.1), strokecolor = :green, strokewidth = 1.9)
185-
text!(sc, "0.0 dB", position = c1[125], offset = (17, 0), color = :green, font = :bold)
186-
187-
lines!(sc, c2, color = :red, linewidth = 1.9)
188-
text!(sc, "0.5 dB", position = c2[110], offset = (-27, 3), color = :red, font = :bold)
189-
190-
lines!(sc, c3, color = :magenta, linewidth = 1.9)
191-
text!(sc, "1.0 dB", position = c3[260], offset = (2, 0), color = :magenta, font = :bold)
192-
193-
lines!(sc, c4, color = :purple, linewidth = 1.9)
194-
text!(sc, "1.4 dB", position = c3[45], offset = (2, 2), color = :purple, font = :bold)
195-
```
196-
197-
![Ccircles](Images/ConstantCircles.svg)
198-
199-
When calculating the stability regions, you can select whether you want to display the stable or unstable region. To do this, modify the keyword `stable` in the `StabilityCircle` function.
200-
201-
```julia
202-
using CairoMakie
203-
f = Figure(size = (800, 500))
204-
Label(f[0, 1:2] , "Stable Regions", fontsize = 24, font = :bold)
205-
S11, S12, S21, S22 = [0.438868-0.778865im 1.4+0.2im; 0.1+0.43im 0.692125-0.361834im]
206-
A = StabilityCircle(S11, S12, S21, S22, :source, 361; stable = false)
207-
B = StabilityCircle(S11, S12, S21, S22, :source, 361; stable = true)
208-
209-
ax = SmithAxis(f[1,1], subtitle = "StabilityCircle(... ; stable = false)")
210-
region = poly!(ax, A, strokecolor = :black, strokewidth = 1.2, color = Pattern('x', linecolor = :red, width = 1.3, background_color = (:red, 0.1)))
211-
translate!(region, (0, 0, -2))
212-
text!(ax, "Unstable Input", position = Point2f(-0.1, -0.5), font = :bold, color = :red, fontsize = 15)
213-
B = StabilityCircle(S11, S12, S21, S22, :source, 361; stable = true);
214-
ax = SmithAxis(f[1,2], subtitle = "StabilityCircle(... ; stable = true)")
215-
region = poly!(ax, B, strokecolor = :black, strokewidth = 1.2, color = Pattern('\\', linecolor = :blue, width = 1.3, background_color = (:blue, 0.1)))
216-
translate!(region, (0, 0, -2))
217-
text!(ax, "Stable Input", position = Point2f(0.1, 0.15), font = :bold, color = :blue, fontsize = 15)
218-
```
219-
![stabilityregions1](Images/bothregions.svg)
220-
221-
It is possible to obtain the input or output stability regions with `StabilityCircle(S11, S12, S21, S22, :source, npoints)` or `StabilityCircle(S11, S12, S21, S22, :load, npoints)`.
222-
223-
```julia
224-
f = Figure()
225-
S11, S12, S21, S22 = [ 0.0967927-0.604297im 0.0255292+0.0394621im ; -8.4396+11.0786im 0.552226-0.425271im]
226-
A = StabilityCircle(S11, S12, S21, S22, :source, 361; stable = true);
227-
B = StabilityCircle(S11, S12, S21, S22, :load, 361; stable = true);
228-
ax = SmithAxis(f[1,1], title = "Input and Output stability regions")
229-
color1 = Pattern('/', linecolor = :blue, width = 1.3, background_color = :transparent)
230-
color2 = Pattern('\\', linecolor = :green, width = 1.3, background_color = :transparent)
231-
region = poly!(ax, A, strokecolor = :black, strokewidth = 1.2, color = color1)
232-
translate!(region, (0, 0, -2))
233-
region = poly!(ax, B, strokecolor = :black, strokewidth = 1.2, color = color2)
234-
translate!(region, (0, 0, -2))
235-
text!(ax, "Stable Input", position = Point2f(-0.85, 0.2), font = :bold, color = :blue, rotation = 25*pi/180, fontsize = 12)
236-
text!(ax, "Stable Output", position = Point2f(0.3, 0.5), font = :bold, color = :green, rotation = -18*pi/180, fontsize = 12)
237-
```
238-
239-
![stabilityregions2](Images/StableRegionsLines.svg)
240-
241-
242-
## Dynamic Annotation Update
243-
244-
You can activate a experimental dynamic curve annotation with the keyword `textupdate = true`
245-
246-
```julia
247-
fig = Figure(size = (800,600))
248-
ax = SmithAxis(fig[1, 1]; subgrid = true, cutgrid = true, zoomupdate = true, textupdate = true, threshold = (150, 150))
249-
```
250-
251-
![ZoomGif](Images/SmithChart_zoom.gif)
252-
253-
254-
## Other Keywords
255-
256-
How some keywords modify visual aspects of the Smith Chart.
257-
258-
### Chart type and grid colors
259-
260-
It is possible to change the type of smith chart or modify the color of the grid or subgrid.
261-
262-
![keywordexample](Images/typeandcolor.png)
263-
264-
### Interior tick options
265-
266-
There are multiple keywords to modify the position of the ticks. Some of them are:
267-
268-
![keywordexample](Images/tickkeywords.png)
269-
270-
### Threshold keyword
271-
272-
`threshold` keyword controls the cut of the lines in the intersection with other arcs.
273-
274-
![keywordexample](Images/threshold.png)
275-
276-
### Subgrid split
277-
278-
The `splitgrid` keyword controls the number of cuts for each zoomlevel.
279-
280-
![keywordexample](Images/splitminor.png)
99+
![datamarkergif](Images/datamarker_drag.gif)

docs/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
3+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
4+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
5+
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
6+
SmithChart = "0c39085a-4a17-4c0c-9861-c4c53bcea38a"

docs/make.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Documenter, SmithChart
2+
3+
DocMeta.setdocmeta!(SmithChart, :DocTestSetup, :(using SmithChart); recursive=true)
4+
5+
makedocs(modules = [SmithChart], clean = true, format = Documenter.HTML(; size_threshold=100_000_000), sitename = "SmithChart.jl",
6+
pages = Any[
7+
"index.md",
8+
"SmithAxisBlock.md",
9+
"api_reference.md",
10+
"Examples" => Any[
11+
"Examples/ChartTypes.md",
12+
"Examples/TickPositions.md",
13+
"Examples/MakieIntegration.md",
14+
"Examples/Reflection.md",
15+
"Examples/InteractiveDataMarkers.md",
16+
"Examples/ConstantCircles.md",
17+
"Examples/VisualDetails.md",
18+
"Examples/DynamicUpdate.md"]
19+
], doctest = true, checkdocs=:none)
20+
21+
deploydocs(
22+
repo = "github.com/uvegege/SmithChart.jl.git",
23+
push_preview = true,
24+
)
25+

docs/src/Examples/ChartTypes.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Chart type and grid colors
2+
3+
Change type and control color of the grid or subgrid. The keywords `zgridcolor` and `ygridcolor` allow controlling both axes with a single keyword. Each of them takes precedence over their respective individual grid color settings (`rgridcolor` and `xgridcolor` for the Z-axis, and `bgridcolor` and `ggridcolor` for the Y-axis).
4+
5+
```@example
6+
using SmithChart
7+
using CairoMakie
8+
CairoMakie.activate!() #hide
9+
f = Figure(size = (1200, 800))
10+
sc1 = SmithAxis(f[1,1], type = :Z, subtitle = "type :Z (default)")
11+
sc2 = SmithAxis(f[1,2], type = :Y, subtitle = "type :Y")
12+
sc3 = SmithAxis(f[1,3], type = :ZY, subtitle = "type :ZY", gtickvisible = false, btickvisible = false)
13+
sc4 = SmithAxis(f[2,1], type = :Z, subtitle = "rgridcolor = :red, xgridcolor = :green", rgridcolor = :red, xgridcolor = :green)
14+
sc5 = SmithAxis(f[2,2], type = :Y, subtitle = "ygridcolor = :blue", ygridcolor = :blue)
15+
sc6 = SmithAxis(f[2,3], type = :ZY, subtitle = "zgridcolor = :orange, ygridcolor = :green", zgridcolor = :orange, ygridcolor = :green, gtickvisible = false, btickvisible = false)
16+
f
17+
```
18+

0 commit comments

Comments
 (0)