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
+41-1Lines changed: 41 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,10 @@ 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
+
```@example connect
60
+
getconnect(k)
57
61
```
58
62
59
63
## Input or output
@@ -177,8 +181,44 @@ A variable can be marked `irreducible` to prevent it from being moved to an
177
181
`observed` state. This forces the variable to be computed during solving so that
178
182
it can be accessed in [callbacks](@ref events)
179
183
180
-
```julia
184
+
```@example metadata
181
185
@variable important_value [irreducible = true]
186
+
isirreducible(important_value)
187
+
```
188
+
189
+
## State Priority
190
+
191
+
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.
201
+
202
+
```@example metadata
203
+
@variable speed [unit=u"m/s"]
204
+
hasunit(speed)
205
+
```
206
+
```@example metadata
207
+
getunit(speed)
208
+
```
209
+
210
+
## Miscellaneous metadata
211
+
212
+
User-defined metadata can be added using the `misc` metadata. This can be queried
213
+
using the `hasmisc` and `getmisc` functions.
214
+
215
+
```@example metadata
216
+
@variables u [misc = :conserved_parameter] y [misc = [2, 4, 6]]
## Units ======================================================================
587
+
"""
588
+
getunit(x)
589
+
590
+
Fetch the unit associated with variable `x`. This function is a metadata getter for an individual variable, while `get_unit` is used for unit inference on more complicated sdymbolic expressions.
0 commit comments