Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. NDSolve::ndnum: Encountered non-numerical value for a derivative at t==0.
  2.  
  3. σ = 1
  4. rc = -4
  5. λ = 1
  6. sink[r_, λ_] = (3 λ)/(4 π r^6)
  7. U[r_] = rc/r
  8. g[r_] = Exp[-U[r]]
  9. Dif = 1
  10. h[r_] = 1
  11. r0 = 1;
  12. tmax = 0.01;
  13. rmax = 1000 Sqrt[6 Dif tmax] + r0;
  14.  
  15. sol = NDSolve[{D[ρ[r, t], {t, 1}] ==
  16. Dif r^-2 D[
  17. r^2 h[r] Exp[-U[r]] D[Exp[U[r]] ρ[r, t], {r, 1}], {r,
  18. 1}] - (λ/g[σ] DiracDelta[r - σ]/(
  19. 4 π σ^2) + sink[r, λ]) ρ[r,
  20. t], ρ[r, 0] == Exp[-(U[r] - rc/rmax)], ρ[rmax, t] ==
  21. 1, 4 π Dif h[σ] (
  22. D[Exp[U[r]] ρ[r, t], {r, 1}] /.
  23. r -> σ) == λ Exp[U[σ]] ρ[σ,
  24. t]}, ρ, {r, σ, rmax}, {t, 0, tmax},
  25. PrecisionGoal -> 4, StartingStepSize -> 0.0001,
  26. Method -> {"MethodOfLines",
  27. "SpatialDiscretization" -> {"TensorProductGrid",
  28. "MinPoints" -> 100, "MaxPoints" -> 200}}]
  29.  
  30. ρn = First[ρ /. sol]
  31. Plot3D[ρn[r, t], {r, σ, rmax/100}, {t, 0, tmax}, PlotRange -> All]
  32.  
  33. appro = With[{k = 1}, Erf[k #]/2 + 1/2 &];
  34.  
  35. Plot[appro'[x - σ], {x, -σ, rmax}, PlotRange -> All, Axes -> None]
  36.  
  37. σ = 1;
  38. rc = -4;
  39. λ = 1;
  40. sink[r_, λ_] = (3 λ)/(4 π r^6);
  41. U[r_] = rc/r;
  42. g[r_] = Exp[-U[r]];
  43. Dif = 1;
  44. h[r_] = 1;
  45. r0 = 1;
  46. tmax = 0.01;
  47. rmax = 1000 Sqrt[6 Dif tmax] + r0;
  48.  
  49. mol[n_Integer, o_:"Pseudospectral"] := {"MethodOfLines",
  50. "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n,
  51. "MinPoints" -> n, "DifferenceOrder" -> o}}
  52.  
  53. mol[tf:False|True,sf_:Automatic]:={"MethodOfLines",
  54. "DifferentiateBoundaryConditions"->{tf,"ScaleFactor"->sf}}
  55.  
  56. sol = With[{coef = 10^6},
  57. NDSolve[{D[ρ[r, t], {t, 1}] ==
  58. Dif r^-2 D[
  59. r^2 h[r] Exp[-U[r]] D[Exp[U[r]] ρ[r, t], {r, 1}], {r,
  60. 1}] - (λ/
  61. g[σ] coef DiracDelta[r - σ]/(4 π σ^2) +
  62. sink[r, λ]) ρ[r, t], ρ[r, 0] ==
  63. Exp[-(U[r] - rc/rmax)], ρ[rmax, t] == 1,
  64. 4 π Dif h[σ] (D[Exp[U[r]] ρ[r, t], {r, 1}] /.
  65. r -> σ) == λ Exp[U[σ]] ρ[σ, t]} /.
  66. DiracDelta -> appro', ρ, {r, σ, rmax}, {t, 0, tmax},
  67. Method -> Union[mol[True, 100], mol[4000, 4]]]];
  68.  
  69. ρn = First[ρ /. sol];
  70. Plot3D[ρn[r, t], {r, σ, rmax/100}, {t, 0, tmax}, PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement