@@ -134,24 +134,24 @@ end
134134 @test all (isapprox .(sol[Mx. y], sol[Mx. x - g* (Mx. t)^ 2 / 2 ]; atol = 1e-10 )) # compare to analytical solution (x(t) = v*t, y(t) = v*t - g*t^2/2)
135135end
136136
137- @testset " Change independent variable (crazy analytical example )" begin
137+ @testset " Change independent variable (crazy 3rd order nonlinear system )" begin
138138 @independent_variables t
139139 D = Differential (t)
140140 @variables x (t) y (t)
141- M1 = ODESystem ([ # crazy non-autonomous non-linear 2nd order ODE
142- D ( D (y)) ~ D (x)^ 2 + D (y^ 3 ) |> expand_derivatives # expand D(y^3) # TODO : make this test 3rd order
143- D (x) ~ x^ 4 + y^ 5 + t^ 6
141+ M1 = ODESystem ([
142+ (D ^ 3 ) (y) ~ D (x)^ 2 + (D ^ 2 ) (y^ 2 ) |> expand_derivatives
143+ D (x)^ 2 + D (y) ^ 2 ~ x^ 4 + y^ 5 + t^ 6
144144 ], t; name = :M )
145- M2 = change_independent_variable (M1, x)
145+ M2 = change_independent_variable (M1, x; add_old_diff = true )
146+ @test_nowarn structural_simplify (M2)
146147
147148 # Compare to pen-and-paper result
148- @independent_variables x
149+ @variables x xˍt (x) xˍt (x) y (x) t (x)
149150 Dx = Differential (x)
150- @variables xˍt (x) xˍtt (x) y (x) t (x)
151- @test Set (equations (M2)) == Set ([
152- xˍt^ 2 * (Dx^ 2 )(y) + xˍt* Dx (xˍt)* Dx (y) ~ xˍt^ 2 + 3 * y^ 2 * Dx (y)* xˍt # from D(D(y))
153- xˍt ~ x^ 4 + y^ 5 + t^ 6 # dummy equation
154- ])
151+ areequivalent (eq1, eq2) = isequal (expand (eq1. lhs - eq2. lhs), 0 ) && isequal (expand (eq1. rhs - eq2. rhs), 0 )
152+ @test areequivalent (equations (M2)[1 ], xˍt^ 3 * (Dx^ 3 )(y) + xˍt^ 2 * Dx (y)* (Dx^ 2 )(xˍt) + xˍt* Dx (y)* (Dx (xˍt))^ 2 + 3 * xˍt^ 2 * (Dx^ 2 )(y)* Dx (xˍt) ~ xˍt^ 2 + 2 * xˍt^ 2 * Dx (y)^ 2 + 2 * xˍt^ 2 * y* (Dx^ 2 )(y) + 2 * y* Dx (y)* Dx (xˍt)* xˍt)
153+ @test areequivalent (equations (M2)[2 ], xˍt^ 2 + xˍt^ 2 * Dx (y)^ 2 ~ x^ 4 + y^ 5 + t^ 6 )
154+ @test areequivalent (equations (M2)[3 ], Dx (t) ~ 1 / xˍt)
155155end
156156
157157@testset " Change independent variable (registered function / callable parameter)" begin
0 commit comments