Skip to content
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
10 changes: 0 additions & 10 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,16 @@ jobs:
if PKG == "ModelingToolkitBase"
@info "Testing ModelingToolkitBase"
Pkg.activate("lib/ModelingToolkitBase")
@info "`dev`ing SciCompDSL"
Pkg.develop(; path = "lib/SciCompDSL")
@info "Running tests" GROUP
Pkg.test()
elseif PKG == "ModelingToolkit"
@info "Testing ModelingToolkit"
Pkg.activate(".")
@info "`dev`ing ModelingToolkitBase"
Pkg.develop(; path = "lib/ModelingToolkitBase")
@info "`dev`ing SciCompDSL"
Pkg.develop(; path = "lib/SciCompDSL")
@info "Running tests" GROUP
Pkg.test()
elseif PKG == "SciCompDSL"
@info "Testing SciCompDSL"
Pkg.activate("lib/SciCompDSL")
@info "`dev`ing ModelingToolkitBase"
Pkg.develop(; path = "lib/ModelingToolkitBase")
@info "`dev`ing ModelingToolkit"
Pkg.develop(; path = ".")
@info "Running tests" GROUP
Pkg.test()
else
Expand Down
9 changes: 0 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ subdir = "lib/ModelingToolkitBase"
rev = "as/mtk-v11"
url = "https://github.com/SciML/ModelingToolkitStandardLibrary.jl"

[sources.ModelingToolkitTearing]
rev = "main"
subdir = "lib/ModelingToolkitTearing"
url = "https://github.com/JuliaComputing/StateSelection.jl/"

[sources.Optimization]
rev = "as/symbolics-v7"
url = "https://github.com/AayushSabharwal/Optimization.jl"
Expand All @@ -76,10 +71,6 @@ url = "https://github.com/AayushSabharwal/Optimization.jl"
[sources.SciCompDSL]
subdir = "lib/SciCompDSL"

[sources.StateSelection]
rev = "main"
url = "https://github.com/JuliaComputing/StateSelection.jl/"

[extensions]
MTKFMIExt = "FMI"

Expand Down
60 changes: 39 additions & 21 deletions lib/ModelingToolkitBase/test/analysis_points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ using Test
using ModelingToolkitBase: t_nounits as t, D_nounits as D, AnalysisPoint, AbstractSystem
import ModelingToolkitBase as MTK
import ControlSystemsBase as CS
using SciCompDSL
using ModelingToolkitStandardLibrary

using Symbolics: NAMESPACE_SEPARATOR
Expand Down Expand Up @@ -693,17 +692,26 @@ using DynamicQuantities

@testset "AnalysisPoint is ignored when verifying units" begin
# no units first
@mtkmodel FirstOrderTest begin
@components begin
@component function FirstOrderTest(; name)
pars = @parameters begin
end

systems = @named begin
in = Step()
fb = Feedback()
fo = SecondOrder(k = 1, w = 1, d = 0.1)
end
@equations begin

vars = @variables begin
end

equations = Equation[
connect(in.output, :u, fb.input1)
connect(fb.output, :e, fo.input)
connect(fo.output, :y, fb.input2)
end
]

return System(equations, t, vars, pars; name, systems)
end
@named model = FirstOrderTest()
@test model isa System
Expand Down Expand Up @@ -735,38 +743,48 @@ using DynamicQuantities
]
return System(eqs, t, [], pars; systems, name)
end
@mtkmodel TestAPAroundUnits begin
@components begin
@component function TestAPAroundUnits(; name)
pars = @parameters begin
end

systems = @named begin
input = UnitfulInput()
ub = UnitfulBlock()
end
@variables begin

vars = @variables begin
output(t), [output=true, unit=u"m^2"]
end
@components begin
ub = UnitfulBlock()
end
@equations begin

equations = Equation[
connect(ub.output, :ap, input)
output ~ input.u^2
end
]

return System(equations, t, vars, pars; name, systems)
end
@named sys = TestAPAroundUnits()
@test sys isa System

@mtkmodel TestAPWithNoOutputs begin
@components begin
@component function TestAPWithNoOutputs(; name)
pars = @parameters begin
end

systems = @named begin
input = UnitfulInput()
ub = UnitfulBlock()
end
@variables begin

vars = @variables begin
output(t), [output=true, unit=u"m^2"]
end
@components begin
ub = UnitfulBlock()
end
@equations begin

equations = Equation[
connect(ub.output, :ap, input)
output ~ input.u^2
end
]

return System(equations, t, vars, pars; name, systems)
end
@named sys2 = TestAPWithNoOutputs()
@test sys2 isa System
Expand Down
49 changes: 36 additions & 13 deletions lib/ModelingToolkitBase/test/basic_transformations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ using ModelingToolkitStandardLibrary.Blocks: RealInput, RealOutput
using Symbolics: value
using SymbolicUtils: symtype, _iszero
using ModelingToolkitBase: SymbolicContinuousCallback
using SciCompDSL

@independent_variables t
D = Differential(t)
Expand Down Expand Up @@ -256,48 +255,72 @@ end

@testset "Change independent variable, no equations" begin
# make this "look" like the standard library RealInput
@mtkmodel Input begin
@variables begin
@component function Input(; name)
pars = @parameters begin
end

systems = @named begin
end

vars = @variables begin
u(t)
end

equations = Equation[]

return System(equations, t, vars, pars; name, systems)
end
@named input_sys = Input()
input_sys = complete(input_sys)
# test no failures
@test change_independent_variable(input_sys, input_sys.u) isa System

@mtkmodel NestedInput begin
@components begin
@component function NestedInput(; name)
pars = @parameters begin
end

systems = @named begin
in = Input()
end
@variables begin

vars = @variables begin
x(t)
end
@equations begin

equations = Equation[
D(x) ~ in.u
end
]

return System(equations, t, vars, pars; name, systems)
end
@named nested_input_sys = NestedInput()
nested_input_sys = complete(nested_input_sys; flatten = false)
@test change_independent_variable(nested_input_sys, nested_input_sys.x) isa System
end

@testset "Change of variables, connections" begin
@mtkmodel ConnectSys begin
@components begin
@component function ConnectSys(; name)
pars = @parameters begin
end

systems = @named begin
in = RealInput()
out = RealOutput()
end
@variables begin

vars = @variables begin
x(t)
y(t)
end
@equations begin

equations = Equation[
connect(in, out)
in.u ~ x
D(x) ~ -out.u
D(y) ~ 1
end
]

return System(equations, t, vars, pars; name, systems)
end
@named sys = ConnectSys()
sys = complete(sys; flatten = false)
Expand Down
40 changes: 28 additions & 12 deletions lib/ModelingToolkitBase/test/causal_variables_connection.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ModelingToolkitBase, ModelingToolkitStandardLibrary.Blocks
using SciCompDSL
using ModelingToolkitBase: t_nounits as t, D_nounits as D
using Test

Expand Down Expand Up @@ -96,27 +95,44 @@ if @isdefined(ModelingToolkit)
end

@testset "Outside input to inside input connection" begin
@mtkmodel Inner begin
@variables begin
@component function Inner(; name)
pars = @parameters begin
end

systems = @named begin
end

vars = @variables begin
x(t), [input = true]
y(t), [output = true]
end
@equations begin

equations = Equation[
y ~ x
end
]

return System(equations, t, vars, pars; name, systems)
end
@mtkmodel Outer begin
@variables begin
u(t), [input = true]
v(t), [output = true]

@component function Outer(; name)
pars = @parameters begin
end
@components begin

systems = @named begin
inner = Inner()
end
@equations begin

vars = @variables begin
u(t), [input = true]
v(t), [output = true]
end

equations = Equation[
connect(u, inner.x)
connect(inner.y, v)
end
]

return System(equations, t, vars, pars; name, systems)
end
@named sys = Outer()
ss = toggle_namespacing(sys, false)
Expand Down
12 changes: 6 additions & 6 deletions lib/ModelingToolkitBase/test/common/rc_model.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import ModelingToolkitStandardLibrary.Electrical as El
import ModelingToolkitStandardLibrary.Blocks as Bl
using SciCompDSL

@mtkmodel RCModel begin
@parameters begin
@component function RCModel(; name)
pars = @parameters begin
R = 1.0
C = 1.0
V = 1.0
end
@components begin
systems = @named begin
resistor = El.Resistor(R = R)
capacitor = El.Capacitor(C = C)
shape = Bl.Constant(k = V)
source = El.Voltage()
ground = El.Ground()
end
@equations begin
eqs = [
connect(shape.output, source.V)
connect(source.p, resistor.p)
connect(resistor.n, capacitor.p)
connect(capacitor.n, source.n)
connect(capacitor.n, ground.g)
end
]
System(eqs, t, [], pars; systems, name)
end

@named rc_model = RCModel()
Loading
Loading