Let's consider a set of equations with initial conditions. Since equations of my interest are complicated, I want to solve those with ParametricNDSolve.
For simplicity let's discuss linear equations though.
testEquations = {x'[t] == a, y'[t] == b, x[0] == x0, y[0] == y0};
xy = ParametricNDSolveValue[testEquations, {x, y}, {t, -10, 10}, {a, b, x0, y0}];
The result I expect is a list of 2 interpolating functions (one for x, one for y), which should return me functions of t after substituting the parameters.
Now if we substitute something
subs = {a -> 1, b -> 1, x0 -> 1, y0 -> 2};
xy[a, b, x0, y0][[1]][t] /. subs
The output is
1[t]
The same output is for xy[a, b, x0, y0][[2]][t]
and
xy[a, b, x0, y0][[1]] /. subs
Returns just 1
.
In addition,
xy[1, 1, 1, 1][[1]][0] /. subs
Gives output
ParametricNDSolveValue::ndnum: Encountered non-numerical value for a derivative at t == 0.`. >>
1[0]
Does anyone know what did I miss?
I am using Mathematica 10.3.1
xy[a, b, x0, y0][[1]][t]
givesa[t]
, and this is the first that is evaluated. Then you apply the rules on this output - it's about the order of evaluation (like differentation - $f'(2)$ doesn't mean to differentiate $f(2)$). Why not justSet
the values of parameters? $\endgroup$