Skip to content
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
elseif PKG == "ModelingToolkit"
@info "Testing ModelingToolkit"
Pkg.activate(".")
@info "`dev`ing ModelingToolkitBase"
Pkg.develop(PackageSpec(; path = "lib/ModelingToolkitBase"))
@info "Running tests" GROUP
Pkg.test()
elseif PKG == "SciCompDSL"
Expand Down
13 changes: 12 additions & 1 deletion lib/ModelingToolkitBase/ext/MTKDynamicQuantitiesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ function __init__()
only(@independent_variables t [unit = DQ.u"s"])
end
SymbolicUtils.hashcons(unwrap(MTK.t), true)
return MTK.D = Differential(MTK.t)
MTK.D = Differential(MTK.t)
# Workaround for Julia 1.10 compiler bug
# See https://github.com/SciML/ModelingToolkit.jl/issues/4211
return @static if VERSION < v"1.11"
# Force collect_var! compilation to fix collect_vars!
@variables _dummy_t
@parameters _dummy_p
@variables _dummy_x(_dummy_t) = _dummy_p
_us = OrderedSet{SymbolicT}()
_ps = OrderedSet{SymbolicT}()
MTK.collect_var!(_us, _ps, unwrap(_dummy_x), unwrap(_dummy_t); depth = 0)
end
end
#For dispatching get_unit
const Conditional = Union{typeof(ifelse)}
Expand Down
6 changes: 5 additions & 1 deletion lib/ModelingToolkitBase/test/initializationsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,11 @@ end
prob.ps[Initial(y[1])] = 0.5
integ = init(prob, Tsit5(); abstol = 1.0e-6, reltol = 1.0e-6)
@test integ[x] ≈ 0.5
@test integ[y] ≈ [0.5, sqrt(3.5)] atol = 1.0e-6
if VERSION < v"1.11" && !@isdefined(ModelingToolkit) # on lts with MTKBase, this flips sign
@test integ[y] ≈ [0.5, -sqrt(3.5)] atol = 1.0e-6
else
@test integ[y] ≈ [0.5, sqrt(3.5)] atol = 1.0e-6
end
end

@testset "Issue#3342" begin
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import REPL

const MTKBasePath = joinpath(dirname(@__DIR__), "lib", "ModelingToolkitBase")
const MTKBasePkgSpec = PackageSpec(; path = MTKBasePath)
Pkg.develop([MTKBasePkgSpec])

const GROUP = get(ENV, "GROUP", "All")

Expand Down
16 changes: 8 additions & 8 deletions test/structural_transformation/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ end
mapping = map_variables_to_equations(sys)
x1 = operation(unwrap(osc1.x))
x2 = operation(unwrap(osc2.x))
@test mapping[osc1.x] == (D(osc1.x) ~ osc1.y)
@test mapping[osc1.y] == (D(osc1.y) ~ osc1.jcn - osc1.k * x1(t - osc1.τ))
@test mapping[osc1.delx] == (osc1.delx ~ x1(t - osc1.τ))
@test mapping[osc1.jcn] == (osc1.jcn ~ osc2.delx)
@test mapping[osc2.x] == (D(osc2.x) ~ osc2.y)
@test mapping[osc2.y] == (D(osc2.y) ~ osc2.jcn - osc2.k * x2(t - osc2.τ))
@test mapping[osc2.delx] == (osc2.delx ~ x2(t - osc2.τ))
@test mapping[osc2.jcn] == (osc2.jcn ~ osc1.delx)
@test mapping[sys.osc1.x] == (D(sys.osc1.x) ~ sys.osc1.y)
@test mapping[sys.osc1.y] == (D(sys.osc1.y) ~ sys.osc1.jcn - sys.osc1.k * x1(t - sys.osc1.τ))
@test mapping[sys.osc1.delx] == (sys.osc1.delx ~ x1(t - sys.osc1.τ))
@test mapping[sys.osc1.jcn] == (sys.osc1.jcn ~ sys.osc2.delx)
@test mapping[sys.osc2.x] == (D(sys.osc2.x) ~ sys.osc2.y)
@test mapping[sys.osc2.y] == (D(sys.osc2.y) ~ sys.osc2.jcn - sys.osc2.k * x2(t - sys.osc2.τ))
@test mapping[sys.osc2.delx] == (sys.osc2.delx ~ x2(t - sys.osc2.τ))
@test mapping[sys.osc2.jcn] == (sys.osc2.jcn ~ sys.osc1.delx)
@test length(mapping) == 8
end
end
Expand Down
Loading