Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8d47389
tearing: Heuristically attempt to assign equations with single solvab…
Keno Jul 2, 2023
c6af68d
Parse the args in extended components (#2202)
ven-k Jul 3, 2023
9c58a2a
Update Project.toml
YingboMa Jul 3, 2023
17448ed
Update tests
YingboMa Jul 4, 2023
a07e8e3
Merge pull request #2203 from Keno/kf/tearingsingle
YingboMa Jul 4, 2023
c458b85
Update Project.toml
YingboMa Jul 4, 2023
47d8f05
Add `isconnector` to `Model` type + add all metadata to `Model.struct…
ven-k Jul 5, 2023
207adaa
Add DDEs support in `structural_simplify`
YingboMa Jul 10, 2023
023d370
Add DDE lowering
YingboMa Jul 10, 2023
8e422ee
Fix TearingState construction
YingboMa Jul 11, 2023
7d594a1
Symbolic support for DDE histories
YingboMa Jul 11, 2023
5b678b2
Fix test
YingboMa Jul 11, 2023
045782f
Fix tests
YingboMa Jul 11, 2023
d76d73f
Fix `isdelay` for NonlinearSystem
YingboMa Jul 11, 2023
e63aad0
Merge pull request #2207 from SciML/myb/dde
ChrisRackauckas Jul 12, 2023
008071d
SDDE support
YingboMa Jul 12, 2023
46c8a2f
Working tests
YingboMa Jul 12, 2023
24d0d7c
Merge pull request #2208 from SciML/myb/sdde
YingboMa Jul 13, 2023
b0b1c3a
fix: update the `Torque` and `Mass` components wrt to MSL-2.0.
ven-k Jul 19, 2023
eabda48
Merge pull request #2212 from ven-k/vkb/msl-2-updates
ChrisRackauckas Jul 20, 2023
b865ff2
Update Project.toml
ChrisRackauckas Jul 20, 2023
6636398
fix breaking changes
Jul 24, 2023
4aa29a0
Merge pull request #2214 from SciML/bgc/gui_fix
ChrisRackauckas Jul 24, 2023
89df241
Make introspecting `dummy_derivative` easier
YingboMa Jul 29, 2023
c91992e
Merge branch 'master' into myb/vis
YingboMa Jul 31, 2023
48c8e91
Update tests
YingboMa Jul 31, 2023
fd58156
Relax tolerance
YingboMa Jul 31, 2023
e1c34ec
Merge pull request #2218 from SciML/myb/vis
YingboMa Aug 1, 2023
b9f285d
Update Project.toml
YingboMa Aug 1, 2023
8899e67
Update ParentScope example in Composition.md
hstrey Aug 3, 2023
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
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ModelingToolkit"
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
authors = ["Yingbo Ma <mayingbo5@gmail.com>", "Chris Rackauckas <accounts@chrisrackauckas.com> and contributors"]
version = "8.60.0"
version = "8.64.0"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down Expand Up @@ -114,9 +114,10 @@ SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SteadyStateDiffEq = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"
StochasticDelayDiffEq = "29a0d76e-afc8-11e9-03a4-eda52ae4b960"
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsMTK", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials"]
test = ["AmplNLWriter", "BenchmarkTools", "ControlSystemsMTK", "NonlinearSolve", "ForwardDiff", "Ipopt", "Ipopt_jll", "ModelingToolkitStandardLibrary", "Optimization", "OptimizationOptimJL", "OptimizationMOI", "OrdinaryDiffEq", "Random", "ReferenceTests", "SafeTestsets", "StableRNGs", "Statistics", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials", "StochasticDelayDiffEq"]
15 changes: 9 additions & 6 deletions docs/src/basics/Composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ In a hierarchical system, variables of the subsystem get namespaced by the name

```julia
@parameters t a b c d e f
p = [a #a is a local variable
ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
ParentScope(ParentScope(c))# ParentScope can be nested
DelayParentScope(d) # skips one level before applying ParentScope
DelayParentScope(e, 2) # second argument allows skipping N levels
GlobalScope(f)]

# a is a local variable
b = ParentScope(b) # b is a variable that belongs to one level up in the hierarchy
c = ParentScope(ParentScope(c)) # ParentScope can be nested
d = DelayParentScope(d) # skips one level before applying ParentScope
e = DelayParentScope(e, 2) # second argument allows skipping N levels
f = GlobalScope(f)

p = [a, b, c, d, e, f]

level0 = ODESystem(Equation[], t, [], p; name = :level0)
level1 = ODESystem(Equation[], t, [], []; name = :level1) ∘ level0
Expand Down
2 changes: 1 addition & 1 deletion src/inputoutput.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ c = 10 # Damping coefficient
@named inertia2 = Inertia(; J = m2)
@named spring = Spring(; c = k)
@named damper = Damper(; d = c)
@named torque = Torque()
@named torque = Torque(; use_support = false)

eqs = [connect(torque.flange, inertia1.flange_a)
connect(inertia1.flange_b, spring.flange_a, damper.flange_a)
Expand Down
27 changes: 16 additions & 11 deletions src/structural_transformation/bipartite_tearing/modia_tearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int}
end
end
end
for eq in es # iterate only over equations that are not in eSolvedFixed
vs = Gsolvable[eq]
if check_der
# if there're differentiated variables, then only consider them
try_assign_eq!(ict, vs, v_active, eq, isder)
if has_der[]
has_der[] = false
continue
# Heuristic: As a first pass, try to assign any equations that only have one
# solvable variable.
for only_single_solvable in (true, false)
for eq in es # iterate only over equations that are not in eSolvedFixed
vs = Gsolvable[eq]
((length(vs) == 1) ⊻ only_single_solvable) && continue
if check_der
# if there're differentiated variables, then only consider them
try_assign_eq!(ict, vs, v_active, eq, isder)
if has_der[]
has_der[] = false
continue
end
end
try_assign_eq!(ict, vs, v_active, eq)
end
try_assign_eq!(ict, vs, v_active, eq)
end

return ict
Expand Down Expand Up @@ -77,6 +82,7 @@ function tear_graph_modia(structure::SystemStructure, isder::F = nothing,
var_eq_matching = complete(var_eq_matching,
max(length(var_eq_matching),
maximum(x -> x isa Int ? x : 0, var_eq_matching)))
full_var_eq_matching = copy(var_eq_matching)
var_sccs::Vector{Union{Vector{Int}, Int}} = find_var_sccs(graph, var_eq_matching)
vargraph = DiCMOBiGraph{true}(graph)
ict = IncrementalCycleTracker(vargraph; dir = :in)
Expand Down Expand Up @@ -105,6 +111,5 @@ function tear_graph_modia(structure::SystemStructure, isder::F = nothing,
empty!(ieqs)
empty!(filtered_vars)
end

return var_eq_matching
return var_eq_matching, full_var_eq_matching
end
15 changes: 10 additions & 5 deletions src/structural_transformation/partial_state_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match
end

function dummy_derivative_graph!(state::TransformationState, jac = nothing;
state_priority = nothing, kwargs...)
state_priority = nothing, log = Val(false), kwargs...)
state.structure.solvable_graph === nothing && find_solvables!(state; kwargs...)
complete!(state.structure)
var_eq_matching = complete(pantelides!(state))
dummy_derivative_graph!(state.structure, var_eq_matching, jac, state_priority)
dummy_derivative_graph!(state.structure, var_eq_matching, jac, state_priority, log)
end

function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, jac,
state_priority)
state_priority, ::Val{log} = Val(false)) where {log}
@unpack eq_to_diff, var_to_diff, graph = structure
diff_to_eq = invview(eq_to_diff)
diff_to_var = invview(var_to_diff)
Expand Down Expand Up @@ -338,7 +338,7 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
end
end

var_eq_matching = tear_graph_modia(structure, isdiffed,
var_eq_matching, full_var_eq_matching = tear_graph_modia(structure, isdiffed,
Union{Unassigned, SelectedState};
varfilter = can_eliminate)
for v in eachindex(var_eq_matching)
Expand All @@ -348,5 +348,10 @@ function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, ja
var_eq_matching[v] = SelectedState()
end

return var_eq_matching
if log
candidates = can_eliminate.(1:ndsts(graph))
return var_eq_matching, full_var_eq_matching, candidates
else
return var_eq_matching
end
end
2 changes: 1 addition & 1 deletion src/structural_transformation/symbolics_tearing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function tearing(state::TearingState; kwargs...)
@unpack graph = state.structure
algvars = BitSet(findall(v -> isalgvar(state.structure, v), 1:ndsts(graph)))
aeqs = algeqs(state.structure)
var_eq_matching′ = tear_graph_modia(state.structure;
var_eq_matching′, = tear_graph_modia(state.structure;
varfilter = var -> var in algvars,
eqfilter = eq -> eq in aeqs)
var_eq_matching = Matching{Union{Unassigned, SelectedState}}(var_eq_matching′)
Expand Down
2 changes: 1 addition & 1 deletion src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ function varname_fix!(expr::Expr)
for arg in expr.args
MLStyle.@match arg begin
::Symbol => continue
Expr(:kw, a) => varname_sanitization!(arg)
Expr(:kw, a...) || Expr(:kw, a) => varname_sanitization!(arg)
Expr(:parameters, a...) => begin
for _arg in arg.args
varname_sanitization!(_arg)
Expand Down
Loading