Skip to content

Commit a055cb3

Browse files
committed
Merge branch 'master' into myb/connector_type
2 parents 1f1b48f + 98e4621 commit a055cb3

File tree

7 files changed

+50
-3
lines changed

7 files changed

+50
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModelingToolkit"
22
uuid = "961ee093-0014-501f-94e3-6117800e7a78"
33
authors = ["Yingbo Ma <[email protected]>", "Chris Rackauckas <[email protected]> and contributors"]
4-
version = "8.29.1"
4+
version = "8.30.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

docs/make.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
using Documenter, ModelingToolkit
22

3+
# Make sure that plots don't throw a bunch of warnings / errors!
4+
ENV["GKSwstype"] = "100"
5+
using Plots
6+
37
include("pages.jl")
48

59
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),

docs/src/basics/ContextualVariables.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ All modeling projects have some form of parameters. `@parameters` marks a variab
2020
as being the parameter of some system, which allows automatic detection algorithms
2121
to ignore such variables when attempting to find the states of a system.
2222

23+
## Wildcard Variable Arguments
24+
25+
```julia
26+
@variables u(..)
27+
```
28+
29+
It is possible to define a dependent variable which is an open function as above,
30+
for which its arguments must be specified each time it is used. This is useful with
31+
PDEs for example, where one may need to use `u(t, x)` in the equations, but will
32+
need to be able to write `u(t, 0.0)` to define a boundary condition at `x = 0`.
33+
2334
## Variable metadata [Experimental/TODO]
2435

2536
In many engineering systems some variables act like "flows" while others do not.

src/systems/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ function _named(name, call, runtime = false)
846846
end
847847
end
848848

849-
is_sys_construction = Symbol("###__is_system_construction###")
849+
is_sys_construction = gensym("###__is_system_construction###")
850850
kws = call.args[2].args
851851
for (i, kw) in enumerate(kws)
852852
if Meta.isexpr(kw, (:(=), :kw))

src/systems/alias_elimination.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,17 +708,27 @@ function alias_eliminate_graph!(graph, var_to_diff, mm_orig::SparseMatrixCLIL)
708708
prev_r = -1
709709
for _ in 1:10_000 # just to make sure that we don't stuck in an infinite loop
710710
reach₌ = Pair{Int, Int}[]
711+
# `r` is aliased to its equality aliases
711712
r === nothing || for n in neighbors(eqg, r)
712713
(n == r || is_diff_edge(r, n)) && continue
713714
c = get_weight(eqg, r, n)
714715
push!(reach₌, c => n)
715716
end
717+
# `r` is aliased to its previous differentiation level's aliases'
718+
# derivative
716719
if (n = length(diff_aliases)) >= 1
717720
as = diff_aliases[n]
718721
for (c, a) in as
719722
(da = var_to_diff[a]) === nothing && continue
720723
da === r && continue
721724
push!(reach₌, c => da)
725+
# `r` is aliased to its previous differentiation level's
726+
# aliases' derivative's equality aliases
727+
r === nothing || for n in neighbors(eqg, da)
728+
(n == da || n == prev_r || is_diff_edge(prev_r, n)) && continue
729+
c′ = get_weight(eqg, da, n)
730+
push!(reach₌, c * c′ => n)
731+
end
722732
end
723733
end
724734
if r === nothing

src/systems/optimization/optimizationsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ function OptimizationProblemExpr(sys::OptimizationSystem, args...; kwargs...)
329329
OptimizationProblemExpr{true}(sys::OptimizationSystem, args...; kwargs...)
330330
end
331331

332-
function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0,
332+
function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map,
333333
parammap = DiffEqBase.NullParameters();
334334
lb = nothing, ub = nothing,
335335
grad = false,

test/reduction.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,25 @@ ss = alias_elimination(sys)
302302
@test length(equations(ss)) == length(states(ss)) == 1
303303
ss = structural_simplify(sys)
304304
@test length(equations(ss)) == length(states(ss)) == 2
305+
306+
@variables t
307+
vars = @variables x(t) y(t) k(t) z(t) zₜ(t) ddx(t)
308+
D = Differential(t)
309+
eqs = [D(D(x)) ~ ddx
310+
ddx ~ y
311+
D(x) ~ z
312+
D(z) ~ zₜ
313+
D(zₜ) ~ sin(t)
314+
D(x) ~ D(k)
315+
D(D(D(x))) ~ sin(t)]
316+
@named sys = ODESystem(eqs, t, vars, [])
317+
state = TearingState(sys);
318+
ag, mm, complete_ag, complete_mm = ModelingToolkit.alias_eliminate_graph!(state)
319+
fullvars = state.fullvars
320+
aliases = []
321+
for (v, (c, a)) in complete_ag
322+
push!(aliases, fullvars[v] => c == 0 ? 0 : c * fullvars[a])
323+
end
324+
ref_aliases = [D(k) => D(x); z => D(x); D(z) => D(D(x)); zₜ => D(D(x)); ddx => D(D(x));
325+
y => D(D(x)); D(zₜ) => D(D(D(x)))]
326+
@test Set(aliases) == Set(ref_aliases)

0 commit comments

Comments
 (0)