|
354 | 354 | sol = solve(prob, Tsit5()) |
355 | 355 | @test !all(iszero, sol.u) |
356 | 356 | tv = 0:k.clock.dt:sol.t[end] |
357 | | - @test std(sol(tv, idxs = m.plant.u)) ≈ 1 rtol=0.1 |
358 | | - @test mean(sol(tv, idxs = m.plant.u)) ≈ 0 atol=0.08 |
359 | | -end |
360 | | - |
361 | | -@testset "UniformNoise" begin |
362 | | - k = ShiftIndex(Clock(0.01)) |
363 | | - |
364 | | - @mtkmodel NoiseModel begin |
365 | | - @components begin |
366 | | - noise = UniformNoise(z = k) |
367 | | - zoh = ZeroOrderHold(z = k) |
368 | | - plant = FirstOrder(T = 1e-4) # Included due to bug with only discrete-time systems |
369 | | - end |
370 | | - @equations begin |
371 | | - connect(noise.output, zoh.input) |
372 | | - connect(zoh.output, plant.input) |
373 | | - end |
374 | | - end |
375 | | - |
376 | | - @named m = NoiseModel() |
377 | | - m = complete(m) |
378 | | - ssys = structural_simplify(IRSystem(m)) |
379 | | - prob = ODEProblem(ssys, [], (0.0, 10.0)) |
380 | | - sol = solve(prob, Tsit5()) |
381 | | - @test !all(iszero, sol.u) |
382 | | - tv = 0:k.clock.dt:sol.t[end] |
383 | 357 | @test minimum(sol(tv, idxs = m.plant.u)) ≈ 0 atol=0.02 |
384 | 358 | @test maximum(sol(tv, idxs = m.plant.u)) ≈ 1 atol=0.02 |
385 | 359 | end |
|
0 commit comments