I want to solve a DAE-system and I want to vary more than one initial conditions and to manipulate them. I looked here:
Putting NDSolve into ParametricPlot
But it does not work:
alpha = 0.5
beta = 1
sol = ParametricNDSolve[{
x'[t] == -x[t]*a[t] - 3*x[t] + alpha*y[t]^2 + 1/2*beta*(r1[t]^2 - r2[t]^2),
y'[t] == -y[t]*a[t] - alpha*x[t]*y[t],
r1'[t] == -r1[t]*a[t] - 3/2*r1[t] + beta*x[t]*r1[t],
r2'[t] == -r2[t]*a[t] - 3/2*r2[t] + beta*x[t]*r2[t],
a[t] == -1/2*(3 - 3*y[t]^2 + 3*x[t]^2),
x[-10] == b, y[-10] == c, r1[-10] == 0.2, r2[-10] == 0.2},
{x, y, r1, r2},
{t, 1, -10}, {b, c}]
Manipulate[
ParametricPlot[y[c][t] + x[b][t], {t, 0, -5}], {b, 0, 1}, {c, 0, 1}]
solf[b,c,tp]is a list of the solutions{x[tp], y[tp], r1[tp], r2[tp]}where I've usedtpas a dummy variable fort. solf[b,c,tp][[1;;2]] then takes the first to second elements of this list (look up;;in the documentation). Taking the total of this gives the sum of the first and second elements:x[tp]+y[tp]. The use ofModulecan be found in the documentation too. These allow you to define functions with local variables and are often used to combine a number of functions together into a single algorithm to solve a problem. – Jonathan Shock May 14 '13 at 23:23