@@ -8,6 +8,7 @@ canonequal(a, b) = isequal(simplify(a), simplify(b))
8
8
9
9
# Define some variables
10
10
@parameters t σ ρ β
11
+ @constants h= 1
11
12
@variables x y z
12
13
13
14
function test_nlsys_inference (name, sys, vs, ps)
@@ -18,7 +19,7 @@ function test_nlsys_inference(name, sys, vs, ps)
18
19
end
19
20
20
21
# Define a nonlinear system
21
- eqs = [0 ~ σ * (y - x),
22
+ eqs = [0 ~ σ * (y - x) * h ,
22
23
0 ~ x * (ρ - z) - y,
23
24
0 ~ x * y - β * z]
24
25
@named ns = NonlinearSystem (eqs, [x, y, z], [σ, ρ, β], defaults = Dict (x => 2 ))
@@ -59,7 +60,7 @@ f = @eval eval(nlsys_func)
59
60
# Intermediate calculations
60
61
a = y - x
61
62
# Define a nonlinear system
62
- eqs = [0 ~ σ * a,
63
+ eqs = [0 ~ σ * a * h ,
63
64
0 ~ x * (ρ - z) - y,
64
65
0 ~ x * y - β * z]
65
66
@named ns = NonlinearSystem (eqs, [x, y, z], [σ, ρ, β])
@@ -87,7 +88,7 @@ sol = solve(prob, NewtonRaphson())
87
88
88
89
@variables u F s a
89
90
eqs1 = [
90
- 0 ~ σ * (y - x) + F,
91
+ 0 ~ σ * (y - x) * h + F,
91
92
0 ~ x * (ρ - z) - u,
92
93
0 ~ x * y - β * z,
93
94
0 ~ x + y - z - u,
@@ -98,7 +99,7 @@ lorenz1 = lorenz(:lorenz1)
98
99
@test_throws ArgumentError NonlinearProblem (lorenz1, zeros (5 ))
99
100
lorenz2 = lorenz (:lorenz2 )
100
101
@named connected = NonlinearSystem ([s ~ a + lorenz1. x
101
- lorenz2. y ~ s
102
+ lorenz2. y ~ s * h
102
103
lorenz1. F ~ lorenz2. u
103
104
lorenz2. F ~ lorenz1. u], [s, a], [],
104
105
systems = [lorenz1, lorenz2])
@@ -123,7 +124,7 @@ sol = solve(prob, Rodas5())
123
124
# Define a nonlinear system
124
125
eqs = [0 ~ σ * (y - x),
125
126
0 ~ x * (ρ - z) - y,
126
- 0 ~ x * y - β * z]
127
+ 0 ~ x * y - β * z * h ]
127
128
@named ns = NonlinearSystem (eqs, [x, y, z], [σ, ρ, β])
128
129
np = NonlinearProblem (ns, [0 , 0 , 0 ], [1 , 2 , 3 ], jac = true , sparse = true )
129
130
@test calculate_jacobian (ns, sparse = true ) isa SparseMatrixCSC
170
171
# observed variable handling
171
172
@variables t x (t) RHS (t)
172
173
@parameters τ
173
- @named fol = NonlinearSystem ([0 ~ (1 - x) / τ], [x], [τ]; observed = [RHS ~ (1 - x) / τ])
174
+ @named fol = NonlinearSystem ([0 ~ (1 - x * h ) / τ], [x], [τ]; observed = [RHS ~ (1 - x) / τ])
174
175
@test isequal (RHS, @nonamespace fol. RHS)
175
176
RHS2 = RHS
176
177
@unpack RHS = fol
@@ -179,7 +180,7 @@ RHS2 = RHS
179
180
# issue #1358
180
181
@variables t
181
182
@variables v1 (t) v2 (t) i1 (t) i2 (t)
182
- eq = [v1 ~ sin (2pi * t)
183
+ eq = [v1 ~ sin (2pi * t * h )
183
184
v1 - v2 ~ i1
184
185
v2 ~ i2
185
186
i1 ~ i2]
193
194
eqs = [u[1 ] ~ 1 ,
194
195
u[2 ] ~ 1 ,
195
196
u[3 ] ~ 1 ,
196
- u[4 ] ~ 1 ]
197
+ u[4 ] ~ h ]
197
198
198
199
sys = NonlinearSystem (eqs, collect (u[1 : 4 ]), Num[], defaults = Dict ([]), name = :test )
199
200
prob = NonlinearProblem (sys, ones (length (states (sys))))
0 commit comments