Skip to content

Commit 370343b

Browse files
baggepinnenAayushSabharwal
authored andcommitted
update pendcart test
1 parent 648956d commit 370343b

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

test/downstream/linearization_dd.jl

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,34 @@ lin_outputs = [cart.s, cart.v, link1.A, link1.dA]
2929
lin_inputs = [force.f.u]
3030

3131
# => nothing to remove extra defaults
32-
op = Dict(cart.s => 10, cart.v => 0, link1.A => -pi/2, link1.dA => 0, force.f.u => 0, link1.x1 => nothing, link1.y1 => nothing, link1.x2 => nothing, link1.x_cm => nothing)
33-
@test_broken begin
34-
@info "named_ss"
35-
G = named_ss(model, lin_inputs, lin_outputs, allow_symbolic = true, op = def,
36-
allow_input_derivatives = true, zero_dummy_der = true)
37-
G = sminreal(G)
38-
@info "minreal"
39-
G = minreal(G)
40-
@info "poles"
41-
ps = poles(G)
42-
43-
@test minimum(abs, ps) < 1e-6
44-
@test minimum(abs, complex(0, 1.3777260367206716) .- ps) < 1e-10
45-
46-
lsys, syss = linearize(model, lin_inputs, lin_outputs, allow_symbolic = true, op = op,
47-
allow_input_derivatives = true, zero_dummy_der = true)
48-
lsyss, sysss = ModelingToolkit.linearize_symbolic(model, lin_inputs, lin_outputs;
49-
allow_input_derivatives = true)
50-
51-
dummyder = setdiff(unknowns(sysss), unknowns(model))
52-
def = merge(ModelingToolkit.guesses(model), def, Dict(x => 0.0 for x in dummyder))
53-
def[link1.fy1] = -def[link1.g] * def[link1.m]
54-
55-
@test substitute(lsyss.A, def) lsys.A
56-
# We cannot pivot symbolically, so the part where a linear solve is required
57-
# is not reliable.
58-
@test substitute(lsyss.B, def)[1:6, 1] lsys.B[1:6, 1]
59-
@test substitute(lsyss.C, def) lsys.C
60-
@test substitute(lsyss.D, def) lsys.D
61-
end
32+
op = Dict(cart.s => 10, cart.v => 0, link1.A => -pi / 2, link1.dA => 0, force.f.u => 0,
33+
link1.x1 => nothing, link1.y1 => nothing, link1.x2 => nothing, link1.x_cm => nothing)
34+
@info "named_ss"
35+
G = named_ss(model, lin_inputs, lin_outputs; allow_symbolic = true, op,
36+
allow_input_derivatives = true, zero_dummy_der = true)
37+
G = sminreal(G)
38+
@info "minreal"
39+
G = minreal(G)
40+
@info "poles"
41+
ps = poles(G)
42+
43+
@test minimum(abs, ps) < 1e-6
44+
@test minimum(abs, complex(0, 1.3777260367206716) .- ps) < 1e-10
45+
46+
lsys, syss = linearize(model, lin_inputs, lin_outputs, allow_symbolic = true, op = op,
47+
allow_input_derivatives = true, zero_dummy_der = true)
48+
lsyss, sysss = ModelingToolkit.linearize_symbolic(model, lin_inputs, lin_outputs;
49+
allow_input_derivatives = true)
50+
51+
dummyder = setdiff(unknowns(sysss), unknowns(model))
52+
# op2 = merge(ModelingToolkit.guesses(model), op, Dict(x => 0.0 for x in dummyder))
53+
op2 = merge(ModelingToolkit.defaults(syss), op)
54+
op2[link1.fy1] = -op2[link1.g] * op2[link1.m]
55+
op2[cart.f] = 0
56+
57+
@test substitute(lsyss.A, op2) lsys.A
58+
# We cannot pivot symbolically, so the part where a linear solve is required
59+
# is not reliable.
60+
@test substitute(lsyss.B, op2)[1:6, 1] lsys.B[1:6, 1]
61+
@test substitute(lsyss.C, op2) lsys.C
62+
@test substitute(lsyss.D, op2) lsys.D

0 commit comments

Comments
 (0)