Solving Poisson equation for galaxy rotation curves Can someone point me to the numerical methods to solve the Poisson equation for the galaxy rotation curves?
I've heard of some tools like PETSc or OpenFOAM. But I'm not sure if these are the right tools for calculating galaxy rotation curves.
Calculation of velocity as $v^2(R) = \frac{ G}{R}M(R)$, where $M(R)$ is the galactic mass till radius $R$, seems too simplified with the assumption of mass distribution having spatial symmetry. So, I'm looking for numerical solution of the Poisson equation, for more accurate results.
Also, I believe, one needs to solve the galaxy rotation curve n 3D to get reasonable results. 2D solutions may be misleading, even though the galaxy is mostly a disc. I'm thinking this because the gravitational field would be in 3D, and restricting the gravitational field to 2D may be erroneous.
 A: When solving the Poisson equation numerically, you can use any programming language that allows for multi-dimensional arrays (C/C++, Fortran, Rust, Python, ....). While I imagine OpenFOAM and PETSc can be used, they are not required.*
You have a relatively simple PDE that you can apply discretization to use in a numerical model. In this way, your PDE would appear as, assuming an axisymmetric model,
$$\nabla^2\Phi=f(r,\,z)\Rightarrow\frac{1}{r_i}\left(r_{i+1/2}\frac{\Phi_{i+1,j}-\Phi_{i,j}}{dr^2}-r_{i-1/2}\frac{\Phi_{i,j}-\Phi_{i-1,j}}{dr^2}\right)+\frac{\Phi_{i,j+1}+\Phi_{i,j-1}-2\Phi_{ij}}{dz^2}=f(r_i,\,z_j)$$
which would require a 2D array for $\Phi$ and some tricks for handling $r\simeq0$. If you solve the above equation for $\Phi_{i,j}$ you can use that equation in relaxation techniques (or any of the "See also" links in this Wikipedia entry) to find the potential to the given density profile.
Once you have that solution, you can use the same discretization to determine the velocity profile,
$$v(r_i)^2\simeq r_i\frac{\Phi_{i+1,j}-\Phi_{i-1,j}}{2\cdot dr}.$$
where the $j$ index on $\Phi$ would either be used to average over all heights or for a single slice.


* My proverbial \$0.02 would be to not use those modules as knowing how to numerically solve PDEs and ODEs is a good tool to have in your possession.
