# Combined ParametricNDSolveValue with Do loop?

two weeks ago, I post a question see, and I got its answer, however, I would like to vary the values: g from (0.02 to 0.07), R from (0.1 to 0.3),and k2 from (0.03 to 0.07) by an increment of 0.01 using for Do loop. Can you please help?

• And what do you need to get out of the loop? Sep 28 '18 at 3:22
• I want to see the behavior of y' and y? Sep 28 '18 at 4:38
• How do you want to visualize data - on a plane or in space? Sep 28 '18 at 5:30
• I want to visualize data on a plane. Sep 28 '18 at 5:36
• A set of curves on one plane or each curve on one plane? Sep 28 '18 at 5:46

It is possible to use the following model for parametric studies.

p[Z0_, g0_, k0_, R0_] := Block[{Z = Z0, g = Rationalize[g0, 0],
k2 = Rationalize[k0, 0],
\[Epsilon] = 10^-4, R = Rationalize[R0, 0]},
ps = ParametricNDSolveValue[{y''[r] + 2 y'[r]/r == k2 Sinh[y[r]],
y[\[Epsilon]] == y0, y'[\[Epsilon]] == 0,
WhenEvent[r == 1, y'[r] -> y'[r] + Z g]}, {y,
y'}, {r, \[Epsilon], R}, {y0}, Method -> "StiffnessSwitching",
WorkingPrecision -> 20];
sol = FindRoot[Last[ps[y0]][R], {y0, -1},
Evaluated -> False][[1, 2]];
Plot[First[ps[sol]][r], {r, \[Epsilon], R}, AxesLabel -> {r, y},
PlotLabel ->
Grid[{{"Z", "g", "k2", "R"}, {Z0, g0, k0, R0}}, Frame -> All]]]

p1[Z0_, g0_, k0_, R0_] := Block[{Z = Z0, g = Rationalize[g0, 0],
k2 = Rationalize[k0, 0],
\[Epsilon] = 10^-4, R = Rationalize[R0, 0]},
ps = ParametricNDSolveValue[{y''[r] + 2 y'[r]/r == k2 Sinh[y[r]],
y[\[Epsilon]] == y0, y'[\[Epsilon]] == 0,
WhenEvent[r == 1, y'[r] -> y'[r] + Z g]}, {y,
y'}, {r, \[Epsilon], R}, {y0}, Method -> "StiffnessSwitching",
WorkingPrecision -> 20];
sol = FindRoot[Last[ps[y0]][R], {y0, -1},
Evaluated -> False][[1, 2]];
Plot[Last[ps[sol]][r], {r, \[Epsilon], R}, AxesLabel -> {r, y'},
PlotLabel ->
Grid[{{"Z", "g", "k2", "R"}, {Z0, g0, k0, R0}}, Frame -> All]]]


Two examples of using this code

Quiet[Table[
p[800, g, 0.0002, 1.5], {g, 0.02, 0.06, .02}]] // AbsoluteTiming

Quiet[Table[
p[800, .02, 0.0002, R], {R, 1.2, 1.7, .1}]] // AbsoluteTiming • Thank you so much, What is this method doing exactly? also, what is p1 and p ? Sep 28 '18 at 17:02
• Can I do this in one step 'Quiet[Table[ p[800, g, 0.0002, R], {g, 0.02, 0.06, .02}, {R, 1.2, 1.7, .1}]] // AbsoluteTiming' .? Sep 28 '18 at 17:13
• p and p1 are the figures y and y', respectively, as the solution of the problem with the selection of parameters indicated at the top of each of the figures. You can use tables with any combination of parameters, but I checked only two of them. Sep 29 '18 at 3:33