Skip to content

Commit 3b0c008

Browse files
Merge pull request #282 from SciML/ChrisRackauckas-patch-2
Update first_simulation.md to not be overdetermined
2 parents e5f683a + 857f212 commit 3b0c008

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

docs/src/getting_started/first_simulation.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ number of animals at each time?
5050

5151
```@example
5252
using ModelingToolkit, DifferentialEquations, Plots
53+
using ModelingToolkit: t_nounits as t, D_nounits as D
5354
5455
# 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)
5657
5758
# Define our parameters
5859
@parameters α=1.5 β=1.0 γ=3.0 δ=1.0
5960
60-
# Define our differential: takes the derivative with respect to `t`
61-
D = Differential(t)
62-
6361
# Define the differential equations
6462
eqs = [D(x) ~ α * x - β * x * y
6563
D(y) ~ -γ * y + δ * x * y
@@ -103,6 +101,7 @@ Now we're ready. Let's load in these packages:
103101

104102
```@example first_sim
105103
using ModelingToolkit, DifferentialEquations, Plots
104+
using ModelingToolkit: t_nounits as t, D_nounits as D
106105
```
107106

108107
### Step 2: Define our ODE Equations
@@ -113,12 +112,14 @@ variables:
113112

114113
```@example first_sim
115114
# 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)
117116
```
118117

119118
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:
122123

123124
```@example first_sim
124125
# Define our parameters
@@ -133,9 +134,6 @@ for parameters, where the default value is now the parameter value:
133134
expressions!
134135

135136
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.
139137

140138
!!! note
141139

@@ -146,9 +144,6 @@ Then, once we have the operator, we apply that into the equations.
146144
is used!
147145

148146
```@example first_sim
149-
# Define our differential: takes the derivative with respect to `t`
150-
D = Differential(t)
151-
152147
# Define the differential equations
153148
eqs = [D(x) ~ α * x - β * x * y
154149
D(y) ~ -γ * y + δ * x * y

0 commit comments

Comments
 (0)