Example #1
0
 def create_star(self):
     star = Particle()
     star.radius = 2 | units.RSun
     star.acc_cutoff = 10 | units.RSun
     star.initial_wind_velocity = 4 | units.kms
     star.terminal_wind_velocity = 12 | units.kms
     return star
Example #2
0
    def test_radius_from_time(self):
        self.skip_no_scipy()

        func = stellar_wind.RSquaredAcceleration()
        star = Particle()
        star.radius = 312. | units.RSun
        star.acc_cutoff = 312*5. | units.RSun
        star.initial_wind_velocity = 2 | units.kms
        star.terminal_wind_velocity = 20 | units.kms

        times = [0., 25., 100.] | units.yr
        print "times", times
        radii = func.radius_from_time(times, star)
        print "radii", radii

        self.assertAlmostEquals(radii[0], 312. | units.RSun)
        self.assertAlmostEquals(radii[1], 22644.6086263 | units.RSun)
        self.assertAlmostEquals(radii[2], 90704.1183516 | units.RSun)

        return

        times = numpy.linspace(0., 1, 100) | units.yr
        radii = func.radius_from_time(times, star)

        print radii
        from matplotlib import pyplot
        from amuse import plot as aplot
        aplot.plot(times, radii/star.radius)
        pyplot.show()
Example #3
0
    def test_radius_from_number(self):
        self.skip_no_scipy()

        star = Particle(
            initial_wind_velocity=200. | units.kms, mass=20. | units.MSun,
            radius=10. | units.RSun, terminal_wind_velocity=1000. | units.kms)
        star.acc_cutoff = 5. * star.radius
        r_max = 24.2642526438 | units.RSun
        x = 0.1

        func = stellar_wind.RSquaredAcceleration()
        radius = func.radius_from_number(x, r_max, star)
        self.assertAlmostEquals(radius,  10.6029030808 | units.RSun)
Example #4
0
    def test_alternate_radius_function(self):
        numpy.random.seed(123)
        gen = stellar_wind.PositionGenerator()
        # func = stellar_wind.LogisticVelocityAcceleration().radius_from_number
        func = stellar_wind.ConstantVelocityAcceleration().radius_from_number

        N = 100000
        rmin = 2 | units.RSun
        rmax = 6 | units.RSun
        star = Particle()
        star.radius = rmin
        star.acc_cutoff = 10 | units.RSun
        star.initial_wind_velocity = 4 | units.kms
        star.terminal_wind_velocity = 12 | units.kms

        p, _ = gen.generate_positions(N, rmin, rmax, func, star)
        r = p.lengths()

        self.assertEquals(len(r), N)
        self.assertGreaterEqual(r.min(), rmin)
        self.assertLessEqual(r.max(), rmax)
        print r.mean()
        self.assertAlmostEquals(r.mean(), 4.00196447056 | units.RSun)

        return

        r = r.value_in(units.RSun)
        n_bins = 50
        n, bins = numpy.histogram(r, n_bins)
        bin_volume = 4./3. * numpy.pi * (bins[1:]**3 - bins[:-1]**3)
        dens = n / bin_volume
        bin_means = (bins[1:] + bins[:-1])/2.

        from matplotlib import pyplot
        pyplot.plot(bin_means, dens, '*')
        pyplot.savefig("dens.pdf")