I have written below a code that using a Do loop-loop. In the loop I am changing the value of x, v,l,x, v, l
and RR
, and looking forat the numbercomputed value of the tottot
, itwhich should equal Z which is 500 andZ
. It does not matter what is the values of x, v,l,x, v, l
or RR
are, ittot
should equal ZZ
. However, the loop gives me a different value of tottot
. AnyCan anyone help, please?
l1 = 0.81
Z = 500;
x0 = 10;
v0 = 0.02;
\[Epsilon]ϵ = $MachineEpsilon ;
$MachineEpsilon;
l0 = 0.0714`20.;
ps = ParametricNDSolveValue[{y''[r]
+ ParametricNDSolveValue[
{y''[r] + 2 y'[r]/r == -4 \[Pi]π l k Exp[-y[r]], y[\[Epsilon]]
== y0,
y[ϵ] == y'[\[Epsilon]]y0, y'[ϵ] == 0,
WhenEvent[r == 1, y'[r] -> y'[r] + Z l]}, {y,
{y, y'}, {r, \[Epsilon]ϵ, R}, {k},
Method -> "StiffnessSwitching",
WorkingPrecision -> 30];
Do[
x = i x0;
v = i^3 v0;
R = Rationalize[v^(-1/3), 0];
l = Rationalize[l1/(i x0), 0];
nn = FindRoot[Last[ps[y0]][R], {y0, -10, 0}, Evaluated -> False][[1,
2]];
Tot tot = 4 \[Pi]π nn NIntegrate[r^2 Exp[-First[ps[nn]][r]], {r, 0, R}];
Print[NumberForm[i, 5], " ", NumberForm[TotNumberForm[tot, 10]];,
{i, 2.92, 3.1, 0.01} ]