Yukterez

n Body Disk Solver

May 17th, 2020
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| *)
  2. (* | Mathematica Syntax | yukterez.net | n-Body calculator for disks with height | Version 1 | *)
  3. (* ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| *)
  4.  
  5. G = 1; (* Gravitationskonstante *)
  6. d = 0.002; (* Abstand der Scheibenpartikel zueinander *)
  7. n = Floor[2π/d]; (* Abstandsgleichheit *)
  8. я1 = d; (* Scheibeninnenradius *)
  9. я2 = 1; (* Scheibenaußenradius *)
  10. h = 0.022; (* Scheibenhöhe *)
  11.  
  12. fx[x_, y_, z_] :=
  13. Flatten[Table[Table[Table[(G M (r Sin[φ]-x))/Sqrt[((r Sin[φ]-x)^2+(r Cos[φ]-y)^2+(Z-z)^2)^3],
  14. {φ, 0, 2π-2π/r/n, 2π/r/n}], {r, я1, я2, d}], {Z, -h/2, h/2, d}]]
  15. gx[x_, y_, z_] := Total[-fx[x, y, z]] (* Fallbeschleunigung entlang x *)
  16.  
  17. fy[x_, y_, z_] :=
  18. Flatten[Table[Table[Table[(G M (r Cos[φ]-y))/Sqrt[((r Sin[φ]-x)^2+(r Cos[φ]-y)^2+(Z-z)^2)^3],
  19. {φ, 0, 2π-2π/r/n, 2π/r/n}], {r, я1, я2, d}], {Z, -h/2, h/2, d}]]
  20. gy[x_, y_, z_] := Total[-fy[x, y, z]] (* Fallbeschleunigung entlang y *)
  21.  
  22. fz[x_, y_, z_] :=
  23. Flatten[Table[Table[Table[(G M (Z-z))/Sqrt[((r Sin[φ]-x)^2+(r Cos[φ]-y)^2+(Z-z)^2)^3],
  24. {φ, 0, 2π-2π/r/n, 2π/r/n}], {r, я1, я2, d}], {Z, -h/2, h/2, d}]]
  25. gz[x_, y_, z_] := Total[-fz[x, y, z]] (* Fallbeschleunigung entlang z *)
  26.  
  27. l = Length[fx[0, 0, 0]] (* Anzahl der Partikel aus denen die Scheibe besteht *)
  28. M = 1/l; (* Masse der einzelnen Partikel *)
  29.  
  30. gχ = Interpolation[ParallelTable[{x, gx[x, 0, 0]}, {x, 0.01, 2, 0.01}]]
  31.  
  32. Plot[gχ[x], {x, 0, 2}, Frame->True, ImageSize->640, PlotRange->{{0, 2}, {0, 3.5}},
  33. AspectRatio->1/3, ImagePadding->{{25, 1}, {15, 5}}, GridLines->{{1}, {1}}]
RAW Paste Data