Skip to content

Commit 3f2c946

Browse files
Merge pull request #31 from SimonEnsemble/update_to_makie
Update to makie
2 parents 8df2e08 + 5eceb90 commit 3f2c946

32 files changed

+659
-940
lines changed

.github/workflows/TagBot.yml

-11
This file was deleted.

.github/workflows/ci_testing.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: 'Controlz'
11+
cancel-in-progress: true
12+
13+
jobs:
14+
unit-and-doc-tests:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
18+
steps:
19+
- name: checkout commit
20+
uses: actions/checkout@main
21+
22+
- name: set up Julia
23+
uses: julia-actions/setup-julia@latest
24+
with:
25+
version: '1.7.1'
26+
27+
- name: build package
28+
uses: julia-actions/julia-buildpkg@latest
29+
30+
- name: run tests
31+
run: julia --project --color=yes -e 'import Pkg; Pkg.test()'
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
35+
36+
- name: set up documenter
37+
run: julia --project -e 'import Pkg; Pkg.add("Documenter")'
38+
39+
- name: build and deploy docs
40+
run: julia --project --color=yes ./docs/make.jl
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
name = "Controlz"
22
uuid = "e034abe6-471a-4d54-96dd-ecd1f4022419"
33
authors = ["SimonEnsemble <[email protected]>"]
4-
version = "0.2.1"
4+
version = "0.3.0"
55

66
[deps]
77
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
88
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
99
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
1010
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
1111
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
12-
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
1312
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
13+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
14+
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
15+
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
1416

1517
[compat]
16-
DifferentialEquations = "^6.16.0"
17-
DataFrames = "^0.22.1"
18-
Interpolations = "^0.13.1"
19-
Polynomials = "^0.6.1"
20-
PyPlot = "^2.9.0"
21-
julia = "^1.5"
22-
Roots = "0.8.4"
18+
DifferentialEquations = "^7.0.0"
19+
DataFrames = "^1.3.1"
20+
Interpolations = "^0.13.5"
21+
Polynomials = "^2.0.22"
22+
julia = "^1.7"
23+
Roots = "^1.3.13"
24+
CairoMakie = "^0.6.6"
25+
ColorSchemes = "^3.15.0"
26+
Colors = "^0.12.8"
2327

2428
[extras]
2529
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
2630
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
2731
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
32+
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
33+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
2834
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
35+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2936

3037
[targets]
31-
test = ["Test", "Documenter", "Polynomials"]
38+
test = ["Test", "Documenter", "Polynomials", "Markdown", "InteractiveUtils", "Pkg"]

docs/make.jl

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using Documenter
22
using Controlz
33

4+
# using Controlz before all docstrings
5+
DocMeta.setdocmeta!(Controlz, :DocTestSetup, :(using Controlz); recursive=true)
6+
47
makedocs(
58
root = joinpath(dirname(pathof(Controlz)), "..", "docs"),
69
modules = [Controlz],

docs/src/FOPTD_step_response.png

-37 KB
Binary file not shown.
-40.3 KB
Binary file not shown.
-31.8 KB
Binary file not shown.
-39 KB
Binary file not shown.

docs/src/example_bode.png

-124 KB
Binary file not shown.

docs/src/example_nyquist.png

-41 KB
Binary file not shown.

docs/src/example_poles_and_zeros.png

-27.5 KB
Binary file not shown.

docs/src/example_root_locus.png

-26.6 KB
Binary file not shown.

docs/src/faq.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ yes, `Controlz.jl` is free and open. see the associated MIT license [here](https
1010

1111
**I'm completely new to Julia and don't know where to start.**
1212

13-
Julia is a free and open-source, high-performance, dynamic programming language designed especially for numerical computing. See [here](https://julialang.org/learning/) for resources on learning Julia. I recommend [Jupyter Lab or Jupyter Notebook](https://jupyter.org/) as an interactive development environment for Julia.
13+
Julia is a free and open-source, high-performance, dynamic programming language designed especially for numerical computing. see [here](https://julialang.org/learning/) for resources on learning Julia. I recommend the interactive [Pluto Notebook](https://github.com/fonsp/Pluto.jl) as an interactive development environment for Julia.
1414

1515
**I found a bug.**
1616

1717
please post an issue [here](https://github.com/SimonEnsemble/Controlz.jl/issues).
1818

1919
**may I contribute to the package?**
2020

21-
absolutely! especially for fixing bugs, making documentation clearer, providing examples, etc. as for new features, please post an issue with your plan for a pull request first.
21+
absolutely! especially for fixing bugs, making documentation clearer, providing examples, etc.
22+
23+
as for new features or significant changes, please post an issue with your plan for a pull request first so I can approve.

docs/src/index.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Controlz.jl
22

3-
`Controlz.jl` is a [Julia](https://julialang.org/) package to analyze and simulate process dynamics and control systems using transfer function representations.
3+
`Controlz.jl` is a pure-[Julia](https://julialang.org/) package to analyze and simulate process dynamics and control systems using transfer function representations.
44

55
for example, to simulate the unit step response of a second-order, underdamped system characterized by the transfer function
66

@@ -24,7 +24,6 @@ viz_response(data, plot_title="SO underdamped step response")
2424

2525
# install the `Controlz.jl` package in Julia
2626

27-
* in the Julia REPL: go into package mode by typing `]`. then `add Controlz`. then `Backspace` to exit package mode.
28-
* in a Jupyter or Pluto Notebook: `using Pkg; Pkg.add("Controlz")`. (this way also works in the REPL)
27+
`Controlz.jl` is an officially registered Julia package. install in the Julia REPL by typing `]` to go into package mode, then `add Controlz`.
2928

30-
for visualizations, `Controlz.jl` relies on `PyPlot.jl`, a Julia interface to matplotlib in Python. see [here](https://github.com/JuliaPy/PyPlot.jl) if you have trouble installing `PyPlot.jl`.
29+
I recommend interactive [Pluto notebooks](https://github.com/fonsp/Pluto.jl) for coding in Julia, whose automatic package manager installs `Controlz.jl` upon running `using Controlz`.

docs/src/sim.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ pass the output $Y(s)$ in the frequency domain into the function `simulate` to i
1212
```julia
1313
g = 4 / (4 * s ^ 2 + 0.8 * s + 1) # second order transfer function, underdamped
1414

15-
U = 1 / s # unit step input
16-
Y = g * U # system output
15+
U = 1 / s # unit step input
16+
Y = g * U # system output
1717

18-
data = simulate(Y, 50.0) # simulate until t = 50, returns DataFrame
19-
data[:, :t] # array of times, tᵢ's
20-
data[:, :output] # array of outputs, yᵢ's ≈ y(tᵢ)'s
18+
data = simulate(Y, 50.0) # simulate until t = 50, returns DataFrame
19+
data[:, :t] # array of times, tᵢ's
20+
data[:, :output] # array of outputs, yᵢ's ≈ y(tᵢ)'s
2121
```
2222

23-
we can then plot the time series via:
23+
then plot the time series via:
2424

2525
```julia
26-
viz_response(data, plot_title="SO underdamped step response")
26+
viz_response(data, title="SO underdamped step response")
2727
```
2828

2929
![](SO_underdamped_step_response.png)
@@ -41,7 +41,7 @@ Y = g * U
4141

4242
data = simulate(Y, 15.0) # simulate until t = 15
4343

44-
viz_response(data, plot_title="FOPTD step response")
44+
viz_response(data, title="FOPTD step response")
4545
```
4646

4747
![](FOPTD_step_response.png)
@@ -60,7 +60,7 @@ U = (s^2 - a^2) / (s^2 + a^2) ^ 2
6060

6161
data = simulate(U, 8.0, nb_time_points=300) # simulate until t=8, use 300 time points for high resolution
6262

63-
viz_response(data, plot_title=L"inverting an input $U(s)$", plot_ylabel=L"$u(t)$")
63+
viz_response(data, title="inverting an input U(s)", ylabel="u(t)")
6464
```
6565

6666
the `nb_time_points` argument allows us to return a time series with a higher resolution in time. if the plot of the response appears jagged, likely you need to increase `nb_time_points`.

docs/src/simple_servo_response.png

-68.6 KB
Binary file not shown.

docs/src/tcosat.png

-44.6 KB
Binary file not shown.

docs/src/tfs.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
```@meta
2+
DocTestSetup = quote
3+
using Controlz
4+
end
5+
```
16
# transfer functions
27

38
the response [output $Y(s)$] of a linear, time-invariant system to any input [$U(s)$] is characterized by a transfer function $g(s)=Y(s)/U(s)$.
@@ -9,13 +14,21 @@ $$g(s)=\dfrac{5s+1}{s^2 + 4s+5}$$.
914

1015
we can construct $g(s)$ in an intuitive way that resembles the algebraic expression:
1116

12-
```julia
17+
```jldoctest; output=false
1318
g = (5 * s + 1) / (s ^ 2 + 4 * s + 5) # way 1
19+
# output
20+
5.0*s + 1.0
21+
---------------------
22+
1.0*s^2 + 4.0*s + 5.0
1423
```
1524

1625
alternatively, we can construct a `TransferFunction` using the coefficients associated with the powers of $s$ in the polynomials composing the numerator and denominator, respectively, of $g(s)$. The coefficients of the highest powers of $s$ go first.
17-
```julia
26+
```jldoctest; output=false
1827
g = TransferFunction([5, 1], [1, 4, 5]) # way 2
28+
# output
29+
5.0*s + 1.0
30+
---------------------
31+
1.0*s^2 + 4.0*s + 5.0
1932
```
2033

2134
note that, under the hood, we defined `s` such that `s == TransferFunction([1, 0], [1])`.

docs/src/viz.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Visualization
22

3+
the visualizations rely on [`CairoMakie.jl`](https://github.com/JuliaPlots/Makie.jl).
4+
35
## poles and zeros of a transfer function
46

57
```julia
@@ -52,20 +54,32 @@ root_locus(g_ol)
5254

5355
![](example_root_locus.png)
5456

55-
## hipster plot theme
57+
## modifying the figures
58+
59+
all visualization functions return a `Figure` object from `CairoMakie.jl` that can be further modified. for example:
60+
61+
```julia
62+
g_ol = 4 / (s + 3) / (s + 2) / (s + 1)
63+
fig = root_locus(g_ol)
64+
ax = current_axis(fig)
65+
xlims!(ax, -15, 5)
66+
ax.xlabel = "real numbers"
67+
```
5668

57-
invoke the hipster plot theme used to make plots for this documentation by:
69+
## cool plot theme
5870

71+
the custom plot theme can be invoked in `CairoMakie.jl` for other plots via:
5972
```julia
60-
using PyPlot
61-
PyPlot.matplotlib.style.use("https://raw.githubusercontent.com/SimonEnsemble/Controlz.jl/master/src/hipster.mplstyle")
73+
using Controlz, CairoMakie
74+
set_theme!(cool_theme)
6275
```
76+
more, `CairoMakie.jl` offers other themes [here](https://makie.juliaplots.org/dev/documentation/theming/predefined_themes/).
6377

6478
## detailed docs
6579

6680
```@docs
67-
viz_poles_and_zeros
6881
viz_response
82+
viz_poles_and_zeros
6983
nyquist_diagram
7084
bode_plot
7185
root_locus

examples/examples.ipynb

-567
This file was deleted.

0 commit comments

Comments
 (0)