def test4(self): mosse = MOSSEInterface() self.initialize_module_with_default_parameters(mosse) types = [1 for x in range(1,4000)] masses = [1.0 + ((x / 4000.0) * 10.0) for x in range(1,4000)] radii = [1.0 for x in range(1,4000)] luminosity = core_mass = core_radius = envelope_mass =\ envelope_radius = spin = epoch =\ t_ms = [0.0 for x in range(1,4000)] sse_age = age = [1e-06 for x in range(1,4000)] result = mosse.evolve_star( types, masses, masses, radii, luminosity, core_mass, core_radius, envelope_mass, envelope_radius, spin, epoch, t_ms, sse_age, age ) self.assertEqual(len(result['mass']), 3999) mosse.stop()
def test1(self): mosse = MOSSEInterface() metallicity = 0.02 neta = 0.5 bwind = 0.0 hewind = 1.0 sigma1 = 265.0 sigma2 = 7.0 ifflag = 0 wdflag = 1 bhflag = 1 nsflag = 3 piflag = 1 mxns = 3.0 idum = 29769 pts1 = 0.05 pts2 = 0.01 pts3 = 0.02 status = mosse.initialize(metallicity, neta, bwind, hewind, sigma1, sigma2, ifflag, wdflag, bhflag, nsflag, piflag, mxns, idum, pts1, pts2, pts3) self.assertEqual(status,0) mosse.stop()
def test3(self): mosse = MOSSEInterface() self.initialize_module_with_default_parameters(mosse) types = [1,1,1] masses = [10,5,4] radii = [5.0, 2.0, 1.0] luminosity = core_mass = core_radius = envelope_mass =\ envelope_radius = spin = epoch = t_ms = [0.0,0.0,0.0] sse_age = age = [1e-6, 1e-06, 1e-6] result = mosse.evolve_star( types, masses, masses, radii, luminosity, core_mass, core_radius, envelope_mass, envelope_radius, spin, epoch, t_ms, sse_age, age ) self.assertEqual(result['mass'][0], 10) self.assertEqual(result['mass'][1], 5) self.assertAlmostEqual(result['mass'][2], 4.0, 2) mosse.stop()
def test1(self): mosse = MOSSEInterface() metallicity = 0.02 neta = 0.5 bwind = 0.0 hewind = 1.0 sigma1 = 265.0 sigma2 = 7.0 ifflag = 0 wdflag = 1 bhflag = 1 nsflag = 3 piflag = 1 mxns = 3.0 idum = 29769 pts1 = 0.05 pts2 = 0.01 pts3 = 0.02 status = mosse.initialize(metallicity, neta, bwind, hewind, sigma1, sigma2, ifflag, wdflag, bhflag, nsflag, piflag, mxns, idum, pts1, pts2, pts3) self.assertEqual(status,0) mosse.stop()
def test4(self): mosse = MOSSEInterface() self.initialize_module_with_default_parameters(mosse) types = [1 for x in range(1,4000)] masses = [1.0 + ((x / 4000.0) * 10.0) for x in range(1,4000)] radii = [1.0 for x in range(1,4000)] luminosity = core_mass = core_radius = envelope_mass =\ envelope_radius = spin = epoch =\ t_ms = [0.0 for x in range(1,4000)] sse_age = age = [1e-06 for x in range(1,4000)] result = mosse.evolve_star( types, masses, masses, radii, luminosity, core_mass, core_radius, envelope_mass, envelope_radius, spin, epoch, t_ms, sse_age, age ) self.assertEquals(len(result['mass']), 3999) mosse.stop()
def test3(self): mosse = MOSSEInterface() self.initialize_module_with_default_parameters(mosse) types = [1,1,1] masses = [10,5,4] radii = [5.0, 2.0, 1.0] luminosity = core_mass = core_radius = envelope_mass =\ envelope_radius = spin = epoch = t_ms = [0.0,0.0,0.0] sse_age = age = [1e-6, 1e-06, 1e-6] result = mosse.evolve_star( types, masses, masses, radii, luminosity, core_mass, core_radius, envelope_mass, envelope_radius, spin, epoch, t_ms, sse_age, age ) self.assertEquals(result['mass'][0], 10) self.assertEquals(result['mass'][1], 5) self.assertAlmostEqual(result['mass'][2], 4.0, 2) mosse.stop()
def test2(self): mosse = MOSSEInterface() metallicity = 0.02 neta = 0.5 bwind = 0.0 hewind = 1.0 sigma1 = 265.0 sigma2 = 7.0 ifflag = 0 wdflag = 1 bhflag = 1 nsflag = 3 piflag = 1 mxns = 3.0 idum = 29769 pts1 = 0.05 pts2 = 0.01 pts3 = 0.02 status = mosse.initialize(metallicity, neta, bwind, hewind, sigma1, sigma2, ifflag, wdflag, bhflag, nsflag, piflag, mxns, idum, pts1, pts2, pts3) self.assertEqual(status,0) new_state = self.state() new_state.mass = 1.0 new_state.zams_mass = 1.0 new_state.stellar_type = 1.0 new_state.age = 1e-06 result = mosse.evolve_star( new_state.stellar_type, new_state.zams_mass, new_state.mass, new_state.radius, new_state.luminosity, new_state.core_mass, new_state.core_radius, new_state.envelope_mass, new_state.envelope_radius, new_state.spin, new_state.epoch, new_state.t_ms, new_state.sse_age, new_state.age ) updated_state = self.state() (updated_state.stellar_type,updated_state.zams_mass, updated_state.mass, updated_state.radius, updated_state.luminosity, updated_state.core_mass, updated_state.core_radius, updated_state.envelope_mass, updated_state.envelope_radius, updated_state.spin, updated_state.epoch, updated_state.t_ms, updated_state.sse_age, updated_state.age) = result attributes = ('stellar_type', 'zams_mass', 'mass', 'radius', 'luminosity', 'core_mass', 'core_radius', 'envelope_mass', 'envelope_radius', 'spin', 'epoch', 't_ms', 'sse_age', 'age') expected = { 'zams_mass': '0x1.0000000000000p+0', 'mass': '0x1.0000000000000p+0', 'radius': '0x1.c6c8a1c793bcep-1', 'luminosity': '0x1.653b1b2d0333bp-1', 'core_mass': '0x0.0p+0', 'core_radius': '0x0.0p+0', 'envelope_mass': '0x1.0d6fc100ab510p-5', 'envelope_radius': '0x1.db27631ba0e5ap-3', 'spin': '0x1.07413b0522d63p+10', 'epoch': '0x0.0p+0', 't_ms': '0x1.57d90abe54643p+13', 'sse_age': '0x1.0c6f7a0b5ed8dp-20', 'age': '0x1.0c6f7a0b5ed8dp-20', }; for x in expected: self.assertAlmostRelativeEqual(float.fromhex(expected[x]),getattr(updated_state, x)) self.assertEqual(updated_state.age, 1e-06) dt = mosse.get_time_step(updated_state.stellar_type, updated_state.zams_mass, updated_state.age, updated_state.mass, updated_state.t_ms, updated_state.epoch) self.assertAlmostEqual(dt, 550.1565, 2) mosse.stop()
def test2(self): mosse = MOSSEInterface() metallicity = 0.02 neta = 0.5 bwind = 0.0 hewind = 1.0 sigma1 = 265.0 sigma2 = 7.0 ifflag = 0 wdflag = 1 bhflag = 1 nsflag = 3 piflag = 1 mxns = 3.0 idum = 29769 pts1 = 0.05 pts2 = 0.01 pts3 = 0.02 status = mosse.initialize(metallicity, neta, bwind, hewind, sigma1, sigma2, ifflag, wdflag, bhflag, nsflag, piflag, mxns, idum, pts1, pts2, pts3) self.assertEqual(status,0) new_state = self.state() new_state.mass = 1.0 new_state.zams_mass = 1.0 new_state.stellar_type = 1.0 new_state.age = 1e-06 result = mosse.evolve_star( new_state.stellar_type, new_state.zams_mass, new_state.mass, new_state.radius, new_state.luminosity, new_state.core_mass, new_state.core_radius, new_state.envelope_mass, new_state.envelope_radius, new_state.spin, new_state.epoch, new_state.t_ms, new_state.sse_age, new_state.age ) updated_state = self.state() (updated_state.stellar_type,updated_state.zams_mass, updated_state.mass, updated_state.radius, updated_state.luminosity, updated_state.core_mass, updated_state.core_radius, updated_state.envelope_mass, updated_state.envelope_radius, updated_state.spin, updated_state.epoch, updated_state.t_ms, updated_state.sse_age, updated_state.age) = result attributes = ('stellar_type', 'zams_mass', 'mass', 'radius', 'luminosity', 'core_mass', 'core_radius', 'envelope_mass', 'envelope_radius', 'spin', 'epoch', 't_ms', 'sse_age', 'age') expected = { 'zams_mass': '0x1.0000000000000p+0', 'mass': '0x1.0000000000000p+0', 'radius': '0x1.c6c8a1c793bcep-1', 'luminosity': '0x1.653b1b2d0333bp-1', 'core_mass': '0x0.0p+0', 'core_radius': '0x0.0p+0', 'envelope_mass': '0x1.0d6fc100ab510p-5', 'envelope_radius': '0x1.db27631ba0e5ap-3', 'spin': '0x1.07413b0522d63p+10', 'epoch': '0x0.0p+0', 't_ms': '0x1.57d90abe54643p+13', 'sse_age': '0x1.0c6f7a0b5ed8dp-20', 'age': '0x1.0c6f7a0b5ed8dp-20', }; for x in expected: self.assertAlmostRelativeEqual(float.fromhex(expected[x]),getattr(updated_state, x)) self.assertEquals(updated_state.age, 1e-06) dt = mosse.get_time_step(updated_state.stellar_type, updated_state.zams_mass, updated_state.age, updated_state.mass, updated_state.t_ms, updated_state.epoch) self.assertAlmostEqual(dt, 550.1565, 2) mosse.stop()