You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/basics/Variable_metadata.md
+45-2Lines changed: 45 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,11 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
54
54
55
55
@variables i(t) [connect = Flow]
56
56
@variables k(t) [connect = Stream]
57
+
hasconnect(i)
58
+
```
59
+
60
+
```@example connect
61
+
getconnect(k)
57
62
```
58
63
59
64
## Input or output
@@ -177,8 +182,46 @@ A variable can be marked `irreducible` to prevent it from being moved to an
177
182
`observed` state. This forces the variable to be computed during solving so that
178
183
it can be accessed in [callbacks](@ref events)
179
184
180
-
```julia
181
-
@variable important_value [irreducible =true]
185
+
```@example metadata
186
+
@variables important_value [irreducible = true]
187
+
isirreducible(important_value)
188
+
```
189
+
190
+
## State Priority
191
+
192
+
When a model is structurally simplified, the algorithm will try to ensure that the variables with higher state priority become states of the system. A variable's state priority is a number set using the `state_priority` metadata.
Units for variables can be designated using symbolic metadata. For more information, please see the [model validation and units](@ref units) section of the docs. Note that `getunit` is not equivalent to `get_unit` - the former is a metadata getter for individual variables (and is provided so the same interface function for `unit` exists like other metadata), while the latter is used to handle more general symbolic expressions.
202
+
203
+
```@example metadata
204
+
using DynamicQuantities
205
+
@variables speed [unit = u"m/s"]
206
+
hasunit(speed)
207
+
```
208
+
209
+
```@example metadata
210
+
getunit(speed)
211
+
```
212
+
213
+
## Miscellaneous metadata
214
+
215
+
User-defined metadata can be added using the `misc` metadata. This can be queried
216
+
using the `hasmisc` and `getmisc` functions.
217
+
218
+
```@example metadata
219
+
@variables u [misc = :conserved_parameter] y [misc = [2, 4, 6]]
0 commit comments