Skip to content

Instantly share code, notes, and snippets.

@rsnemmen
Created November 19, 2014 19:02
Show Gist options
  • Save rsnemmen/b5e20558c84ce13b73b5 to your computer and use it in GitHub Desktop.
Save rsnemmen/b5e20558c84ce13b73b5 to your computer and use it in GitHub Desktop.
Simplified galaxy rotation curves with and without dark matter and their visual impact, Mathematica
Galaxy rotation curves in Mathematica
Author: Rodrigo Nemmen
Visually illustrating the impact of the presence of dark matter in speeding up the
rotation of test particles in galaxies
Input
nϕ=15;
rmin=1;rmax=50; nr=40;
tmin=0; tmax=15Pi;
Rotation curves
Only visible matter
Mvis=Piecewise[{{r^2,r<5},{25,r>5}}];
vvis=Sqrt[Mvis/r];
ωvis=vvis/r;
Dark matter
Mdm=Piecewise[{{r^2,r<5},{5*r,r>5}}];
vdm=Sqrt[Mdm/r];
ωdm=vdm/r;
Rigid body
vrigid=2*(r/50);
ωrigid=vrigid/r;
Plots: rotation curves
Plot[vrigid,{r,0,rmax},AxesStyle->Black,PlotStyle->Green]
Plot[{vdm,vvis,vrigid},{r,0,rmax},AxesStyle->Black]
Animation: rigid body
Animate[ListLinePlot[
ParallelTable[{r Cos[\[Omega]rigid*t + \[Phi]],
r Sin[\[Omega]rigid*t + \[Phi]]}, {\[Phi], 0, 2 Pi,
2 Pi/n\[Phi]}, {r, rmin, rmax, rmax/nr}],
PlotRange -> {{-rmax, rmax}, {-rmax, rmax}}, AspectRatio -> 1],
{t, tmin, tmax}, DefaultDuration -> 40, AnimationRunning -> False]
Animation: galaxies with and without dark matter
Animate[Magnify[
GraphicsGrid[{{
ListLinePlot[
ParallelTable[{r Cos[\[Omega]vis*t + \[Phi]],
r Sin[\[Omega]vis*t + \[Phi]]}, {\[Phi], 0, 2 Pi,
2 Pi/n\[Phi]}, {r, rmin, rmax, rmax/nr}],
PlotRange -> {{-rmax, rmax}, {-rmax, rmax}}, AspectRatio -> 1],
ListLinePlot[
ParallelTable[{r Cos[\[Omega]dm*t + \[Phi]],
r Sin[\[Omega]dm*t + \[Phi]]}, {\[Phi], 0, 2 Pi,
2 Pi/n\[Phi]}, {r, rmin, rmax, rmax/nr}],
PlotRange -> {{-rmax, rmax}, {-rmax, rmax}}, AspectRatio -> 1]
}}]
],
{t, tmin, tmax}, DefaultDuration -> 40, AnimationRunning -> False]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment