{"action":"closed","issue":{"url":"https://api.github.com/repos/pynbody/pynbody/issues/270","labels_url":"https://api.github.com/repos/pynbody/pynbody/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/pynbody/pynbody/issues/270/comments","events_url":"https://api.github.com/repos/pynbody/pynbody/issues/270/events","html_url":"https://github.com/pynbody/pynbody/issues/270","id":100540305,"number":270,"title":"Midplane gravity gives inaccurate results in galaxy center","user":{"login":"jakobherpich","id":5030846,"avatar_url":"https://avatars.githubusercontent.com/u/5030846?v=3","gravatar_id":"","url":"https://api.github.com/users/jakobherpich","html_url":"https://github.com/jakobherpich","followers_url":"https://api.github.com/users/jakobherpich/followers","following_url":"https://api.github.com/users/jakobherpich/following{/other_user}","gists_url":"https://api.github.com/users/jakobherpich/gists{/gist_id}","starred_url":"https://api.github.com/users/jakobherpich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakobherpich/subscriptions","organizations_url":"https://api.github.com/users/jakobherpich/orgs","repos_url":"https://api.github.com/users/jakobherpich/repos","events_url":"https://api.github.com/users/jakobherpich/events{/privacy}","received_events_url":"https://api.github.com/users/jakobherpich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pynbody/pynbody/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/pynbody/pynbody/labels/wontfix","name":"wontfix","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-12T13:14:39Z","updated_at":"2015-08-18T15:05:16Z","closed_at":"2015-08-18T15:05:16Z","body":"In the following plot I overplotted the potential (`phi` array) of all particles with |z|<0.1 kpc as a function of radius (black points), a spherically averaged profile of the `phi` array (`prof['phi']`) from the simulation (red line) and the potential from midplane gravity (`prof['pot']`). There is a discrepancy between the midplane gravity method with the spherical mean and the actual data in the plane inside ~ 1 kpc. The gravitational softening is 227 pc.\r\n\r\nWhy is the midplane gravity calculation not able to reproduce the potential in the inner region? Even a spherically averaged profile is more accurate. Since the gravity calculation uses the softening from the simulation I would assume that it returns the same potential as the simulation software.\r\n\r\n![prof_phi_test](https://cloud.githubusercontent.com/assets/5030846/9224525/512f1b02-4103-11e5-88c7-173c51ca4e2a.png)\r\n\r\nHere is the code:\r\n```\r\nIn [2]: sim = pynbody.load('halo.000818')\r\n\r\nIn [3]: trans = pynbody.analysis.angmom.faceon(sim.s, vcen=0)\r\n\r\nIn [4]: plt.figure(figsize=(5, 3.6))\r\nOut[4]: <matplotlib.figure.Figure at 0x44e1e90>\r\n\r\nIn [5]: prof = pynbody.analysis.profile.Profile(sim, nbins=1000, type='log', ndim=3)\r\n\r\nIn [6]: plane = sim[np.where(np.abs(sim['z'])<.1)]\r\n\r\nIn [7]: plt.plot(plane['rxy'], plane['phi'].in_units(prof['pot'].units), 'k.')\r\npynbody.analysis.profile : Profile pot -- this routine assumes the disk is in the x-y plane\r\nOut[7]: [<matplotlib.lines.Line2D at 0x45f1990>]\r\n\r\nIn [8]: plt.semilogx(prof['rbins'], prof['phi'], 'r-')\r\n/home/herpich/python/pynbody/analysis/profile.py:418: RuntimeWarning: invalid value encountered in double_scalars\r\n  result[i] = (name_array * mass_array).sum() / self['mass'][i]\r\nOut[8]: [<matplotlib.lines.Line2D at 0x4608150>]\r\n\r\nIn [9]: plt.semilogx(prof['rbins'], prof['pot'], 'g-')\r\nOut[9]: [<matplotlib.lines.Line2D at 0x461ae50>]\r\n```"}}