def test_dunham_co(verbose=True, *args, **kwargs): molecule = "CO" isotope = 1 # %% Check molecule data JSON from radis.db.utils import get_dunham_coefficients dunham_coeffs = get_dunham_coefficients(molecule, isotope, "X1SIG+") # # Compare with results from Evj calculation in Herzberg notation from radis.db.molecules import Molecules CO_X = Molecules[molecule][isotope]["X"] # %% Calculate v, J = 0, 0 if verbose: print(("Energies for CO(X) v, J=", v, J)) # ... calculate with Molecular Data from JSON (new format) print(("... from JSON: {0:.5f} cm-1".format(EvJ(v, J, **dunham_coeffs)))) # ... calculate with hardcoded Dunham expansion (legacy) print(("... from hardcoded Herzberg constants {0:.5f} cm-1".format( CO_X.Erovib(v, J, remove_ZPE=False)))) import numpy as np assert np.isclose(EvJ(v, J, **dunham_coeffs), CO_X.Erovib(v, J, remove_ZPE=False))
def _parse_rovib_constants(self, spectroscopic_constants, spectroscopic_constants_type): r"""Parse spectroscopic constants Stores :py:attr:`~radis.db.classes.ElectronicState.Te` and :py:attr:`~radis.db.classes.ElectronicState.re` as electronic state attributes, and the rest under :py:attr:`~radis.db.classes.ElectronicState.rovib_constants` Parameters ---------- spectroscopic_constants: str, or ``'default'`` filename of spectroscopic constants under Herzberg or Dunham format. Expected in the file: Yij: cm-1 rovibrational coefficients in Dunham convention or wexe, Be, etc. : cm-1 rovibrational coefficients in Herzberg convention or Te: cm-1 electronic energy. Default ``None`` if not given If ``default``, the constants defined in :ref:`spectroscopic constants <label_db_spectroscopic_constants>` are used. spectroscopic_constants_type: ``'herzberg'``, ``'dunham'`` convention for spectroscopic constants. Default ``'herzberg'`` Returns ------- None: but constants are stored under :py:attr:`~radis.db.classes.ElectronicState.rovib_constants`, and store json file in :py:attr:`~radis.db.classes.ElectronicState.jsonfile` """ # Get file name if spectroscopic_constants == "default": jsonfile = get_default_jsonfile(self.name) elif exists(spectroscopic_constants): # absolute path jsonfile = spectroscopic_constants else: # assume a json file stored in the default folder jsonfile = join(dirname(get_default_jsonfile(self.name)), spectroscopic_constants) # Parse file if spectroscopic_constants_type == "dunham": rovib_constants = get_dunham_coefficients(self.name, self.iso, self.get_statename_utf(), jsonfile=jsonfile) elif spectroscopic_constants_type == "herzberg": rovib_constants = get_herzberg_coefficients( self.name, self.iso, self.get_statename_utf(), jsonfile=jsonfile) else: raise ValueError( "Unexpected spectroscopic constant type: {0}".format( spectroscopic_constants_type)) # Clean keys # In particular, remove trailing '_cm-1' if given in dict or database import re rovib_constants = { re.sub("_cm-1$", "", k): v for (k, v) in rovib_constants.items() } # Get specific keys self.Te = rovib_constants.pop("Te", None) # default None self.re = rovib_constants.pop("re", None) # Store self.rovib_constants = rovib_constants self.jsonfile = jsonfile
from radis.db.utils import get_dunham_coefficients, get_herzberg_coefficients # %% 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=get_dunham_coefficients('CO', 1, 'X1SIG+'), 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=get_dunham_coefficients('CO', 2, 'X1SIG+'), vmax=17, # max level for Dunham's expansion vmax_morse=48, Ediss=eV2cm(11.16), ) CO_X_iso3 = ElectronicState(