Skip to content

Fixes to test suite #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ julia = "1.6"
[extras]
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["OrdinaryDiffEq", "SafeTestsets", "Test", "ControlSystemsBase", "DataInterpolations"]
test = ["LinearAlgebra", "OrdinaryDiffEq", "SafeTestsets", "Test", "ControlSystemsBase", "DataInterpolations"]
4 changes: 2 additions & 2 deletions test/Blocks/test_analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ sys_outer = ODESystem(eqs, t, systems = [F, sys_inner, r], name = :outer)

# test first that the structural_simplify works correctly
ssys = structural_simplify(sys_outer)
prob = ODEProblem(ssys, [P.x => 1], (0, 10))
prob = ODEProblem(ssys, Pair[], (0, 10))
# sol = solve(prob, Rodas5())
# plot(sol)

Expand All @@ -148,7 +148,7 @@ lsyso = sminreal(ss(matrices_So...))
## A more complicated test case
using ModelingToolkit, OrdinaryDiffEq, LinearAlgebra
using ModelingToolkitStandardLibrary.Mechanical.Rotational
using ModelingToolkitStandardLibrary.Blocks: t, Sine, PID, SecondOrder, Step, RealOutput
using ModelingToolkitStandardLibrary.Blocks: Sine, PID, SecondOrder, Step, RealOutput
using ModelingToolkit: connect
# Parameters
m1 = 1
Expand Down
17 changes: 13 additions & 4 deletions test/Electrical/analog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ end
sol = solve(prob, Tsit5())
y(x, st) = (x .> st) .* abs.(collect(x) .- st)
@test sol.retcode == Success
@test sum(reduce(vcat, sol.u) .- y(sol.t, start_time))≈0 atol=1e-2
@test sum(reduce(vcat, sol[capacitor.v]) .- y(sol.t, start_time))≈0 atol=1e-2
end

@testset "Integrator" begin
Expand All @@ -201,19 +201,28 @@ end
@named R2 = Resistor(R = 100 * R)
@named C1 = Capacitor(C = 1 / (2 * pi * f * R))
@named opamp = IdealOpAmp()
@named square = Square(amplitude = Vin)
@named square_source = Square(amplitude = Vin)
@named voltage = Voltage()
@named sensor = VoltageSensor()

connections = [connect(square.output, voltage.V)
connections = [connect(square_source.output, voltage.V)
connect(voltage.p, R1.p)
connect(R1.n, C1.n, R2.p, opamp.n1)
connect(opamp.p2, C1.p, R2.n)
connect(opamp.p1, ground.g, opamp.n2, voltage.n)
connect(opamp.p2, sensor.p)
connect(sensor.n, ground.g)]
@named model = ODESystem(connections, t,
systems = [R1, R2, opamp, square, voltage, C1, ground, sensor])
systems = [
R1,
R2,
opamp,
square_source,
voltage,
C1,
ground,
sensor,
])
sys = structural_simplify(model)
u0 = [C1.v => 0.0
R1.v => 0.0]
Expand Down