I am trying to use `ParalleDo`

function through ParametricNDSolveValue and NIntegrate.

The question is pretty similar how to apply `paralleDo`

to my code

First I intend to use `Do`

loop and its works fine but It cost a longer time, so to reduce the computational time I want to use `ParalleDo`

, but I get an error message and I don’t understand where it comes from.

Moreover, I intend to write the output data in data file formate by using

` file = OpenWrite[ "file1.dat", FormatType -> TableForm]; `

But I got the following error `OutputStream[file1.dat ,3] is not open.`

Below is my minimal working code and some comments:

` l1 = 0.81; Z = 1500; x0 = 10; v0 = 0.02; \[Epsilon] = $ MachineEpsilon; l0 = 0.0714`20.; ps = ParametricNDSolveValue[{y''[r] + 2 y'[r]/r == -4 \[Pi] l k Exp[-y[r]], y[\[Epsilon]] == y0, y'[\[Epsilon]] == 0, WhenEvent[r == 1, y'[r] -> y'[r] + Z l]}, {y, y'}, {r, \[Epsilon], R}, {k, l}, Method -> {"StiffnessSwitching"}, AccuracyGoal -> 5, PrecisionGoal -> 4, WorkingPrecision -> 15]; file = OpenWrite[ "file1.dat", FormatType -> TableForm]; ParallelDo[x = i x0; v = i^3 v0; R = Rationalize[v^(-1/3), 0]; l = Rationalize[l1/(i x0), 0]; nn = FindRoot[Last[ps[y0, l]][R], {y0, -1}, Evaluated -> False][[1, 2]]; Tot = 4 \[Pi] nn NIntegrate[ r^2 Exp[-First[ps[nn, l]][r]], {r, \[Epsilon], R}, PrecisionGoal -> 4]; Print[NumberForm[i*1., 5], " ", NumberForm[Tot, 5]];, {i, 292/100, 31/10, 1/100}] // Quiet // AbsoluteTiming Close[file]; `