Skip to content

Commit b20cee5

Browse files
committed
Merge branch 'master' into myb/op
2 parents 7ed1261 + 43fa26f commit b20cee5

19 files changed

+80
-52
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
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.56.0"
4+
version = "8.57.0"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -79,7 +79,7 @@ MacroTools = "0.5"
7979
NaNMath = "0.3, 1"
8080
RecursiveArrayTools = "2.3"
8181
Reexport = "0.2, 1"
82-
RuntimeGeneratedFunctions = "0.4.3, 0.5"
82+
RuntimeGeneratedFunctions = "0.5.9"
8383
SciMLBase = "1.76.1"
8484
Setfield = "0.7, 0.8, 1"
8585
SimpleNonlinearSolve = "0.1.0"

src/ModelingToolkit.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using JumpProcesses
1818
using DataStructures
1919
using SpecialFunctions, NaNMath
2020
using RuntimeGeneratedFunctions
21+
using RuntimeGeneratedFunctions: drop_expr
2122
using Base.Threads
2223
using DiffEqCallbacks
2324
using Graphs

src/structural_transformation/StructuralTransformations.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ using ModelingToolkit.SystemStructures: algeqs, EquationsView
3434

3535
using ModelingToolkit.DiffEqBase
3636
using ModelingToolkit.StaticArrays
37-
using ModelingToolkit: @RuntimeGeneratedFunction, RuntimeGeneratedFunctions
37+
using RuntimeGeneratedFunctions: @RuntimeGeneratedFunction, RuntimeGeneratedFunctions,
38+
drop_expr
3839

3940
RuntimeGeneratedFunctions.init(@__MODULE__)
4041

src/structural_transformation/bipartite_tearing/modia_tearing.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ function tear_graph_modia(structure::SystemStructure, isder::F = nothing,
7373
# find them here [TODO: It would be good to have an explicit example of this.]
7474

7575
@unpack graph, solvable_graph = structure
76-
var_eq_matching = complete(maximal_matching(graph, eqfilter, varfilter, U))
76+
var_eq_matching = maximal_matching(graph, eqfilter, varfilter, U)
77+
var_eq_matching = complete(var_eq_matching,
78+
max(length(var_eq_matching),
79+
maximum(x -> x isa Int ? x : 0, var_eq_matching)))
7780
var_sccs::Vector{Union{Vector{Int}, Int}} = find_var_sccs(graph, var_eq_matching)
7881
vargraph = DiCMOBiGraph{true}(graph)
7982
ict = IncrementalCycleTracker(vargraph; dir = :in)

src/structural_transformation/codegen.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function gen_nlsolve!(is_not_prepended_assignment, eqs, vars, u0map::AbstractDic
219219
end
220220

221221
nlsolve_expr = Assignment[preassignments
222-
fname @RuntimeGeneratedFunction(f)
222+
fname drop_expr(@RuntimeGeneratedFunction(f))
223223
DestructuredArgs(vars, inbounds = !checkbounds) solver_call]
224224

225225
nlsolve_expr
@@ -345,7 +345,7 @@ function build_torn_function(sys;
345345
end
346346
end
347347

348-
ODEFunction{true, SciMLBase.AutoSpecialize}(@RuntimeGeneratedFunction(expr),
348+
ODEFunction{true, SciMLBase.AutoSpecialize}(drop_expr(@RuntimeGeneratedFunction(expr)),
349349
sparsity = jacobian_sparsity ?
350350
torn_system_with_nlsolve_jacobian_sparsity(state,
351351
var_eq_matching,
@@ -501,7 +501,7 @@ function build_observed_function(state, ts, var_eq_matching, var_sccs,
501501
isscalar ? ts[1] : MakeArray(ts, output_type),
502502
false))), sol_states)
503503

504-
expression ? ex : @RuntimeGeneratedFunction(ex)
504+
expression ? ex : drop_expr(@RuntimeGeneratedFunction(ex))
505505
end
506506

507507
"""

src/structural_transformation/symbolics_tearing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,10 @@ Tear the nonlinear equations in system. When `simplify=true`, we simplify the
583583
new residual equations after tearing. End users are encouraged to call [`structural_simplify`](@ref)
584584
instead, which calls this function internally.
585585
"""
586-
function tearing(sys::AbstractSystem; simplify = false)
587-
state = TearingState(sys)
586+
function tearing(sys::AbstractSystem, state = TearingState(sys); mm = nothing,
587+
simplify = false, kwargs...)
588588
var_eq_matching = tearing(state)
589-
invalidate_cache!(tearing_reassemble(state, var_eq_matching; simplify = simplify))
589+
invalidate_cache!(tearing_reassemble(state, var_eq_matching; mm, simplify))
590590
end
591591

592592
"""

src/systems/alias_elimination.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ function observed2graph(eqs, states)
468468
end
469469

470470
function fixpoint_sub(x, dict)
471-
y = substitute(x, dict)
471+
y = fast_substitute(x, dict)
472472
while !isequal(x, y)
473473
y = x
474-
x = substitute(y, dict)
474+
x = fast_substitute(y, dict)
475475
end
476476

477477
return x

src/systems/callbacks.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ function compile_affect(eqs::Vector{Equation}, sys, dvs, ps; outputidxs = nothin
354354
# applied user-provided function to the generated expression
355355
if postprocess_affect_expr! !== nothing
356356
postprocess_affect_expr!(rf_ip, integ)
357-
(expression == Val{false}) && (return @RuntimeGeneratedFunction(rf_ip))
357+
(expression == Val{false}) &&
358+
(return drop_expr(@RuntimeGeneratedFunction(rf_ip)))
358359
end
359360
rf_ip
360361
end

src/systems/clock_inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function generate_discrete_affect(syss, inputs, continuous_id, id_to_clock;
225225
end
226226
if eval_expression
227227
affects = map(affect_funs) do a
228-
@RuntimeGeneratedFunction(eval_module, toexpr(LiteralExpr(a)))
228+
drop_expr(@RuntimeGeneratedFunction(eval_module, toexpr(LiteralExpr(a))))
229229
end
230230
else
231231
affects = map(a -> toexpr(LiteralExpr(a)), affect_funs)

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = s
281281
expression_module = eval_module, checkbounds = checkbounds,
282282
kwargs...)
283283
f_oop, f_iip = eval_expression ?
284-
(@RuntimeGeneratedFunction(eval_module, ex) for ex in f_gen) : f_gen
284+
(drop_expr(@RuntimeGeneratedFunction(eval_module, ex)) for ex in f_gen) :
285+
f_gen
285286
f(u, p, t) = f_oop(u, p, t)
286287
f(du, u, p, t) = f_iip(du, u, p, t)
287288

@@ -299,7 +300,7 @@ function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = s
299300
expression_module = eval_module,
300301
checkbounds = checkbounds, kwargs...)
301302
tgrad_oop, tgrad_iip = eval_expression ?
302-
(@RuntimeGeneratedFunction(eval_module, ex) for ex in tgrad_gen) :
303+
(drop_expr(@RuntimeGeneratedFunction(eval_module, ex)) for ex in tgrad_gen) :
303304
tgrad_gen
304305
_tgrad(u, p, t) = tgrad_oop(u, p, t)
305306
_tgrad(J, u, p, t) = tgrad_iip(J, u, p, t)
@@ -314,7 +315,7 @@ function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = s
314315
expression_module = eval_module,
315316
checkbounds = checkbounds, kwargs...)
316317
jac_oop, jac_iip = eval_expression ?
317-
(@RuntimeGeneratedFunction(eval_module, ex) for ex in jac_gen) :
318+
(drop_expr(@RuntimeGeneratedFunction(eval_module, ex)) for ex in jac_gen) :
318319
jac_gen
319320
_jac(u, p, t) = jac_oop(u, p, t)
320321
_jac(J, u, p, t) = jac_iip(J, u, p, t)
@@ -423,7 +424,8 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
423424
expression_module = eval_module, checkbounds = checkbounds,
424425
kwargs...)
425426
f_oop, f_iip = eval_expression ?
426-
(@RuntimeGeneratedFunction(eval_module, ex) for ex in f_gen) : f_gen
427+
(drop_expr(@RuntimeGeneratedFunction(eval_module, ex)) for ex in f_gen) :
428+
f_gen
427429
f(du, u, p, t) = f_oop(du, u, p, t)
428430
f(out, du, u, p, t) = f_iip(out, du, u, p, t)
429431

@@ -434,7 +436,7 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
434436
expression_module = eval_module,
435437
checkbounds = checkbounds, kwargs...)
436438
jac_oop, jac_iip = eval_expression ?
437-
(@RuntimeGeneratedFunction(eval_module, ex) for ex in jac_gen) :
439+
(drop_expr(@RuntimeGeneratedFunction(eval_module, ex)) for ex in jac_gen) :
438440
jac_gen
439441
_jac(du, u, p, ˍ₋gamma, t) = jac_oop(du, u, p, ˍ₋gamma, t)
440442

0 commit comments

Comments
 (0)