Skip to content

Commit ded3046

Browse files
committed
Add note in FAQ
1 parent 8b170a2 commit ded3046

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

docs/src/basics/FAQ.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ p, replace, alias = SciMLStructures.canonicalize(Tunable(), prob.p)
186186

187187
This error can come up after running `structural_simplify` on a system that generates dummy derivatives (i.e. variables with `ˍt`). For example, here even though all the variables are defined with initial values, the `ODEProblem` generation will throw an error that defaults are missing from the variable map.
188188

189-
```
189+
```julia
190190
using ModelingToolkit
191191
using ModelingToolkit: t_nounits as t, D_nounits as D
192192

@@ -202,7 +202,7 @@ prob = ODEProblem(sys, [], (0,1))
202202

203203
We can solve this problem by using the `missing_variable_defaults()` function
204204

205-
```
205+
```julia
206206
prob = ODEProblem(sys, ModelingToolkit.missing_variable_defaults(sys), (0,1))
207207
```
208208

@@ -221,7 +221,7 @@ julia> ModelingToolkit.missing_variable_defaults(sys, [1,2,3])
221221
Use the `u0_constructor` keyword argument to map an array to the desired
222222
container type. For example:
223223

224-
```
224+
```julia
225225
using ModelingToolkit, StaticArrays
226226
using ModelingToolkit: t_nounits as t, D_nounits as D
227227

@@ -230,3 +230,17 @@ eqs = [D(x1) ~ 1.1 * x1]
230230
@mtkbuild sys = ODESystem(eqs, t)
231231
prob = ODEProblem{false}(sys, [], (0,1); u0_constructor = x->SVector(x...))
232232
```
233+
234+
## Using a custom independent variable
235+
236+
When possible, we recommend `using ModelingToolkit: t_nounits as t, D_nounits as D` as the independent variable and its derivative.
237+
However, if you want to use your own, you can do so:
238+
239+
```julia
240+
using ModelingToolkit
241+
242+
@parameters x # independent variables must be created as parameters
243+
D = Differential(x)
244+
@variables y(x)
245+
@named sys = ODESystem([D(y) ~ x], x)
246+
```

0 commit comments

Comments
 (0)