Example #1
0
def get_zpe_aeexp(cond_filter_ele):
    """
    Return 2 dict:
        * zpe_exp  Dict of zpe experimental                   (zpe_exp[name])
        * ae_exp   Dict of atomization experimental energis   (ae_ext[name])
    """

    # -#-#- #
    # S Q L #
    # -#-#- #
    try:
        zpe_ae_user = config.get("ZPE_AE", "value")
    except KeyError:
        print "WARNING bad ZPE AE type"
        raise

    if zpe_ae_user == "recomended":
        cond = ['basis_id=(1)']
    else:
        method_id = ae_zpe_exp_dict[zpe_ae_user]
        cond = ['(basis_id=1)', '(method_id=%d)' % (method_id)]

    cond_filter = cond_filter_ele + cond
    cmd_where = " AND ".join(cond_filter)

    cursor = c_row.execute("""SELECT name,
                         formula,
                             zpe,
                            kcal,
                   min(kcal_err) as kcal_err
                            FROM id_tab
                    NATURAL JOIN zpe_tab
                    NATURAL JOIN atomization_tab
                           WHERE {cmd_where}
                           GROUP BY name""".format(cmd_where=cmd_where))

    # -#-#-#- #
    # I n i t #
    # -#-#-#- #
    ae_exp = defaultdict()
    zpe_exp = defaultdict()

    # -#-#-#-#-#-#- #
    # F i l l _ i n #
    # -#-#-#-#-#-#- #
    for r in cursor:
        zpe = r['zpe'] * 4.55633e-06
        energy = r['kcal'] * 0.00159362
        energy_err = r['kcal_err'] * 0.00159362 if r['kcal_err'] else 0.

        ae_exp[r['name']] = v_un(energy, energy_err)
        zpe_exp[r['name']] = zpe

    return [ae_exp, zpe_exp]
Example #2
0
def get_zpe_aeexp(cond_filter_ele):
    """
    Return 2 dict:
        * zpe_exp  Dict of zpe experimental                   (zpe_exp[name])
        * ae_exp   Dict of atomization experimental energis   (ae_ext[name])
    """

    # -#-#- #
    # S Q L #
    # -#-#- #
    try:
        zpe_ae_user = config.get("ZPE_AE", "value")
    except KeyError:
        print "WARNING bad ZPE AE type"
        raise

    if zpe_ae_user == "recomended":
        cond = ['basis_id=(1)']
    else:
        method_id = ae_zpe_exp_dict[zpe_ae_user]
        cond = ['(basis_id=1)', '(method_id=%d)' % (method_id)]

    cond_filter = cond_filter_ele + cond
    cmd_where = " AND ".join(cond_filter)

    cursor = c_row.execute("""SELECT name,
                         formula,
                             zpe,
                            kcal,
                   min(kcal_err) as kcal_err
                            FROM id_tab
                    NATURAL JOIN zpe_tab
                    NATURAL JOIN atomization_tab
                           WHERE {cmd_where}
                           GROUP BY name""".format(cmd_where=cmd_where))

    # -#-#-#- #
    # I n i t #
    # -#-#-#- #
    ae_exp = defaultdict()
    zpe_exp = defaultdict()

    # -#-#-#-#-#-#- #
    # F i l l _ i n #
    # -#-#-#-#-#-#- #
    for r in cursor:
        zpe = r['zpe'] * 4.55633e-06
        energy = r['kcal'] * 0.00159362
        energy_err = r['kcal_err'] * 0.00159362 if r['kcal_err'] else 0.

        ae_exp[r['name']] = v_un(energy, energy_err)
        zpe_exp[r['name']] = zpe

    return [ae_exp, zpe_exp]
Example #3
0
def get_ecal_runinfo_finfo(cmd_where, cipsi_type):
    """
    Return 3 dict:
        * e_cal    Dict of energies theorical / calculated    (e_cal[run_id][name])
        * run_info Dict of the geo,basis,method,comments      (run_info[run_id])
        * f_info   Dict of formula (run_id[name])
    """
    # -#-#- #
    # S Q L #
    # -#-#- #
    cursor = c_row.execute("""SELECT formula,
                      num_atoms,
                         run_id,
                    method_name method,
                     basis_name basis,
                       geo_name geo,
                       comments,
                output_tab.name ele,
                       s_energy,
                       c_energy,
                          c_pt2,
                       q_energy,
                          q_err
                           FROM output_tab
                     INNER JOIN id_tab
                             ON output_tab.name = id_tab.name
                          WHERE {0}""".format(cmd_where.replace("name", "ele")))

    # -#-#-#- #
    # I n i t #
    # -#-#-#- #
    e_cal = defaultdict(dict)
    run_info = defaultdict()
    f_info = defaultdict()

    # -#-#-#-#-#-#- #
    # F i l l _ i n #
    # -#-#-#-#-#-#- #
    num_formula = namedtuple('num_formula', ['num_atoms', 'formula'])
    for r in cursor:
        # Energy
        if r['s_energy']:
            value = float(r['s_energy'])

        if r['c_energy']:
            if cipsi_type == "var":
                value = float(r['c_energy'])
            elif cipsi_type == "pt2":
                value = float(r['c_pt2'])
            elif cipsi_type == "var+pt2":
                value = float(r['c_energy']) + float(r['c_pt2'])

        if r['q_energy']:
            value = v_un(float(r['q_energy']),
                         float(r['q_err']))

        e_cal[r['run_id']][r['ele']] = value
        # Info
        run_info[r['run_id']] = [r['method'], r['basis'],
                                 r['geo'], r['comments']]

        if not r['ele'] in f_info:
            f_info[r['ele']] = num_formula(r['num_atoms'], eval(r['formula']))

    return [e_cal, run_info, f_info]
Example #4
0
def get_ecal_runinfo_finfo(cmd_where, cipsi_type):
    """
    Return 3 dict:
        * e_cal    Dict of energies theorical / calculated    (e_cal[run_id][name])
        * run_info Dict of the geo,basis,method,comments      (run_info[run_id])
        * f_info   Dict of formula (run_id[name])
    """
    # -#-#- #
    # S Q L #
    # -#-#- #
    cursor = c_row.execute("""SELECT formula,
                      num_atoms,
                         run_id,
                    method_name method,
                     basis_name basis,
                       geo_name geo,
                       comments,
                output_tab.name ele,
                       s_energy,
                       c_energy,
                          c_pt2,
                       q_energy,
                          q_err
                           FROM output_tab
                     INNER JOIN id_tab
                             ON output_tab.name = id_tab.name
                          WHERE {0}""".format(cmd_where.replace("name",
                                                                "ele")))

    # -#-#-#- #
    # I n i t #
    # -#-#-#- #
    e_cal = defaultdict(dict)
    run_info = defaultdict()
    f_info = defaultdict()

    # -#-#-#-#-#-#- #
    # F i l l _ i n #
    # -#-#-#-#-#-#- #
    num_formula = namedtuple('num_formula', ['num_atoms', 'formula'])
    for r in cursor:
        # Energy
        if r['s_energy']:
            value = float(r['s_energy'])

        if r['c_energy']:
            if cipsi_type == "var":
                value = float(r['c_energy'])
            elif cipsi_type == "pt2":
                value = float(r['c_pt2'])
            elif cipsi_type == "var+pt2":
                value = float(r['c_energy']) + float(r['c_pt2'])

        if r['q_energy']:
            value = v_un(float(r['q_energy']), float(r['q_err']))

        e_cal[r['run_id']][r['ele']] = value
        # Info
        run_info[r['run_id']] = [
            r['method'], r['basis'], r['geo'], r['comments']
        ]

        if not r['ele'] in f_info:
            f_info[r['ele']] = num_formula(r['num_atoms'], eval(r['formula']))

    return [e_cal, run_info, f_info]