Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- V[v_] = (-1 + (1/8 (-9 + Sqrt[145]) - v)^2)^2 + 3 (1/8 (-9 + Sqrt[145]) - v)^3;
- sol[rmax_, [Delta]_] := Last@Last@ Last@NDSolve[{+D[v[r], {r, 2}] + 2/r D[v[r], {r, 1}] - (D[V[v], v] /. v -> v[r]) == 0, (D[v[r], r] /. r -> SetPrecision[10^-10, 100]) == 0, v[SetPrecision[10^-10, 100]] == SetPrecision[[Delta], 100]}, v, {r, 10^-10, rmax}, WorkingPrecision -> 50, Method -> "Extrapolation"](*this function computes the static solution*)
- iTf = sol[30, 1.506400187591933106770472351]; (*this is the static solution*)
- Plot[{iTf[r]}, {r, 0, 30}, PlotRange -> All, Frame -> True]
- mol[n:_Integer|{_Integer..}, o_:"Pseudospectral"] := {"MethodOfLines",
- "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n,
- "MinPoints" -> n, "DifferenceOrder" -> o}}
- mol[tf:False|True,sf_:Automatic]:={"MethodOfLines",
- "DifferentiateBoundaryConditions"->{tf,"ScaleFactor"->sf}}
- r0 = 10^-10; rmax = 30; tmax = 40;
- iTfTime = v /. ParametricNDSolve[{-D[v[t, r], {t, 2}] + D[v[t, r], {r, 2}] + 2/r D[v[t, r], {r, 1}] - (D[V[v], v] /. v -> v[t, r]) == 0,
- v[0, r] == iTf[r],
- ((D[v[t, r], t]) /. t -> 0) == +δ 10^-2,
- (D[v[t, r], r] /. r -> r0) == 0,
- v[t, rmax] == 0}, v, {t, 0, tmax}, {r, r0, rmax}, {δ},
- Method -> Union[mol[1500, 2], mol[True, 1]]];
- iTfTimeToPlot = iTfTime[0.001]; (*This is the solution*)
- tmp = NIntegrate[r^2 (1/2 (D[iTfTimeToPlot[t, r], t])^2 + 1/2 (D[iTfTimeToPlot[t, r], r])^2 + V[iTfTimeToPlot[t, r]]) /. t -> 0, {r, 0, rmax}](*Energy at time t==0*)
- (*Output:8070.32 *)
- tmp = NIntegrate[r^2 (1/2 (D[iTfTimeToPlot[t, r], t])^2 + 1/2 (D[iTfTimeToPlot[t, r], r])^2 + V[iTfTimeToPlot[t, r]]) /. t -> 10, {r, 0, rmax}](*Energy at time t==10*)
- (*Output8093.97 *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement