Example #1
0
def test_ending():
    correct = """ITERATIONS 15
PRINT 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
PUNCH 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
BEGIN                    ITERATION  15 COMPLETED
END
"""
    md = model_definition.ModelDefinition()
    assert correct == md._ending()
Example #2
0
def test_introduction():
    correct_intoduction = """READ KAPPA
READ PUNCH
MOLECULES ON
READ MOLECULES
FREQUENCIES 337 1 337 BIG
CONVECTION OVER 1.25 0 36
"""
    md = model_definition.ModelDefinition()
    assert md._introduction() == correct_intoduction
Example #3
0
def test_set_title():
    parameters = MagicMock()
    parameters.microturbulence = 10
    parameters.teff = 8000
    parameters.logg = 4.34
    parameters.metallicity = 0.0

    title_line = "TITLE TEFF=8000, LOGG=4.34, [M/H]=0.00, VMIC=10\n"

    md = model_definition.ModelDefinition()
    assert md._title(parameters) == title_line
Example #4
0
def test_teff_logg_string(teff, logg, correct_definition):
    parameters = MagicMock()
    parameters.teff = teff
    parameters.logg = logg

    # TEFF FORMAT "-----."
    # LOGG FORMAT "-.--"
    # "SCALE 72 -6.875 0.125 -----. -.--"

    md = model_definition.ModelDefinition()
    assert md._teff_logg(parameters) == correct_definition
Example #5
0
def test_single_abundance():
    parameters = MagicMock()

    parameters.chemical_composition = {
        1: 0.9004,
        2: 0.08034,
        3: -10.92,
        100: None
    }

    correct = "ABUNDANCE CHANGE  1 0.9004\nABUNDANCE CHANGE  2 0.08034\nABUNDANCE CHANGE  3 -10.92\n"
    md = model_definition.ModelDefinition()
    for c, r in zip(correct.splitlines(),
                    md._chemical_composition(parameters).splitlines()):
        assert c[0:17] == r[0:17]
        assert float(c[17:20]) == float(r[17:20])
        assert float(c[20:]) == float(r[20:])
Example #6
0
def test_creating_model_definition():
    parameters = MagicMock()

    parameters.microturbulence = 10
    parameters.teff = 8000
    parameters.logg = 4.34
    parameters.metallicity = 0.0
    parameters.chemical_composition = {
        1: 0.9004,
        2: 0.08034,
        3: -10.92,
        100: None
    }

    md = model_definition.ModelDefinition()
    model_string = md(parameters)
    # It is difficult to test correct format of ATLAS definition file so I don't do it
    # I test the type in order to document how to use ModelDefinition class
    assert type("string") == type(model_string)
Example #7
0
def test_metallicity(metallicity, correct):
    parameters = MagicMock()
    parameters.metallicity = metallicity

    md = model_definition.ModelDefinition()
    assert md._metallicity(parameters) == correct
Example #8
0
def test_turbulence(microturbulence, correct):
    parameters = MagicMock()
    parameters.microturbulence = microturbulence

    md = model_definition.ModelDefinition()
    assert md._microturbulence(parameters) == correct