示例#1
0
def test_populations(verbose=True, *args, **kwargs):
    """ Test that vib and rovib populations are calculated correctly """

    from radis.lbl import SpectrumFactory
    from radis.misc.basics import all_in

    export = ["vib", "rovib"]
    sf = SpectrumFactory(
        2000,
        2300,
        export_populations=export,
        db_use_cached=True,
        cutoff=1e-25,
        isotope="1",
    )
    sf.warnings.update({
        "MissingSelfBroadeningWarning": "ignore",
        "VoigtBroadeningWarning": "ignore"
    })
    sf.load_databank("HITRAN-CO-TEST")

    s = sf.non_eq_spectrum(2000, 2000)

    pops = sf.get_populations(export)
    if not all_in(["rovib", "vib"], list(pops["CO"][1]["X"].keys())):
        raise AssertionError(
            "vib and rovib levels should be defined after non_eq_spectrum calculation!"
        )
    if not "nvib" in list(pops["CO"][1]["X"]["vib"].keys()):
        raise AssertionError(
            "Vib populations should be defined after non_eq_spectrum calculation!"
        )

    s = sf.eq_spectrum(300)

    pops = sf.get_populations(export)
    if "nvib" in list(pops["CO"][1]["X"]["vib"].keys()):
        raise AssertionError(
            "Vib levels should not be defined anymore after eq_spectrum calculation!"
        )

    # Any of these is True and something went wrong
    s = sf.non_eq_spectrum(2000, 2000)
    s2 = sf.non_eq_spectrum(300, 300)

    # printm(all(s2.get_vib_levels(isotope=1) == s.get_vib_levels(isotope=1)))
    assert not (s2.get_vib_levels() is s.get_vib_levels())
    assert not (s2.get_rovib_levels() == s.get_rovib_levels()).all().all()
    assert not (s2.get_rovib_levels() is s.get_rovib_levels())

    return True  # if no AssertionError
示例#2
0
def test_populations(verbose=True, *args, **kwargs):
    ''' Test that vib and rovib populations are calculated correctly '''

    from radis.lbl import SpectrumFactory
    from radis.misc.basics import all_in

    export = ['vib', 'rovib']
    sf = SpectrumFactory(2000,
                         2300,
                         export_populations=export,
                         db_use_cached=True,
                         cutoff=1e-25,
                         isotope='1')
    sf.warnings.update({
        'MissingSelfBroadeningWarning': 'ignore',
        'VoigtBroadeningWarning': 'ignore'
    })
    sf.load_databank('HITRAN-CO-TEST')

    s = sf.non_eq_spectrum(2000, 2000)

    pops = sf.get_populations(export)
    if not all_in(['rovib', 'vib'], list(pops['CO'][1]['X'].keys())):
        raise AssertionError(
            'vib and rovib levels should be defined after non_eq_spectrum calculation!'
        )
    if not 'nvib' in list(pops['CO'][1]['X']['vib'].keys()):
        raise AssertionError(
            'Vib populations should be defined after non_eq_spectrum calculation!'
        )

    s = sf.eq_spectrum(300)

    pops = sf.get_populations(export)
    if 'nvib' in list(pops['CO'][1]['X']['vib'].keys()):
        raise AssertionError(
            'Vib levels should not be defined anymore after eq_spectrum calculation!'
        )

    # Any of these is True and something went wrong
    s = sf.non_eq_spectrum(2000, 2000)
    s2 = sf.non_eq_spectrum(300, 300)

    #printm(all(s2.get_vib_levels(isotope=1) == s.get_vib_levels(isotope=1)))
    assert not (s2.get_vib_levels() is s.get_vib_levels())
    assert not (s2.get_rovib_levels() == s.get_rovib_levels()).all().all()
    assert not (s2.get_rovib_levels() is s.get_rovib_levels())

    return True  # if no AssertionError