コード例 #1
0
ファイル: test_mcmc.py プロジェクト: anilkunwar/ESPEI
def test_lnprob_does_not_raise_on_ValueError(datasets_db):
    """lnprob() should catch ValueError raised by equilibrium and return -np.inf"""
    dbf = Database.from_string(CU_MG_TDB, fmt='tdb')
    datasets_db.insert(CU_MG_DATASET_ZPF_WORKING)
    res = lnprob([10], comps=['CU', 'MG', 'VA'], dbf=dbf,
                 phases=['LIQUID', 'FCC_A1', 'HCP_A3', 'LAVES_C15', 'CUMG2'],
                 datasets=datasets_db, symbols_to_fit=['VV0001'], phase_models=None)
    assert np.isneginf(res)
コード例 #2
0
def test_lnprob_calculates_probability_for_success(datasets_db):
    """lnprob() successfully calculates the probability for equilibrium """
    datasets_db.insert(zpf_json)
    res = lnprob([10], comps=['CU','MG', 'VA'], dbf=dbf,
                 phases=['LIQUID', 'FCC_A1', 'HCP_A3', 'LAVES_C15', 'CUMG2'],
                 datasets=datasets_db, symbols_to_fit=['VV0001'], phase_models=None, scheduler=None)
    assert np.isreal(res)
    assert np.isclose(res, -5740.542839073727)
コード例 #3
0
def test_lnprob_does_not_raise_on_ValueError(datasets_db):
    """lnprob() should catch ValueError raised by equilibrium and return -np.inf"""
    datasets_db.insert(zpf_json)
    res = lnprob([10],
                 comps=['CU', 'MG', 'VA'],
                 dbf=dbf,
                 phases=['LIQUID', 'FCC_A1', 'HCP_A3', 'LAVES_C15', 'CUMG2'],
                 datasets=datasets_db,
                 symbols_to_fit=['VV0001'],
                 phase_models=None,
                 scheduler=None)
    assert np.isneginf(res)
コード例 #4
0
ファイル: test_mcmc.py プロジェクト: anilkunwar/ESPEI
def test_lnprob_calculates_multi_phase_probability_for_success(datasets_db):
    """lnprob() successfully calculates the probability for equilibrium """
    dbf = Database.from_string(CU_MG_TDB, fmt='tdb')
    datasets_db.insert(CU_MG_DATASET_ZPF_WORKING)
    comps = ['CU', 'MG', 'VA']
    phases = ['LIQUID', 'FCC_A1', 'HCP_A3', 'LAVES_C15', 'CUMG2']
    param = 'VV0001'
    orig_val = dbf.symbols[param].args[0].expr
    eq_callables = build_callables(dbf, comps, phases, model=Model, parameters={param: orig_val})
    eq_callables['phase_models'] = eq_callables.pop('model')
    eq_callables.pop('phase_records')

    res = lnprob([10], comps=comps, dbf=dbf, phases=phases,
                 datasets=datasets_db, symbols_to_fit=[param], callables=eq_callables)

    assert np.isreal(res)
    assert np.isclose(res, -5740.54416621)

    res_2 = lnprob([10000000], comps=comps, dbf=dbf, phases=phases,
                 datasets=datasets_db, symbols_to_fit=[param], callables=eq_callables)

    assert not np.isclose(res_2, -5740.54416621)
コード例 #5
0
def test_lnprob_calculates_single_phase_probability_for_success(datasets_db):
    """lnprob() succesfully calculates the probability from single phase data"""
    datasets_db.insert(single_phase_json)
    res = lnprob(
        [10],
        comps=['CU', 'MG', 'VA'],
        dbf=dbf,
        phases=['LIQUID', 'FCC_A1', 'HCP_A3', 'LAVES_C15', 'CUMG2'],
        datasets=datasets_db,
        symbols_to_fit=['VV0001'],
        phase_models=None,
        scheduler=None,
    )
    assert np.isreal(res)
    assert np.isclose(res, -19859.38)