Ejemplo n.º 1
0
    def test3(self):
        numpy.random.seed(345672)
        instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35)
        n = 10000
        total_mass, set_of_masses = instance.next_set(n)

        self.assertAlmostEqual(instance.mass_mean(), 0.35136877959 | units.MSun)
        self.assertAlmostEqual(total_mass / n, 0.35136877959 | units.MSun, 1)
        self.assertAlmostEqual(total_mass / n, 0.33999456911 | units.MSun)
        self.assertAlmostEqual(instance.mass(0.5), set_of_masses.median(), 2)
Ejemplo n.º 2
0
 def test3(self):
     numpy.random.seed(345672)
     instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha = -2.35)
     n = 10000
     total_mass, set_of_masses = instance.next_set(n)
     
     self.assertAlmostEqual(instance.mass_mean(), 0.35136877959 | units.MSun)
     self.assertAlmostEqual(total_mass / n,       0.35136877959 | units.MSun, 1)
     self.assertAlmostEqual(total_mass / n,       0.33999456911 | units.MSun)
     self.assertAlmostEqual(instance.mass(0.5),   set_of_masses.median(), 2)
Ejemplo n.º 3
0
 def test5(self):
     print("Test 5: testing user interface (SI units)")
     numpy.random.seed(345672)
     masses = new_salpeter_mass_distribution(1000)
     
     self.assertEqual(len(masses), 1000)
     self.assertAlmostEqual(masses.mean(), 0.334475937397 | units.MSun)
     self.assertAlmostRelativeEqual(masses.mean(), SalpeterIMF().mass_mean(), 1)
     self.assertAlmostEqual(masses.amin(), 0.10017909529 | units.MSun)
     self.assertAlmostEqual(masses.amax(), 19.7132849297 | units.MSun)
Ejemplo n.º 4
0
 def test4(self):
     instance = SalpeterIMF(0.1 | units.MSun, 125 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass_mean(),
                            0.353943475903 | units.MSun)
Ejemplo n.º 5
0
 def test2(self):
     instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass(1.0), 100 | units.MSun)
     self.assertAlmostEqual(instance.mass(0.0), 0.1 | units.MSun)
Ejemplo n.º 6
0
 def test1(self):
     instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass_mean().value_in(units.MSun),
                            0.351, 3)
Ejemplo n.º 7
0
 def test4(self):
     instance = SalpeterIMF(0.1 | units.MSun, 125 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass_mean(), 0.353943475903 | units.MSun)
Ejemplo n.º 8
0
 def test2(self):
     instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass(1.0), 100 | units.MSun)
     self.assertAlmostEqual(instance.mass(0.0), 0.1 | units.MSun)
Ejemplo n.º 9
0
 def test1(self):
     instance = SalpeterIMF(0.1 | units.MSun, 100 | units.MSun, alpha=-2.35)
     self.assertAlmostEqual(instance.mass_mean().value_in(units.MSun), 0.351, 3)