Skip to content

Commit 8a34766

Browse files
Merge pull request #3832 from AayushSabharwal/as/ode-nlprob
feat: make `nlprobmap` in-place
2 parents 0aad5b4 + 528ba4b commit 8a34766

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ RecursiveArrayTools = "3.26"
149149
Reexport = "0.2, 1"
150150
RuntimeGeneratedFunctions = "0.5.9"
151151
SCCNonlinearSolve = "1.0.0"
152-
SciMLBase = "2.100.0"
152+
SciMLBase = "2.104.0"
153153
SciMLPublic = "1.0.0"
154154
SciMLStructures = "1.7"
155155
Serialization = "1"

src/systems/solver_nlprob.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function generate_ODENLStepData(sys::System, u0, p, mm = calculate_massmatrix(sy
1818
set_gamma_c = setsym(nlsys, (ODE_GAMMA..., ODE_C))
1919
set_outer_tmp = setsym(nlsys, outer_tmp)
2020
set_inner_tmp = setsym(nlsys, inner_tmp)
21-
nlprobmap = getsym(nlsys, unknowns(sys))
21+
nlprobmap = generate_nlprobmap(sys, nlsys)
2222

2323
return SciMLBase.ODENLStepData(nlprob, subsetidxs, set_gamma_c, set_outer_tmp, set_inner_tmp, nlprobmap)
2424
end
@@ -58,3 +58,19 @@ function inner_nlsystem(sys::System, mm)
5858
nlsys = mtkcompile(System(new_eqs, new_dvs, new_ps; name = :nlsys); split = is_split(sys))
5959
return nlsys, outer_tmp, inner_tmp
6060
end
61+
62+
struct NLStep_probmap{F}
63+
f::F
64+
end
65+
66+
function (nlp::NLStep_probmap)(buffer, nlsol)
67+
nlp.f(buffer, state_values(nlsol), parameter_values(nlsol))
68+
end
69+
70+
function (nlp::NLStep_probmap)(nlsol)
71+
nlp.f(state_values(nlsol), parameter_values(nlsol))
72+
end
73+
74+
function generate_nlprobmap(sys::System, nlsys::System)
75+
return NLStep_probmap(build_explicit_observed_function(nlsys, unknowns(sys)))
76+
end

0 commit comments

Comments
 (0)