def test_convert(verbose=True, *args, **kwargs): """ Test conversions """ E = np.linspace(1, 5, 5) # eV assert (J2eV(K2J(J2K(eV2J(E)))) == E).all() E = 2150 # cm-1 assert J2cm(cm2J(E)) == E assert K2cm(cm2K(E)) == E if verbose: print("K -> cm: ~ {0:.2f} K/cm".format(cm2K(1))) E = 1 # eV assert eV2cm(E) == J2cm(eV2J(1)) assert round(eV2K(E), 0) == 11605 assert K2eV(eV2K(E)) == E E = 250 # nm assert isclose(nm2eV(E), cm2eV(nm2cm(E))) assert eV2nm(nm2eV(E)) == E assert hz2nm(nm2hz(E)) == E fwhm = 1.5 # nm lbd_0 = 632.8 # nm assert isclose(fwhm, dcm2dnm(dnm2dcm(fwhm, lbd_0), nm2cm(lbd_0))) fwhm = 2e-3 # 0.002 nm lbd_0 = 632.8 fwhm_hz = dnm2dhz(fwhm, lbd_0) # ~ 1.5 GHz if verbose: print( ( "{0:.2g} nm broadening at {1} nm = {2:.2g} Ghz".format( fwhm, lbd_0, fwhm_hz * 1e-9 ) ) ) assert isclose(fwhm_hz * 1e-9, 1.4973307983125002) assert isclose(dhz2dnm(fwhm_hz, nm2hz(lbd_0)), fwhm) assert atm2bar(1) == 1.01325 assert isclose(torr2bar(atm2torr(bar2atm(1))), 1) assert isclose(torr2atm(bar2torr(atm2bar(1))), 1) # Hz assert isclose(1 / hz2cm(1e9), 30, atol=0.1) # 1 Ghz is about 30 cm assert hz2cm(cm2hz(600)) == 600 return True
def test_convert(verbose=True, *args, **kwargs): ''' Test conversions ''' E = np.linspace(1, 5, 5) # eV assert (J2eV(K2J(J2K(eV2J(E)))) == E).all() E = 2150 # cm-1 assert J2cm(cm2J(E)) E = 1 # eV assert (eV2cm(E) == J2cm(eV2J(1))) assert (round(eV2K(E), 0) == 11605) assert K2eV(eV2K(E)) == E E = 250 # nm assert isclose(nm2eV(E), cm2eV(nm2cm(E))) assert (eV2nm(nm2eV(E)) == E) assert hz2nm(nm2hz(E)) == E fwhm = 1.5 # nm lbd_0 = 632.8 # nm assert (isclose(fwhm, dcm2dnm(dnm2dcm(fwhm, lbd_0), nm2cm(lbd_0)))) fwhm = 2e-3 # 0.002 nm lbd_0 = 632.8 fwhm_hz = dnm2dhz(fwhm, lbd_0) # ~ 1.5 GHz if verbose: print(('{0:.2g} nm broadening at {1} nm = {2:.2g} Ghz'.format( fwhm, lbd_0, fwhm_hz * 1e-9))) assert isclose(fwhm_hz * 1e-9, 1.4973307983125002) assert isclose(dhz2dnm(fwhm_hz, nm2hz(lbd_0)), fwhm) assert atm2bar(1) == 1.01325 assert isclose(torr2bar(atm2torr(bar2atm(1))), 1) assert isclose(torr2atm(bar2torr(atm2bar(1))), 1) return True
# %% Define some commonly used molecules from radis.phys.convert import eV2cm # CO # ---------- # Define with default diatomic constants CO_X_iso1 = ElectronicState('CO', isotope=1, state='X', term_symbol='1Σ+', spectroscopic_constants='default', spectroscopic_constants_type='dunham', vmax=17, # max level for Dunham's expansion vmax_morse=48, Ediss=eV2cm(11.16), ) CO_X_iso2 = ElectronicState('CO', isotope=2, state='X', term_symbol='1Σ+', spectroscopic_constants='default', spectroscopic_constants_type='dunham', vmax=17, # max level for Dunham's expansion vmax_morse=48, Ediss=eV2cm(11.16), ) CO_X_iso3 = ElectronicState('CO', isotope=3, state='X', term_symbol='1Σ+', spectroscopic_constants='default', spectroscopic_constants_type='dunham', vmax=17, # max level for Dunham's expansion vmax_morse=48, Ediss=eV2cm(11.16), )