@@ -50,16 +50,14 @@ number of animals at each time?
50
50
51
51
``` @example
52
52
using ModelingToolkit, DifferentialEquations, Plots
53
+ using ModelingToolkit: t_nounits as t, D_nounits as D
53
54
54
55
# Define our state variables: state(t) = initial condition
55
- @variables t x(t)=1 y(t)=1 z(t)=2
56
+ @variables x(t)=1 y(t)=1 z(t)
56
57
57
58
# Define our parameters
58
59
@parameters α=1.5 β=1.0 γ=3.0 δ=1.0
59
60
60
- # Define our differential: takes the derivative with respect to `t`
61
- D = Differential(t)
62
-
63
61
# Define the differential equations
64
62
eqs = [D(x) ~ α * x - β * x * y
65
63
D(y) ~ -γ * y + δ * x * y
@@ -103,6 +101,7 @@ Now we're ready. Let's load in these packages:
103
101
104
102
``` @example first_sim
105
103
using ModelingToolkit, DifferentialEquations, Plots
104
+ using ModelingToolkit: t_nounits as t, D_nounits as D
106
105
```
107
106
108
107
### Step 2: Define our ODE Equations
@@ -113,12 +112,14 @@ variables:
113
112
114
113
``` @example first_sim
115
114
# Define our state variables: state(t) = initial condition
116
- @variables t x(t)=1 y(t)=1 z(t)=2
115
+ @variables x(t)=1 y(t)=1 z(t)
117
116
```
118
117
119
118
Notice here that we use the form ` state = default ` , where on the right-hand side the default
120
- value of a state is interpreted to be its initial condition. This is then done similarly
121
- for parameters, where the default value is now the parameter value:
119
+ value of a state is interpreted to be its initial condition. Note that since ` z ` will be given
120
+ by an algebraic equation, we do not need to specify its initial condition.
121
+
122
+ This is then done similarly for parameters, where the default value is now the parameter value:
122
123
123
124
``` @example first_sim
124
125
# Define our parameters
@@ -133,9 +134,6 @@ for parameters, where the default value is now the parameter value:
133
134
expressions!
134
135
135
136
Next, we define our set of differential equations.
136
- To define the ` Differential ` operator ` D ` , we need to first tell it what to
137
- differentiate with respect to, here the independent variable ` t ` ,
138
- Then, once we have the operator, we apply that into the equations.
139
137
140
138
!!! note
141
139
@@ -146,9 +144,6 @@ Then, once we have the operator, we apply that into the equations.
146
144
is used!
147
145
148
146
``` @example first_sim
149
- # Define our differential: takes the derivative with respect to `t`
150
- D = Differential(t)
151
-
152
147
# Define the differential equations
153
148
eqs = [D(x) ~ α * x - β * x * y
154
149
D(y) ~ -γ * y + δ * x * y
0 commit comments