Skip to content

Commit 645de82

Browse files
committed
docs: add @icon section to "Components and Connectors"
1 parent 8965a72 commit 645de82

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

docs/src/basics/MTKModel_Connector.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ equations.
2626
- `@components`: for listing sub-components of the system
2727
- `@equations`: for the list of equations
2828
- `@extend`: for extending a base system and unpacking its states
29+
- `@icon` : for embedding the model icon
2930
- `@parameters`: for specifying the symbolic parameters
3031
- `@structural_parameters`: for specifying non-symbolic parameters
3132
- `@variables`: for specifing the states
@@ -50,6 +51,7 @@ end
5051
end
5152
5253
@mtkmodel ModelC begin
54+
@icon "https://github.com/SciML/SciMLDocs/blob/main/docs/src/assets/logo.png"
5355
@structural_parameters begin
5456
f = sin
5557
end
@@ -58,6 +60,7 @@ end
5860
end
5961
@variables begin
6062
v(t) = v_var
63+
v_array(t)[1:2, 1:3]
6164
end
6265
@extend ModelB(; p1)
6366
@components begin
@@ -69,6 +72,41 @@ end
6972
end
7073
```
7174

75+
#### `@icon`
76+
77+
An icon can be embedded in 3 ways:
78+
79+
- URI
80+
- Path to a valid image-file.<br>
81+
It can be an absolute path. Or, a path relative to an icon directory; which is
82+
`DEPOT_PATH[1]/mtk_icons` by default and can be changed by setting
83+
`ENV["MTK_ICONS_DIR"]`.<br>
84+
Internally, it is saved in the _File URI_ scheme.
85+
86+
```julia
87+
@mtkmodel WithPathtoIcon begin
88+
@icon "/home/user/.julia/dev/mtk_icons/icon.png"
89+
# Rest of the model definition
90+
end
91+
```
92+
93+
- Inlined SVG.
94+
95+
```julia
96+
@mtkmodel WithInlinedSVGIcon begin
97+
@icon """<svg height="100" width="100">
98+
<circle cx="50" cy="50" r="40" stroke="green" fill="none" stroke-width="3"/>
99+
</svg>
100+
"""
101+
# Rest of the model definition
102+
end
103+
```
104+
105+
#### `@structural_parameters` begin block
106+
107+
- This block is for non symbolic input arguements. These are for inputs that usually are not meant to be part of components; but influence how they are defined. One can list inputs like boolean flags, functions etc... here.
108+
- Whenever default values are specified, unlike parameters/variables, they are reflected in the keyword argument list.
109+
72110
#### `@parameters` and `@variables` begin block
73111

74112
- Parameters and variables are declared with respective begin blocks.
@@ -80,15 +118,10 @@ end
80118
```julia
81119
julia> @mtkbuild model_c1 = ModelC(; v = 2.0);
82120

83-
julia> ModelingToolkit.getdefault(model_c.v)
121+
julia> ModelingToolkit.getdefault(model_c1.v)
84122
2.0
85123
```
86124

87-
#### `@structural_parameters` begin block
88-
89-
- This block is for non symbolic input arguements. These are for inputs that usually are not meant to be part of components; but influence how they are defined. One can list inputs like boolean flags, functions etc... here.
90-
- Whenever default values are specified, unlike parameters/variables, they are reflected in the keyword argument list.
91-
92125
#### `@extend` begin block
93126

94127
- Partial systems can be extended in a higher system as `@extend PartialSystem(; kwargs)`.
@@ -209,11 +242,12 @@ For example, the structure of `ModelC` is:
209242

210243
```julia
211244
julia> ModelC.structure
212-
Dict{Symbol, Any} with 6 entries:
245+
Dict{Symbol, Any} with 7 entries:
213246
:components => [[:model_a, :ModelA]]
214-
:variables => Dict{Symbol, Dict{Symbol, Any}}(:v=>Dict(:default=>:v_var), :v_array=>Dict(:size=>(4,)))
247+
:variables => Dict{Symbol, Dict{Symbol, Any}}(:v=>Dict(:default=>:v_var), :v_array=>Dict(:size=>(2, 3)))
248+
:icon => URI("https://github.com/SciML/SciMLDocs/blob/main/docs/src/assets/logo.png")
215249
:kwargs => Dict{Symbol, Any}(:f=>:sin, :v=>:v_var, :v_array=>nothing, :model_a__k_array=>nothing, :p1=>nothing)
216250
:independent_variable => t
217-
:extend => Any[[:p1, :p2], :model_b, :ModelB]
218-
:equations => ["model_a.k1 ~ f(v)"]
251+
:extend => Any[[:p2, :p1], Symbol("#mtkmodel__anonymous__ModelB"), :ModelB]
252+
:equations => ["model_a.k ~ f(v)"]
219253
```

0 commit comments

Comments
 (0)