1+
12function test_instantaneous (
23 sys:: ModelingToolkit.AbstractSystem ,
34 ic,
@@ -6,8 +7,8 @@ function test_instantaneous(
67 if ! SymbolicIndexingInterface. is_observed (checks)
78 @assert false " The given check values are not observed values of the given system"
89 end
9- sv = ModelingToolkit. varmap_to_vars (ic, states (sys); defaults= ModelingToolkit . defaults (sys))
10- pv = ModelingToolkit. varmap_to_vars (ic, parameters (sys); defaults= ModelingToolkit . defaults (sys))
10+ sv = ModelingToolkit. varmap_to_vars (ic, variable_symbols (sys); defaults= default_values (sys))
11+ pv = ModelingToolkit. varmap_to_vars (ic, parameter_symbols (sys); defaults= default_values (sys))
1112
1213 obsfun = SymbolicIndexingInterface. observed (sys, checks)
1314 if SymbolicIndexingInterface. istimedependent (sys)
@@ -25,21 +26,9 @@ function test_instantaneous(
2526 ic,
2627 checks:: Array ;
2728 t = nothing ) # todo: after porting to v9 use InitializationSystem to solve the checks system
28- if ! all (SymbolicIndexingInterface. is_observed .((sys, ), checks))
29- @assert false " The given check values are not observed values of the given system"
30- end
31- sv = ModelingToolkit. varmap_to_vars (ic, states (sys); defaults= ModelingToolkit. defaults (sys))
32- pv = ModelingToolkit. varmap_to_vars (ic, parameters (sys); defaults= ModelingToolkit. defaults (sys))
33-
34- obsfuns = SymbolicIndexingInterface. observed .((ODEFunction (sys),), checks)
35- if SymbolicIndexingInterface. is_time_dependent (sys)
36- @assert ! isnothing (t) " The kwarg t must be given (and be a non-nothing value) if the system is time dependent"
37- return map (fun -> fun (sv, pv, t), obsfuns)
38- elseif ! SymbolicIndexingInterface. constant_structure (sys)
39- @assert false " The system's structure must be constant to use test_instantaneous; to be fixed" # TODO
40- else
41- return map (fun -> fun (sv, pv), obsfuns)
42- end
29+ prob = ODEProblem (sys, ic, (0.0 , 0.0 ))
30+ getter = getu (prob, checks)
31+ return getter (prob)
4332end
4433
4534export test_instantaneous
0 commit comments