# Gravity of a Planet with a Disk or Ring, Solver

Apr 24th, 2020
31
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. (* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| *)
2. (* ||||| Mathematica Syntax | yukterez.net | Ball, Ring, Disk g,v,Φ-Solver | Version 2 ||||||| *)
3. (* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| *)
4.
5. G = 1; (* Gravitationskonstante *)
6. M = 1; (* Masse der Scheibe *)
7. Ḿ = 0; (* Masse der zentralen Kugel *)
8.
9. я1 = 0; (* Scheibeninnenradius *)
10. я2 = 1; (* Scheibenaußenradius *)
11. я3 = 1; (* Kugelradius *)
12.
13. ρ = M/(π я2^2-π я1^2); (* Flächendichte der Scheibe *)
14. m[R_, Ḿ_] := If[я3==0, Ḿ, Ḿ R^3/я3^3]; (* innere Kugelrestmasse *)
15.
16. gř[r_, я_] := (2 Sqrt[я] G ρ (-EllipticE[(4 я r)/(я^2+2 я r+r^2)]+EllipticK[(4 я r)/(я^2+2 я r+
17. r^2)] (1-(2 я r)/(я^2+2 я r+r^2))))/(Sqrt[r] Sqrt[(я r)/(я^2+2 я r+r^2)]); (* g(r) der Scheibe *)
18. gž[z_, я_] := 2 G ρ(π-(π/2 (-я+z)+1/2 π (я+z))/Sqrt[я^2+z^2]); (* g(z) der Scheibe *)
19.
20. gk[R_, Ḿ_] := G Min[m[R, Ḿ], Ḿ]/R^2; (* g(R) der Kugel *)
21.
22. gr[r_, я1_, я2_] := gř[r, я2]-If[я1==0, 0, gř[r, я1]]+gk[r, Ḿ]; (* g(r) total *)
23. gz[z_, я1_, я2_] := gž[z, я2]-If[я1==0, 0, gž[z, я1]]+gk[z, Ḿ]; (* g(z) total *)
24.
25. U[r_, z_, я_] := 2 G ρ (-Sqrt[я^2+r^2+2 я r+z^2] EllipticE[(4 я r)/(я^2+r^2+
26. 2 я r+z^2)]+((-я^2+r^2) EllipticK[(4 я r)/(я^2+r^2+2 я r+z^2)])/Sqrt[я^2+
27. r^2+2 я r+z^2]+((-я+r) z^2 EllipticPi[(4 я r)/(я+
28. r)^2, (4 я r)/(я^2+r^2+2 я r+z^2)])/((я+r) Sqrt[я^2+r^2+
29. 2 я r+z^2])+1/2 π z (1+Sign[я-r]));
30. V[r_, z_, я1_, я2_] := U[r, z, я2]-If[я1==0, 0, U[r, z, я1]]; (* Potential der Scheibe *)
31. W[R_, Ḿ_] := Integrate[-G Min[m[j, Ḿ], Ḿ]/j^2, {j, R, Infinity}]; (* Potential der Kugel *)
32.
33. Plot[{gk[R, M], gr[R, я1, я2], gz[R, я1, я2]}, {R, 0, 2 я2}, (* Plot g *)
34. GridLines->{{я1, я2, я3}, {1}}, Frame->True, ImageSize->640, AspectRatio->1/3,
35. PlotStyle->{Gray, Cyan, Magenta}, PlotRange->{All, All}]
36.
37. Plot[{Sqrt[gk[R, M] R], Sqrt[gr[R, я1, я2]R], Sqrt[gz[R, я1, я2]R]}, {R, 0, 2 я2}, (* Plot v *)
38. GridLines->{{я1, я2, я3}, {1}}, Frame->True, ImageSize->640, AspectRatio->1/3,
39. PlotStyle->{Gray, Cyan, Magenta}, PlotRange->{All, All}]
40.
41. Plot[{-W[R, M], -V[R, 0, я1, я2], -V[0, R, я1, я2]}, {R, 0, 2 я2}, (* Plot Φ *)
42. GridLines->{{я1, я2, я3}, {1}}, Frame->True, ImageSize->640, AspectRatio->1/3,
43. PlotStyle->{Gray, Cyan, Magenta}, PlotRange->{All, All}]
RAW Paste Data