def formula_to_dictionary(formula='<STR_LIT>', thickness=np.NaN, density=np.NaN, database='<STR_LIT>'):
if '<STR_LIT:.>' in formula:<EOL><INDENT>raise ValueError("<STR_LIT>".format(formula, '<STR_LIT:.>'))<EOL><DEDENT>_formula_parsed = re.findall(r'<STR_LIT>', formula)<EOL>if len(_formula_parsed) == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>".format(formula))<EOL><DEDENT>_elements_array = []<EOL>_atomic_ratio_array = []<EOL>for _element in _formula_parsed:<EOL><INDENT>[_single_element, _atomic_ratio] = list(_element)<EOL>if not is_element_in_database(element=_single_element, database=database):<EOL><INDENT>raise ValueError("<STR_LIT>".format(_single_element, database))<EOL><DEDENT>if _atomic_ratio == '<STR_LIT>':<EOL><INDENT>_atomic_ratio = <NUM_LIT:1><EOL><DEDENT>_atomic_ratio_array.append(int(_atomic_ratio))<EOL>_elements_array.append(_single_element)<EOL><DEDENT>_dict = {formula: {'<STR_LIT>': _elements_array,<EOL>'<STR_LIT>': _atomic_ratio_array,<EOL>'<STR_LIT>': {'<STR_LIT:value>': thickness,<EOL>'<STR_LIT>': '<STR_LIT>'},<EOL>'<STR_LIT>': {'<STR_LIT:value>': density,<EOL>'<STR_LIT>': '<STR_LIT>'},<EOL>'<STR_LIT>': {'<STR_LIT:value>': np.nan,<EOL>'<STR_LIT>': '<STR_LIT>'}<EOL>}<EOL>}<EOL>return _dict<EOL>
create dictionary based on formula given

    Parameters:
    ===========
    formula: string
       ex: 'AgCo2'
       ex: 'Ag'
    thickness: float (in mm) default is np.NaN
    density: float (in g/cm3) default is np.NaN
    database: string (default is ENDV_VIII). Database where to look for elements

    Raises:
    =======
    ValueError if one of the element is missing from the database

    Return:
    =======
    the dictionary of the elements passed
      ex: {'AgCo2': {'elements': ['Ag','Co'],
                     'stoichiometric_ratio': [1,2],
                     'thickness': {'value': thickness,
                                   'units': 'mm'},
                     'density': {'value': density,
                                 'units': 'g/cm3'},
                     'molar_mass': {'value': np.nan,
                                    'units': 'g/mol'},
                    }