|
216 | 216 | @test sol[minu.output.u] ≈ - sin.(2 * pi * sol.t) |
217 | 217 | end |
218 | 218 |
|
| 219 | +@testset "Floor" begin |
| 220 | + @named c1 = Sine(; frequency = 1) |
| 221 | + @named flr = Floor(;) |
| 222 | + @named int = Integrator(; k = 1) |
| 223 | + @named model = ODESystem( |
| 224 | + [ |
| 225 | + connect(c1.output, flr.input), |
| 226 | + connect(flr.output, int.input) |
| 227 | + ], |
| 228 | + t, |
| 229 | + systems = [int, flr, c1]) |
| 230 | + sys = structural_simplify(model) |
| 231 | + prob = ODEProblem(sys, Pair[int.x => 0.0], (0.0, 1.0)) |
| 232 | + sol = solve(prob, Rodas4()) |
| 233 | + @test isequal(unbound_inputs(sys), []) |
| 234 | + @test sol.retcode == Success |
| 235 | + @test sol[flr.output.u] ≈ floor.(sin.(2 * pi * sol.t)) |
| 236 | +end |
| 237 | + |
| 238 | +@testset "Ceil" begin |
| 239 | + @named c1 = Sine(; frequency = 1) |
| 240 | + @named cel = Ceil(;) |
| 241 | + @named int = Integrator(; k = 1) |
| 242 | + @named model = ODESystem( |
| 243 | + [ |
| 244 | + connect(c1.output, cel.input), |
| 245 | + connect(cel.output, int.input) |
| 246 | + ], |
| 247 | + t, |
| 248 | + systems = [int, cel, c1]) |
| 249 | + sys = structural_simplify(model) |
| 250 | + prob = ODEProblem(sys, Pair[int.x => 0.0], (0.0, 1.0)) |
| 251 | + sol = solve(prob, Rodas4()) |
| 252 | + @test isequal(unbound_inputs(sys), []) |
| 253 | + @test sol.retcode == Success |
| 254 | + @test sol[cel.output.u] ≈ ceil.(sin.(2 * pi * sol.t)) |
| 255 | +end |
| 256 | + |
219 | 257 | @testset "Division" begin |
220 | 258 | @named c1 = Sine(; frequency = 1) |
221 | 259 | @named c2 = Constant(; k = 2) |
|
0 commit comments