def get_enr(cond_filter_ele): """ Return 1 dict: * e_nr Dict of estimated exact no relativist energy (e_nr[name]) """ # -#-#- # # S Q L # # -#-#- # # Get Davidson est. atomics energies try: run_id_mol = e_nr_name_id_dict[config.get("estimated_exact", "method")] run_id_atom = e_nr_name_id_dict[config.get("estimated_exact", "atomic")] except KeyError: print "WARNING bad method in cfg" print "Will use by default Feller and Chakravorty" run_id_mol = e_nr_name_id_dict["Feller"] run_id_atom = e_nr_name_id_dict["Chakravorty"] cmd_id = cond_sql_or("run_id", [run_id_atom, run_id_mol]) cmd_where = " AND ".join(cond_filter_ele + cmd_id) c.execute("""SELECT name as name_atome, energy as exact_energy FROM simple_energy_tab NATURAL JOIN id_tab WHERE {cmd_where}""".format(cmd_where=cmd_where)) # -#-#-#- # # I n i t # # -#-#-#- # e_nr = defaultdict() # -#-#-#-#-#-#- # # F i l l _ i n # # -#-#-#-#-#-#- # # Put exact energy non relativist for atom and molecule for name, exact_energy in c.fetchall(): e_nr[name] = float(exact_energy) return e_nr
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]
def print_table_energy(run_info, table_body, header_name, header_unit): """ Print the famous energy table. If is to big, split it ! """ # -#-#-#-#-#-#-#- # # B i g Ta b l e # # -#-#-#-#-#-#-#- # from src.terminaltables import AsciiTable table_body = [map(str, i) for i in table_body] table_data = [header_name] + [header_unit] + table_body table_big = AsciiTable(table_data) # -#-#-#-#-#- # # F i l t e r # # -#-#-#-#-#- # # Table_big.ok Check if the table will fit in the terminal mode = config.get("Size", "mode") if all([mode == "Auto", not table_big.ok]) or mode == "Small": # Split into two table # table_run_id (run _id -> method,basis, comment) # table_data_small (run_id -> energy, etc) table_run_id = ["Run_id Method Basis Geo Comments".split()] for run_id, l in run_info.iteritems(): line = [run_id] + l table_run_id.append(line) t = AsciiTable([map(str, i) for i in table_run_id]) print t.table() table_data_small = [[l[0]] + l[5:] for l in table_data] t = AsciiTable(table_data_small) print t.table(row_separator=2) else: print table_big.table(row_separator=2)
# -*- coding: utf-8 -*- # _ # / _ | | _ _ _|_ o _ ._ # \_ (_) | | (/_ (_ |_ | (_) | | # from collections import defaultdict from src.Requirement_util import config import sys # Format dict format_dict = defaultdict() for name, value in config.items("Format_dict"): format_dict[name] = config.get("Format_mesure", value) DEFAULT_CHARACTER = "" from src.terminaltables import AsciiTable # _ # |_ _ ._ ._ _ _. _|_ # | (_) | | | | (_| |_ # def format_table(header_name, table_body): """ Take and retable table_body. Format the table """
# -*- coding: utf-8 -*- # _ # / _ | | _ _ _|_ o _ ._ # \_ (_) | | (/_ (_ |_ | (_) | | # from collections import defaultdict from src.Requirement_util import config import sys # Format dict format_dict = defaultdict() for name, value in config.items("Format_dict"): format_dict[name] = config.get("Format_mesure", value) DEFAULT_CHARACTER = "" from src.terminaltables import AsciiTable # _ # |_ _ ._ ._ _ _. _|_ # | (_) | | | | (_| |_ # def format_table(header_name, table_body): """ Take and retable table_body. Format the table