Skip to content

Commit f2310cf

Browse files
committed
Make initial conditions parametric
1 parent e61bc6b commit f2310cf

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/src/basics/Variable_metadata.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,19 @@ hasbounds(u)
8383
getbounds(u)
8484
```
8585

86+
## Guess
87+
88+
Specify an initial guess for custom initial conditions of an `ODESystem`.
89+
90+
```@example metadata
91+
@variables u [guess = 1]
92+
hasguess(u)
93+
```
94+
95+
```@example metadata
96+
getguess(u)
97+
```
98+
8699
## Mark input as a disturbance
87100

88101
Indicate that an input is not available for control, i.e., it's a disturbance input.

test/nonlinearsystem.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ end
237237
@testset "Initialization System" begin
238238
# Define the Lotka Volterra system which begins at steady state
239239
@parameters t
240-
pars = @parameters a=1.5 b=1.0 c=3.0 d=1.0
240+
pars = @parameters a=1.5 b=1.0 c=3.0 d=1.0 dx_ss = 1e-5
241241

242242
vars = @variables begin
243243
dx(t),
244244
dy(t),
245-
(x(t) = dx ~ 0), [guess = 0.5]
245+
(x(t) = dx ~ dx_ss), [guess = 0.5]
246246
(y(t) = dy ~ 0), [guess = -0.5]
247247
end
248248

@@ -270,8 +270,8 @@ end
270270
@test sol.retcode == SciMLBase.ReturnCode.Success
271271

272272
# Confirm for all the states of the non-simplified system
273-
@test all(.≈(sol[states(sys)], [0, 0, 0, 0]; atol = 1e-8))
273+
@test all(.≈(sol[states(sys)], [1e-5, 0, 1e-5 / 1.5, 0]; atol = 1e-8))
274274

275275
# Confirm for all the states of the simplified system
276-
@test all(.≈(sol[states(sys_simple)], [0, 0]; atol = 1e-8))
276+
@test all(.≈(sol[states(sys_simple)], [1e-5 / 1.5, 0]; atol = 1e-8))
277277
end

0 commit comments

Comments
 (0)