Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. V[v_] = (-1 + (1/8 (-9 + Sqrt[145]) - v)^2)^2 + 3 (1/8 (-9 + Sqrt[145]) - v)^3;
  2.  
  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*)
  4.  
  5. iTf = sol[30, 1.506400187591933106770472351]; (*this is the static solution*)
  6. Plot[{iTf[r]}, {r, 0, 30}, PlotRange -> All, Frame -> True]
  7.  
  8. mol[n:_Integer|{_Integer..}, o_:"Pseudospectral"] := {"MethodOfLines",
  9. "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n,
  10. "MinPoints" -> n, "DifferenceOrder" -> o}}
  11. mol[tf:False|True,sf_:Automatic]:={"MethodOfLines",
  12. "DifferentiateBoundaryConditions"->{tf,"ScaleFactor"->sf}}
  13.  
  14. r0 = 10^-10; rmax = 30; tmax = 40;
  15.  
  16. 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,
  17. v[0, r] == iTf[r],
  18. ((D[v[t, r], t]) /. t -> 0) == +δ 10^-2,
  19. (D[v[t, r], r] /. r -> r0) == 0,
  20. v[t, rmax] == 0}, v, {t, 0, tmax}, {r, r0, rmax}, {δ},
  21. Method -> Union[mol[1500, 2], mol[True, 1]]];
  22.  
  23. iTfTimeToPlot = iTfTime[0.001]; (*This is the solution*)
  24.  
  25. 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*)
  26. (*Output:8070.32 *)
  27.  
  28. 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*)
  29.  
  30. (*Output8093.97 *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement