Skip to content

Commit 8a208f7

Browse files
author
Brad Carman
committed
Added electrical example and icons
1 parent cb576a9 commit 8a208f7

File tree

15 files changed

+1011
-2
lines changed

15 files changed

+1011
-2
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
# ModelingToolkitDesigner.jl
22

3-
The ModelingToolkitDesigner.jl package is a helper tool for visualizing and editing ModelingToolkit.jl system connections. An example system visualization generated from this package is shown below
3+
The ModelingToolkitDesigner.jl package is a helper tool for visualizing and editing ModelingToolkit.jl system connections.
44

5-
![example](https://user-images.githubusercontent.com/40798837/228676202-c13b93c2-d023-4b00-bed8-c8440cb8ca57.png)
5+
## Examples
6+
Examples can be found in the "examples" folder.
7+
8+
### Hydraulic Example
9+
10+
![example1](https://user-images.githubusercontent.com/40798837/228676202-c13b93c2-d023-4b00-bed8-c8440cb8ca57.png)
11+
12+
### RC Circuit Example
13+
14+
![example2](examples/electrical.svg)
615

716

817
# Tutorial

examples/design/Main/Circuit.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
connect(constant.output, source.V)
2+
connect(source.p, resistor.p)
3+
connect(resistor.n, capacitor.p)
4+
connect(capacitor.n, source.n)
5+
connect(source.n, ground.g)

examples/design/Main/Circuit.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[capacitor]
2+
n = "S"
3+
x = 0.52
4+
y = 0.29
5+
6+
[constant]
7+
x = 0.54
8+
y = -0.03
9+
10+
[ground]
11+
x = 0.43
12+
y = 0.11
13+
14+
[resistor]
15+
n = "W"
16+
p = "S"
17+
x = 0.8
18+
y = 0.29
19+
20+
[source]
21+
V = "S"
22+
n = "W"
23+
x = 0.66
24+
y = 0.11

examples/electrical.jl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using ModelingToolkit
2+
using ModelingToolkitStandardLibrary.Electrical
3+
using ModelingToolkitStandardLibrary.Blocks: Constant
4+
using ModelingToolkitDesigner
5+
using CairoMakie
6+
7+
@component function Circuit(;name)
8+
9+
R = 1.0
10+
C = 1.0
11+
V = 1.0
12+
@variables t
13+
systems = @named begin
14+
resistor = Resistor(R = R)
15+
capacitor = Capacitor(C = C)
16+
source = Voltage()
17+
constant = Constant(k = V)
18+
ground = Ground()
19+
end
20+
21+
22+
eqs = [connect(constant.output, source.V)
23+
connect(source.p, resistor.p)
24+
connect(resistor.n, capacitor.p)
25+
connect(capacitor.n, source.n, ground.g)]
26+
27+
ODESystem(eqs, t, [], []; systems, name)
28+
end
29+
30+
@named rc = Circuit()
31+
32+
33+
path = joinpath(@__DIR__, "design")
34+
design = ODESystemDesign(rc, path)
35+
ModelingToolkitDesigner.view(design)
36+
37+
CairoMakie.set_theme!(Theme(;fontsize=12))
38+
fig = ModelingToolkitDesigner.view(design, false)
39+
save(joinpath(@__DIR__, "electrical.svg"), fig; resolution=(400,400))

examples/electrical.svg

Lines changed: 400 additions & 0 deletions
Loading
1.07 KB
Loading
Lines changed: 104 additions & 0 deletions
Loading
1.38 KB
Loading
Lines changed: 104 additions & 0 deletions
Loading
1.12 KB
Loading

0 commit comments

Comments
 (0)