@@ -23,7 +23,7 @@ postwalk(f, ex) = walk(ex, x -> postwalk(f, x), f)
2323 x + u₃
2424 end
2525 @infer_incidence u₁ + u₂ true # a second argument of `true` makes it return the IR, not the Incidence
26- @infer_incidence exp(u₂) + u₁ # will create u₂ as the second continuous variable
26+ @infer_incidence 1/u₂ + u₁ # will create u₂ as the second continuous variable
2727
2828Return the `Incidence` object after inferring the structure of the provided code,
2929substituting any variables starting by 'u'. Variables are created as `continuous()`
@@ -174,6 +174,11 @@ dependencies(row) = sort(rowvals(row) .=> nonzeros(row), by = first)
174174 @test dependencies (incidence. row) == [2 => 1 ]
175175 @test incidence == incidence " u₁"
176176
177+ incidence = @infer_incidence 3.0 * ᵢ u₁
178+ @test incidence. typ === Const (0.0 )
179+ @test dependencies (incidence. row) == [2 => 3.0 ]
180+ @test incidence == incidence " 3.0u₁"
181+
177182 incidence = @infer_incidence u₁ + ᵢ u₂
178183 @test incidence. typ === Const (0.0 )
179184 @test dependencies (incidence. row) == [2 => 1 , 3 => 1 ]
@@ -274,26 +279,66 @@ dependencies(row) = sort(rowvals(row) .=> nonzeros(row), by = first)
274279 @test dependencies (incidence. row) == [2 => nonlinear, 3 => linear_state_dependent, 4 => linear_state_dependent]
275280 @test incidence == incidence " f(u₁, ∝ₛu₂, ∝ₛu₃)"
276281
277- incidence = @infer_incidence exp (u₁)
282+ incidence = @infer_incidence 1 / u₁
278283 @test dependencies (incidence. row) == [2 => nonlinear]
279284 @test incidence == incidence " a + f(u₁)"
280285
281- incidence = @infer_incidence t * exp ( u₁)
286+ incidence = @infer_incidence t * ( 1 / u₁)
282287 @test dependencies (incidence. row) == [1 => linear_state_dependent, 2 => nonlinear]
283288 @test incidence == incidence " a + f(∝ₛt, u₁)"
284289
285- incidence = @infer_incidence u₁ * exp ( t)
290+ incidence = @infer_incidence u₁ * ( 1 / t)
286291 @test dependencies (incidence. row) == [1 => nonlinear, 2 => linear_time_dependent]
287292 @test incidence == incidence " a + f(t, ∝ₜu₁)"
288293
289- incidence = @infer_incidence u₁ * exp ( t + u₂)
294+ incidence = @infer_incidence u₁ * ( 1 / ( t + u₂) )
290295 @test dependencies (incidence. row) == [1 => nonlinear, 2 => linear_time_and_state_dependent, 3 => nonlinear]
291296 @test incidence == incidence " a + f(t, ∝ₜₛu₁, u₂)"
292297
293- incidence = @infer_incidence atan (u₁, u₂)
298+ incidence = @infer_incidence 1 / (u₁ * u₂)
294299 @test dependencies (incidence. row) == [2 => nonlinear, 3 => nonlinear]
295300 @test incidence == incidence " a + f(u₁, u₂)"
296301 end
297- end ;
302+
303+ @testset " Time derivatives" begin
304+ incidence = @infer_incidence ddt (3.0 * ᵢ t)
305+ @test incidence == incidence " 3.0"
306+
307+ incidence = @infer_incidence ddt (3.0 * ᵢ t + ᵢ 5.0 )
308+ @test incidence == incidence " 3.0"
309+
310+ incidence = @infer_incidence ddt (3.0 * t)
311+ @test incidence == incidence " a"
312+
313+ incidence = @infer_incidence ddt (u₁)
314+ @test incidence == incidence " u₂"
315+
316+ incidence = @infer_incidence ddt (1.0 + ᵢ u₁)
317+ @test incidence == incidence " u₂"
318+
319+ incidence = @infer_incidence u₁ + ᵢ ddt (u₁)
320+ @test incidence == incidence " u₁ + u₂"
321+
322+ incidence = @infer_incidence ddt (u₁ * ᵢ u₂)
323+ @test incidence == incidence " f(∝ₛu₁, ∝ₛu₂, ∝ₛu₃, ∝ₛu₄)"
324+
325+ incidence = @infer_incidence ddt (u₁ * ᵢ t)
326+ @test incidence == incidence " a + ∝u₁ + f(∝ₛt, ∝ₜu₂)"
327+
328+ incidence = @infer_incidence ddt (u₁ * ᵢ u₁)
329+ @test incidence == incidence " a + f(u₁, u₂)"
330+ # Note that the constant term may be removed if we
331+ # model nonlinear time-independent incidences.
332+
333+ incidence = @infer_incidence ddt (1 / u₁)
334+ @test incidence == incidence " a + f(u₁, u₂)"
335+
336+ incidence = @infer_incidence ddt ((2.0 + ᵢ u₁) * ᵢ (3.0 + ᵢ u₂))
337+ @test incidence == incidence " f(∝ₛu₁, ∝ₛu₂, ∝ₛu₃, ∝ₛu₄)"
338+
339+ incidence = @infer_incidence ddt ((2.0 + ᵢ u₁) * ᵢ (3.0 + ᵢ t))
340+ @test incidence == incidence " a + ∝u₁ + f(∝ₛt, ∝ₜu₂)"
341+ end
342+ end
298343
299344end
0 commit comments