Skip to content

Commit b6c9e78

Browse files
Pass syms, indepsym, paramsyms as before
1 parent e57a27f commit b6c9e78

File tree

8 files changed

+41
-29
lines changed

8 files changed

+41
-29
lines changed

src/ModelingToolkit.jl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,8 @@ abstract type AbstractODESystem <: AbstractTimeDependentSystem end
9999
abstract type AbstractMultivariateSystem <: AbstractSystem end
100100
abstract type AbstractOptimizationSystem <: AbstractTimeIndependentSystem end
101101

102-
# """
103-
# $(TYPEDSIGNATURES)
104-
105-
# Get the set of independent variables for the given system.
106-
# """
107-
# function independent_variables end
108-
109102
function independent_variable end
110103

111-
# """
112-
# $(TYPEDSIGNATURES)
113-
114-
# Get the set of states for the given system.
115-
# """
116-
# function states end
117-
118-
# """
119-
# $(TYPEDSIGNATURES)
120-
121-
# Get the set of parameters variables for the given system.
122-
# """
123-
# function parameters end
124-
125104
# this has to be included early to deal with depency issues
126105
include("structural_transformation/bareiss.jl")
127106
function complete end

src/structural_transformation/codegen.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ function build_torn_function(sys;
353353
eqs_idxs,
354354
states_idxs) :
355355
nothing,
356-
# syms = syms,
357-
# paramsyms = Symbol.(parameters(sys)),
358-
# indepsym = Symbol(get_iv(sys)),
356+
syms = syms,
357+
paramsyms = Symbol.(parameters(sys)),
358+
indepsym = Symbol(get_iv(sys)),
359359
observed = observedfun,
360360
mass_matrix = mass_matrix,
361361
sys = sys), states

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = s
380380
tgrad = _tgrad === nothing ? nothing : _tgrad,
381381
mass_matrix = _M,
382382
jac_prototype = jac_prototype,
383+
syms = Symbol.(states(sys)),
384+
indepsym = Symbol(get_iv(sys)),
385+
paramsyms = Symbol.(ps),
383386
observed = observedfun,
384387
sparsity = sparsity ? jacobian_sparsity(sys) : nothing)
385388
end
@@ -470,6 +473,9 @@ function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys),
470473
DAEFunction{iip}(f,
471474
sys = sys,
472475
jac = _jac === nothing ? nothing : _jac,
476+
syms = Symbol.(dvs),
477+
indepsym = Symbol(get_iv(sys)),
478+
paramsyms = Symbol.(ps),
473479
jac_prototype = jac_prototype,
474480
observed = observedfun)
475481
end
@@ -553,6 +559,9 @@ function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys),
553559
tgrad = $tgradsym,
554560
mass_matrix = M,
555561
jac_prototype = $jp_expr,
562+
syms = $(Symbol.(states(sys))),
563+
indepsym = $(QuoteNode(Symbol(get_iv(sys)))),
564+
paramsyms = $(Symbol.(parameters(sys))),
556565
sparsity = $(sparsity ? jacobian_sparsity(sys) : nothing))
557566
end
558567
!linenumbers ? striplines(ex) : ex

src/systems/diffeqs/sdesystem.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ function DiffEqBase.SDEFunction{iip}(sys::SDESystem, dvs = states(sys),
437437
Wfact = _Wfact === nothing ? nothing : _Wfact,
438438
Wfact_t = _Wfact_t === nothing ? nothing : _Wfact_t,
439439
mass_matrix = _M,
440+
syms = Symbol.(states(sys)),
441+
indepsym = Symbol(get_iv(sys)),
442+
paramsyms = Symbol.(ps),
440443
observed = observedfun)
441444
end
442445

@@ -520,7 +523,10 @@ function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys),
520523
tgrad = tgrad,
521524
Wfact = Wfact,
522525
Wfact_t = Wfact_t,
523-
mass_matrix = M)
526+
mass_matrix = M,
527+
syms = $(Symbol.(states(sys))),
528+
indepsym = $(Symbol(get_iv(sys))),
529+
paramsyms = $(Symbol.(parameters(sys))))
524530
end
525531
!linenumbers ? striplines(ex) : ex
526532
end

src/systems/discrete_system/discrete_system.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ function SciMLBase.DiscreteProblem(sys::DiscreteSystem, u0map = [], tspan = get_
223223
expression_module = eval_module)
224224
f_oop, _ = (@RuntimeGeneratedFunction(eval_module, ex) for ex in f_gen)
225225
f(u, p, iv) = f_oop(u, p, iv)
226-
fd = DiscreteFunction(f; sys = sys)
226+
fd = DiscreteFunction(f; syms = Symbol.(dvs), indepsym = Symbol(iv), paramsyms = Symbol.(ps))
227227
DiscreteProblem(fd, u0, tspan, p; kwargs...)
228228
end
229229

src/systems/jumps/jumpsystem.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,10 @@ function DiffEqBase.DiscreteProblem(sys::JumpSystem, u0map, tspan::Union{Tuple,
312312
end
313313
end
314314

315-
df = DiscreteFunction{true, true}(f; observed = observedfun)
315+
df = DiscreteFunction{true, true}(f; syms = Symbol.(states(sys)),
316+
indepsym = Symbol(get_iv(sys)),
317+
paramsyms = Symbol.(ps), sys = sys,
318+
observed = observedfun)
316319
DiscreteProblem(df, u0, tspan, p; kwargs...)
317320
end
318321

@@ -351,7 +354,9 @@ function DiscreteProblemExpr(sys::JumpSystem, u0map, tspan::Union{Tuple, Nothing
351354
u0 = $u0
352355
p = $p
353356
tspan = $tspan
354-
df = DiscreteFunction{true, true}(f)
357+
df = DiscreteFunction{true, true}(f; syms = $(Symbol.(states(sys))),
358+
indepsym = $(Symbol(get_iv(sys))),
359+
paramsyms = $(Symbol.(parameters(sys))))
355360
DiscreteProblem(df, u0, tspan, p)
356361
end
357362
end

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ function SciMLBase.NonlinearFunction{iip}(sys::NonlinearSystem, dvs = states(sys
253253
jac_prototype = sparse ?
254254
similar(calculate_jacobian(sys, sparse = sparse),
255255
Float64) : nothing,
256+
syms = Symbol.(states(sys)),
257+
paramsyms = Symbol.(parameters(sys)),
256258
observed = observedfun)
257259
end
258260

@@ -297,7 +299,9 @@ function NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = states(sys),
297299
jac = $_jac
298300
NonlinearFunction{$iip}(f,
299301
jac = jac,
300-
jac_prototype = $jp_expr)
302+
jac_prototype = $jp_expr,
303+
syms = $(Symbol.(states(sys))),
304+
paramsyms = $(Symbol.(parameters(sys))))
301305
end
302306
!linenumbers ? striplines(ex) : ex
303307
end
@@ -326,6 +330,7 @@ function process_NonlinearProblem(constructor, sys::NonlinearSystem, u0map, para
326330

327331
f = constructor(sys, dvs, ps, u0; jac = jac, checkbounds = checkbounds,
328332
linenumbers = linenumbers, parallel = parallel, simplify = simplify,
333+
syms = Symbol.(dvs), paramsyms = Symbol.(ps),
329334
sparse = sparse, eval_expression = eval_expression, kwargs...)
330335
return f, u0, p
331336
end

src/systems/optimization/optimizationsystem.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
352352
grad = _grad,
353353
hess = _hess,
354354
hess_prototype = hess_prototype,
355+
syms = Symbol.(states(sys)),
356+
paramsyms = Symbol.(parameters(sys)),
355357
cons = cons[2],
356358
cons_j = _cons_j,
357359
cons_h = _cons_h,
@@ -368,6 +370,8 @@ function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map,
368370
SciMLBase.NoAD();
369371
grad = _grad,
370372
hess = _hess,
373+
syms = Symbol.(states(sys)),
374+
paramsyms = Symbol.(parameters(sys)),
371375
hess_prototype = hess_prototype,
372376
expr = obj_expr,
373377
observed = observedfun)
@@ -540,6 +544,8 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map,
540544
_f = OptimizationFunction{iip}(f, SciMLBase.NoAD();
541545
grad = grad,
542546
hess = hess,
547+
syms = syms,
548+
paramsyms = paramsyms,
543549
hess_prototype = hess_prototype,
544550
cons = cons,
545551
cons_j = cons_j,
@@ -566,6 +572,8 @@ function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map,
566572
_f = OptimizationFunction{iip}(f, SciMLBase.NoAD();
567573
grad = grad,
568574
hess = hess,
575+
syms = syms,
576+
paramsyms = paramsyms,
569577
hess_prototype = hess_prototype,
570578
expr = obj_expr)
571579
OptimizationProblem{$iip}(_f, u0, p; lb = lb, ub = ub, int = int, kwargs...)

0 commit comments

Comments
 (0)