Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Carman committed Sep 20, 2023
1 parent a335d75 commit 8661c0d
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions docs/src/tutorials/domain_connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,23 @@ When the system is defined we can generate a fluid component and connect it to t
end
@named odesys = System()
nothing #hide
```

using ModelingToolkitDesigner
path = joinpath(dirname(pathof(ModelingToolkit)),
"..",
"docs",
"src",
"assets",
"domain_connections")
design = ODESystemDesign(odesys, path);
ModelingToolkitDesigner.view(design, false)
```@setup domain
# code to generate diagrams...
# using ModelingToolkitDesigner
# path = raw"C:\Work\Assets\ModelingToolkit.jl\domain_connections"
# design = ODESystemDesign(odesys, path);
# using CairoMakie
# CairoMakie.set_theme!(Theme(;fontsize=12))
# fig = ModelingToolkitDesigner.view(design, false)
# save(joinpath(path, "odesys.svg"), fig; resolution=(300,300))
```

![odesys](https://github.com/SciML/ModelingToolkit.jl/assets/40798837/d19fbcf4-781c-4743-87b7-30bed348ff98)

To see how the domain works, we can examine the set parameter values for each of the ports `src.port` and `vol.port`. First we assemble the system using `structural_simplify()` and then check the default value of `vol.port.ρ`, whichs points to the setter value `fluid₊ρ`. Likewise, `src.port.ρ`, will also point to the setter value `fluid₊ρ`. Therefore, there is now only 1 defined density value `fluid₊ρ` which sets the density for the connected network.

```@repl domain
Expand Down Expand Up @@ -189,11 +194,17 @@ A system with 2 different fluids is defined and connected to each separate domai
end
@named actsys2 = ActuatorSystem2()
nothing #hide
```

design2 = ODESystemDesign(actsys2, path);
ModelingToolkitDesigner.view(design2, false)
```@setup domain
# design = ODESystemDesign(actsys2, path);
# fig = ModelingToolkitDesigner.view(design, false)
# save(joinpath(path, "actsys2.svg"), fig; resolution=(500,300))
```

![actsys2](https://github.com/SciML/ModelingToolkit.jl/assets/40798837/8ed50035-f6ac-48cb-a585-1ef415154a02)

After running `structural_simplify()` on `actsys2`, the defaults will show that `act.port_a.ρ` points to `fluid_a₊ρ` and `act.port_b.ρ` points to `fluid_b₊ρ`. This is a special case, in most cases a hydraulic system will have only 1 fluid, however this simple system has 2 separate domain networks. Therefore, we can connect a single fluid to both networks. This does not interfer with the mathmatical equations of the system, since no states are connected.

```@example domain
Expand All @@ -215,11 +226,17 @@ After running `structural_simplify()` on `actsys2`, the defaults will show that
end
@named actsys1 = ActuatorSystem1()
nothing #hide
```

design1 = ODESystemDesign(actsys1, path);
ModelingToolkitDesigner.view(design1, false)
```@setup domain
# design = ODESystemDesign(actsys1, path);
# fig = ModelingToolkitDesigner.view(design, false)
# save(joinpath(path, "actsys1.svg"), fig; resolution=(500,300))
```

![actsys1](https://github.com/SciML/ModelingToolkit.jl/assets/40798837/054404eb-dbb7-4b85-95c0-c9503d0c4d00)

## Special Connection Cases (`domain_connect()`)

In some cases a component will be defined with 2 connectors of the same domain, but they are not connected. For example the `Restrictor` defined here gives equations to define the behavior of how the 2 connectors `port_a` and `port_b` are physcially connected.
Expand Down Expand Up @@ -265,11 +282,17 @@ end
@named ressys = RestrictorSystem()
sys = structural_simplify(ressys)
nothing #hide
```

design = ODESystemDesign(ressys, path);
ModelingToolkitDesigner.view(design, false)
```@setup domain
# design = ODESystemDesign(ressys, path);
# fig = ModelingToolkitDesigner.view(design, false)
# save(joinpath(path, "ressys.svg"), fig; resolution=(500,300))
```

![ressys](https://github.com/SciML/ModelingToolkit.jl/assets/40798837/3740f0e2-7324-4c1f-af8b-eba02cfece81)

When `structural_simplify()` is applied to this system it can be seen that the defaults are missing for `res.port_b` and `vol.port`.

```@repl domain
Expand Down

0 comments on commit 8661c0d

Please sign in to comment.