Skip to content

Commit 1cba906

Browse files
author
Brad Carman
committed
added hydraulic example
1 parent c70d53f commit 1cba906

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
Then we can visualize the system using `ODESystemDesign()` and the `view()` functions
5252

5353
```julia
54-
path = "./design" # folder where visualization info is saved and retrieved
54+
path = joinpath(@__DIR__, "design") # folder where visualization info is saved and retrieved
5555
design = ODESystemDesign(sys, path);
5656
ModelingToolkitDesigner.view(design)
5757
```

examples/design/Main/System.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
connect(stp.output, src.input)
2+
connect(src.port, res.port_a)
3+
connect(vol.port, res.port_b)
4+
connect(src.port, fluid)

examples/design/Main/System.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[fluid]
2+
x = 0.38
3+
y = -0.01
4+
5+
[res]
6+
port_a = "W"
7+
x = 0.47
8+
y = 0.09
9+
10+
[src]
11+
input = "W"
12+
x = 0.3
13+
y = 0.09
14+
15+
[stp]
16+
x = 0.12
17+
y = 0.09
18+
19+
[vol]
20+
port = "W"
21+
x = 0.64
22+
y = 0.09

examples/hydraulic.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using ModelingToolkit
2+
using ModelingToolkitDesigner
3+
4+
import ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible as IC
5+
import ModelingToolkitStandardLibrary.Blocks as B
6+
7+
8+
@parameters t
9+
10+
@component function System(; name)
11+
12+
pars = []
13+
14+
systems = @named begin
15+
fluid = IC.HydraulicFluid(; density = 876, bulk_modulus = 1.2e9, viscosity = 0.034)
16+
17+
stp = B.Step(; height = 10e5, start_time = 0.005)
18+
src = IC.InputSource(; p_int = 0)
19+
vol = IC.FixedVolume(; p_int = 0, vol = 10.0)
20+
res = IC.Pipe(5; p_int = 0, area = 0.01, length = 500.0)
21+
end
22+
23+
eqs = [
24+
connect(stp.output, src.input)
25+
connect(src.port, res.port_a)
26+
connect(vol.port, res.port_b)
27+
connect(src.port, fluid)
28+
]
29+
30+
31+
ODESystem(eqs, t, [], pars; name, systems)
32+
end
33+
34+
@named sys = System()
35+
36+
path = joinpath(@__DIR__, "design") # folder where visualization info is saved and retrieved
37+
design = ODESystemDesign(sys, path);
38+
ModelingToolkitDesigner.view(design)

0 commit comments

Comments
 (0)