@@ -158,22 +158,62 @@ end
158158end
159159
160160@testset " Power" begin
161- @named c1 = Constant (; k = 2 )
161+ @named c1 = Sine (; frequency = 1 )
162162 @named c2 = Constant (; k = 2 )
163163 @named pow = Power (;)
164+ @named int = Integrator (; k = 1 )
164165 @named model = ODESystem (
165166 [
166167 connect (c1. output, pow. input1),
167- connect (c2. output, pow. input2)
168+ connect (c2. output, pow. input2),
169+ connect (pow. output, int. input)
170+ ],
171+ t,
172+ systems = [int, pow, c1, c2])
173+ sys = structural_simplify (model)
174+ prob = ODEProblem (sys, Pair[int. x => 0.0 ], (0.0 , 1.0 ))
175+ sol = solve (prob, Rodas4 ())
176+ @test isequal (unbound_inputs (sys), [])
177+ @test sol. retcode == Success
178+ @test sol[pow. output. u] ≈ sin .(2 * pi * sol. t) .^ 2
179+ end
180+
181+ @testset " Modulo" begin
182+ @named c1 = Ramp (height = 2 , duration = 1 , offset = 1 , start_time = 0 , smooth = false )
183+ @named c2 = Constant (; k = 1 )
184+ @named modl = Modulo (;)
185+ @named model = ODESystem (
186+ [
187+ connect (c1. output, modl. input1),
188+ connect (c2. output, modl. input2)
168189 ],
169190 t,
170- systems = [pow , c1, c2])
191+ systems = [modl , c1, c2])
171192 sys = structural_simplify (model)
172193 prob = ODEProblem (sys, [], (0.0 , 1.0 ))
173194 sol = solve (prob, Rodas4 ())
174195 @test isequal (unbound_inputs (sys), [])
175196 @test sol. retcode == Success
176- @test sol[pow. output. u] ≈ 4
197+ @test sol[modl. output. u] ≈ mod .(2 * sol. t,1 )
198+ end
199+
200+ @testset " UnaryMinus" begin
201+ @named c1 = Sine (; frequency = 1 )
202+ @named minu = UnaryMinus (;)
203+ @named int = Integrator (; k = 1 )
204+ @named model = ODESystem (
205+ [
206+ connect (c1. output, minu. input),
207+ connect (minu. output, int. input)
208+ ],
209+ t,
210+ systems = [int, minu, c1])
211+ sys = structural_simplify (model)
212+ prob = ODEProblem (sys, Pair[int. x => 0.0 ], (0.0 , 1.0 ))
213+ sol = solve (prob, Rodas4 ())
214+ @test isequal (unbound_inputs (sys), [])
215+ @test sol. retcode == Success
216+ @test sol[minu. output. u] ≈ - sin .(2 * pi * sol. t)
177217end
178218
179219@testset " Division" begin
0 commit comments