Beispiel #1
0
    def test6(self):
        directory = os.path.dirname(__file__)
        set = io.read_set_from_file(os.path.join(directory, 'evolved.dyn'),
                                    'starlab')
        self.assertEqual(len(set), 20)

        self.assertAlmostRelativeEquals(
            set.time, set.age,
            4)  #only accurate to 4, starlab stellar evolution time scale?

        self.assertAlmostRelativeEquals(
            set[0].velocity, [177.579717905, 38.5027308364, -35.8571344243]
            | units.km / units.hour, 8)
        self.assertAlmostRelativeEquals(
            set[0].acceleration,
            [-0.000648471729782, 0.000309476774701, -0.000356623346185]
            | units.parsec / (units.Myr**2), 8)
        self.assertAlmostRelativeEquals(
            set.unconverted_set()[0].specific_potential,
            -0.32735384622167929 | nbody_system.potential)
        #select the main sequence star, the dwarf masses don't match
        main_sequence_stars = set.select(
            lambda stellar_type: stellar_type == units.stellar_type(
                "Main Sequence star"), ["stellar_type"])
        self.assertAlmostRelativeEquals(main_sequence_stars.mass,
                                        main_sequence_stars.relative_mass, 10)
        carbon_dwarfs = set.select(
            lambda stellar_type: stellar_type == units.stellar_type(
                "Carbon/Oxygen White Dwarf"), ["stellar_type"])
        self.assertAlmostRelativeEquals(carbon_dwarfs.mass,
                                        carbon_dwarfs.core_mass, 10)
Beispiel #2
0
 def test6(self):
     directory = os.path.dirname(__file__)
     set = io.read_set_from_file(os.path.join(directory, 'evolved.dyn'), 'starlab')
     self.assertEquals(len(set), 20)
     
     self.assertAlmostRelativeEquals(set.time, set.age, 4) #only accurate to 4, starlab stellar evolution time scale?
     
     self.assertAlmostRelativeEquals(set[0].velocity, [177.579717905, 38.5027308364, -35.8571344243] | units.km / units.hour, 8)
     self.assertAlmostRelativeEquals(set[0].acceleration, [-0.000648471729782, 0.000309476774701, -0.000356623346185] | units.parsec / (units.Myr ** 2), 8)
     self.assertAlmostRelativeEquals(set.unconverted_set()[0].specific_potential, -0.32735384622167929 | nbody_system.potential)
     #select the main sequence star, the dwarf masses don't match
     main_sequence_stars = set.select(lambda stellar_type : stellar_type ==  units.stellar_type("Main Sequence star"), ["stellar_type"])
     self.assertAlmostRelativeEquals(main_sequence_stars.mass, main_sequence_stars.relative_mass, 10)
     carbon_dwarfs = set.select(lambda stellar_type : stellar_type ==   units.stellar_type("Carbon/Oxygen White Dwarf") , ["stellar_type"])
     self.assertAlmostRelativeEquals(carbon_dwarfs.mass, carbon_dwarfs.core_mass, 10)
Beispiel #3
0
 def test5(self):
     set = starlab.StarlabFileFormatProcessor().load_string(with_stellar_structure)
     self.assertEquals(len(set), 2)
     self.assertAlmostRelativeEquals(set[0].envelope_mass, 0.0946766969331061387 | units.MSun)
     self.assertAlmostRelativeEquals(set[0].core_mass, 0.0100000000000000002 | units.MSun)
     self.assertAlmostRelativeEquals(set[0].relative_mass,  set[0].mass, 10)
     self.assertAlmostRelativeEquals(set[0].effective_temperature,  3011.01000587455155 | units.K)
     self.assertAlmostRelativeEquals(set[0].effective_luminocity,  0.00122847524117014736 | units.LSun)
     self.assertAlmostRelativeEquals(set[0].stellar_type, units.stellar_type("Main Sequence star"))
     self.assertAlmostRelativeEquals(set[1].relative_mass,  set[1].mass, 10)
Beispiel #4
0
 def convert_starlab_stellar_type_to_amuse(self, string):
     if string in starlab_stellar_types_to_amuse_stellar_type:
         return starlab_stellar_types_to_amuse_stellar_type[string]
     else:
         return units.stellar_type("Unknown stellar type")
Beispiel #5
0
import sys
import xml.dom.minidom 
import pdb #use with pdb.set_trace()
import re

from amuse.io import base
from amuse.units import units
from amuse.units import nbody_system
from amuse.units import generic_unit_converter

from amuse import datamodel
starlab_stellar_types_to_amuse_stellar_type = {
    "planet":units.stellar_type("Unknown stellar type"),
    "proto_star":units.stellar_type("Unknown stellar type"),
    "brown_dwarf":units.stellar_type("Unknown stellar type"),
    "main_sequence":units.stellar_type("Main Sequence star"),
    "hyper_giant":units.stellar_type("Second Asymptotic Giant Branch"),
    "hertzsprung_gap":units.stellar_type("Hertzsprung Gap"),
    "sub_giant":units.stellar_type("First Giant Branch"),
    "horizontal_branch":units.stellar_type("Core Helium Burning"),
    "super_giant":units.stellar_type("First Asymptotic Giant Branch"),
    "thorne_zytkow":units.stellar_type("Unknown stellar type"),
    "carbon_star":units.stellar_type("Unknown stellar type"),
    "helium_star":units.stellar_type("Main Sequence Naked Helium star"),
    "helium_giant":units.stellar_type("Giant Branch Naked Helium star"),
    "helium_dwarf":units.stellar_type("Helium White Dwarf"),
    "carbon_dwarf":units.stellar_type("Carbon/Oxygen White Dwarf"),
    "oxygen_dwarf":units.stellar_type("Oxygen/Neon White Dwarf"),
    "xray_pulsar":units.stellar_type("Neutron Star"),
    "radio_pulsar":units.stellar_type("Neutron Star"),
    "neutron_star":units.stellar_type("Neutron Star"),
Beispiel #6
0
 def convert_starlab_stellar_type_to_amuse(self, string):
     if string in starlab_stellar_types_to_amuse_stellar_type:
         return starlab_stellar_types_to_amuse_stellar_type[string]
     else:
         return units.stellar_type("Unknown stellar type")
Beispiel #7
0
import sys
import xml.dom.minidom
import pdb  # use with pdb.set_trace()
import re

from amuse.io import base
from amuse.units import units
from amuse.units import nbody_system
from amuse.units import generic_unit_converter

from amuse import datamodel

starlab_stellar_types_to_amuse_stellar_type = {
    "planet": units.stellar_type("Unknown stellar type"),
    "proto_star": units.stellar_type("Unknown stellar type"),
    "brown_dwarf": units.stellar_type("Unknown stellar type"),
    "main_sequence": units.stellar_type("Main Sequence star"),
    "hyper_giant": units.stellar_type("Second Asymptotic Giant Branch"),
    "hertzsprung_gap": units.stellar_type("Hertzsprung Gap"),
    "sub_giant": units.stellar_type("First Giant Branch"),
    "horizontal_branch": units.stellar_type("Core Helium Burning"),
    "super_giant": units.stellar_type("First Asymptotic Giant Branch"),
    "thorne_zytkow": units.stellar_type("Unknown stellar type"),
    "carbon_star": units.stellar_type("Unknown stellar type"),
    "helium_star": units.stellar_type("Main Sequence Naked Helium star"),
    "helium_giant": units.stellar_type("Giant Branch Naked Helium star"),
    "helium_dwarf": units.stellar_type("Helium White Dwarf"),
    "carbon_dwarf": units.stellar_type("Carbon/Oxygen White Dwarf"),
    "oxygen_dwarf": units.stellar_type("Oxygen/Neon White Dwarf"),
    "xray_pulsar": units.stellar_type("Neutron Star"),
    "radio_pulsar": units.stellar_type("Neutron Star"),