def xtest4(self): """ test if get_gravity_at_point is consistent with the default, (which uses get_potential_at_point). It seems that this doesn't really make sense """ static_potential = static_potentials.Galactic_Center_Potential_Kruijssen( ) r = numpy.logspace(1, 3, 10) | units.parsec z = numpy.zeros(r.shape) | units.parsec gravity = static_potential.get_gravity_at_point(z, r, z, z) orig_gravity = static_potentials.Abstract_Potential.get_gravity_at_point( static_potential, z, r, z, z) # quick plot for testing from matplotlib import pyplot from amuse import plot as aplot aplot.plot(r, gravity[0], marker="*", color='black') aplot.plot(r, orig_gravity[0], ls=":", marker="^", color='black') aplot.plot(r, gravity[1], marker="*", color='red') aplot.plot(r, orig_gravity[1], ls=":", marker="^", color='red') aplot.plot(r, gravity[2], marker="*", color='green') aplot.plot(r, orig_gravity[2], ls=":", marker="^", color='green') pyplot.show() TODO
def test1(self): """ test enclosed mass profile of Kruijssen potential """ static_potential = static_potentials.Galactic_Center_Potential_Kruijssen( ) m_zero = static_potential.enclosed_mass(0 | units.parsec) self.assertAlmostEqual(m_zero, 0 | units.MSun) factor = 8.3 / 8.5 m_on_bin = static_potential.enclosed_mass(7.489 | units.parsec * factor) self.assertAlmostEqual(m_on_bin, factor**2 * 17170000. | units.MSun) m_in_bin = static_potential.enclosed_mass(200 | units.parsec) self.assertAlmostEqual(m_in_bin, 1.644965507 | 1E9 * units.MSun) # test array r = numpy.logspace(1, 3, 500) | units.parsec m = static_potential.enclosed_mass(r) self.assertAlmostEqual(m[10], 2.0680055041 | 1E7 * units.MSun) # test 2D array x = numpy.logspace(1, 3, 500) | units.parsec matrix, m = quantities.meshgrid(x, x) mm = static_potential.enclosed_mass(matrix) self.assertAlmostEqual(mm[20, 20], 2.223803269 | 1E7 * units.MSun)
def test3(self): """ Test get_gravity_at_point """ static_potential = static_potentials.Galactic_Center_Potential_Kruijssen() points = [[1,0,0], [0,10,0], [1e3,0,1e2], ] | units.parsec grav = static_potential.get_gravity_at_point(0, *points.transpose()).transpose() print(grav) self.assertAlmostEqual(grav[0], [-5.6003771, 0, 0]|1e-7*units.m/units.s**2, 6) self.assertAlmostEqual(grav[1], [0, -2.6887222, 0]|1e-8*units.m/units.s**2, 6) self.assertAlmostEqual(grav[2], [-4.7661597, 0, -1.200846]|1e-10*units.m/units.s**2, 6)
def test2(self): """ Test get_potential_at_point """ static_potential = static_potentials.Galactic_Center_Potential_Kruijssen() points = [[1,0,0], [0,10,0], [1e3,0,1e2], ] | units.parsec potentials = static_potential.get_potential_at_point(0, *points.transpose()) # print potentials.in_(units.kms**2) self.assertAlmostEqual(potentials[0], -17280.958078|units.kms**2, 6) self.assertAlmostEqual(potentials[1], -8296.5300805|units.kms**2, 6) self.assertAlmostEqual(potentials[2], -14965.2205261|units.kms**2, 6)
def setup_system(): """ Galacitic center potential and Arches cluster position from Kruijssen 2014 """ potential = static_potentials.Galactic_Center_Potential_Kruijssen() cluster = Particle() # At time 2.05 in KDL15 cluster.position = [-17.55767, -53.26560, -9.39921] | units.parsec cluster.velocity = [-187.68008, 80.45276, 33.96556] | units.kms cluster.position += coordinate_correction return potential, cluster