def test_default_lmech(self): star_particles = self.create_star(1) stars = stellar_wind.StarsWithMassLoss() stars.track_mechanical_energy() star = stars.add_particle(star_particles[0]) self.assertEquals(star.mechanical_energy, 0 | units.J)
def test_add_wrong_attribute(self): star_particles = self.create_star(2) star_particles stars = stellar_wind.StarsWithMassLoss() stars.add_particles(star_particles) self.assertRaises(AttributeError, stars.__setattr__, "other_attr", 10)
def test_superfluous_attributes(self): star_particles = self.create_star(2) star_particles.other_attr = 10 | units.yr stars = stellar_wind.StarsWithMassLoss() stars.add_particles(star_particles) self.assertRaises(AttributeError, stars.__getattr__, "other_attr")
def test_add_particle_later(self): star_particles = self.create_star(2) stars = stellar_wind.StarsWithMassLoss() stars.add_particle(star_particles[0]) stars.evolve_mass_loss(1 | units.yr) new_star = stars.add_particle(star_particles[1]) self.assertAlmostEquals(new_star.wind_release_time, 1 | units.yr)
def test_add_particles(self): star_particles = self.create_star(2) print "created parts" stars = stellar_wind.StarsWithMassLoss() print "created stars" stars.add_particles(star_particles) print "added", stars self.assertEquals(stars.lost_mass, [0, 0] | units.MSun) self.assertEquals(stars.wind_release_time, [0, 0] | units.yr) self.assertAlmostEquals(stars.mu[0], 1.145934546 | units.amu)
def test_add_particle(self): star_particles = self.create_star(1) stars = stellar_wind.StarsWithMassLoss() star = stars.add_particle(star_particles[0]) self.assertEquals(star.lost_mass, 0 | units.MSun) self.assertEquals(star.wind_release_time, 0 | units.yr) self.assertAlmostEquals(star.mu, 1.145934546 | units.amu) attrs = stars.get_attribute_names_defined_in_store() self.assertFalse("mechanical_energy" in attrs) self.assertFalse("previous_mechanical_luminosity" in attrs)