Beispiel #1
0
def test_temperature_corrections_QH(QS, E, ZPE, H, qhH, TS, TqhS, G, qhG):
    temp = 200
    conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, spc, invert = True, 100.0, 100.0, 1.0, 'none', False, False
    bbe298 = GV.calc_bbe(datapath('Al_298K.out'), QS, QH, s_freq_cutoff,
                         h_freq_cutoff, temp, conc, freq_scale_factor, solv,
                         spc, invert)
    bbe400 = GV.calc_bbe(datapath('Al_400K.out'), QS, QH, s_freq_cutoff,
                         h_freq_cutoff, temp, conc, freq_scale_factor, solv,
                         spc, invert)
    precision = 6
    assert E == round(bbe298.scf_energy, precision) == round(
        bbe400.scf_energy, precision)
    assert ZPE == round(bbe298.zpe, precision) == round(bbe400.zpe, precision)
    assert H == round(bbe298.enthalpy, precision) == round(
        bbe400.enthalpy, precision)
    assert qhH == round(bbe298.qh_enthalpy, precision) == round(
        bbe400.qh_enthalpy, precision)
    assert TS == round(temp * bbe298.entropy, precision) == round(
        temp * bbe400.entropy, precision)
    assert TqhS == round(temp * bbe298.qh_entropy, precision) == round(
        temp * bbe400.qh_entropy, precision)
    assert G == round(bbe298.gibbs_free_energy, precision) == round(
        bbe400.gibbs_free_energy, precision)
    assert qhG == round(bbe298.qh_gibbs_free_energy, precision) == round(
        bbe400.qh_gibbs_free_energy, precision)
Beispiel #2
0
def test_temperature_corrections(QH, E, ZPE, H, TS, TqhS, G, qhG):
    temp = 200
    conc = GV.atmos / (GV.GAS_CONSTANT * temp)
    freq_cutoff, freq_scale_factor, solv, spc = 100.0, 1.0, 'none', False
    bbe298 = GV.calc_bbe(datapath('Al_298K.out'), QH, freq_cutoff, temp, conc, freq_scale_factor, solv, spc)
    bbe400 = GV.calc_bbe(datapath('Al_400K.out'), QH, freq_cutoff, temp, conc, freq_scale_factor, solv, spc)
    precision = 6
    assert E == round(bbe298.scf_energy, precision) == round(bbe400.scf_energy, precision)
    assert ZPE == round(bbe298.zpe, precision) == round(bbe400.zpe, precision)
    assert H == round(bbe298.enthalpy, precision) == round(bbe400.enthalpy, precision)
    assert TS == round(temp * bbe298.entropy, precision) == round(temp * bbe400.entropy, precision)
    assert TqhS == round(temp * bbe298.qh_entropy, precision) == round(temp * bbe400.qh_entropy, precision)
    assert G == round(bbe298.gibbs_free_energy, precision) == round(bbe400.gibbs_free_energy, precision)
    assert qhG == round(bbe298.qh_gibbs_free_energy, precision) == round(bbe400.qh_gibbs_free_energy, precision)
Beispiel #3
0
def test_media_correction(path, conc, media, E, ZPE, H, TS, TqhS, G, qhG):
    path = datapath(path)
    QH, QS, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, temp, solv, spc, invert = False, "grimme", 100.0, 100.0, 1.0, 298.15, 'none', False, False
    bbe = GV.calc_bbe(path, QS, QH, s_freq_cutoff, h_freq_cutoff, temp, conc,
                      freq_scale_factor, solv, spc, invert)
    precision = 6

    media_correction = 0.0
    if media is not False:
        MW_solvent = solvents[media][0]
        density_solvent = solvents[media][1]
        concentration_solvent = (density_solvent * 1000) / MW_solvent
        media_correction = -(GV.GAS_CONSTANT /
                             GV.J_TO_AU) * math.log(concentration_solvent)

    assert E == round(bbe.scf_energy, precision)
    if hasattr(bbe, "gibbs_free_energy"):
        assert ZPE == round(bbe.zpe, precision)
        assert H == round(bbe.enthalpy, precision)
        assert TS == round(temp * (bbe.entropy + media_correction), precision)
        assert TqhS == round(temp * (bbe.qh_entropy + media_correction),
                             precision)
        assert G == round(bbe.gibbs_free_energy + (temp * (-media_correction)),
                          precision)
        assert qhG == round(
            bbe.qh_gibbs_free_energy + (temp * (-media_correction)), precision)
Beispiel #4
0
    def __init__(self, file):
        # default values for thermochemical calculations
        if '.log' not in file:
            raise TypeError('A g16 .log file must be provided')
            
        self.file=file
        self.name=os.path.basename(file)
        
        QH, freq_cutoff, temperature, freq_scale_factor, solv, spc = 'grimme', 100.0, 298.15, 1.0, 'none', False
        conc = GV.atmos / GV.GAS_CONSTANT / temperature

        self.get_termination() and self.getCPU()
        self.get_error() and self.getCPU()
        
        try:
            #pybel molecule object
            self._pybel_mol = next(readfile('g09', file))
        except:
            raise Exception('You log file is too bad to generate a molecule')
        else:
            self.get_charge()
            self.get_route()
            self.get_coords()
            self.freq = pq.getoutData(file)
         
        if self.termination:
            bbe = GV.calc_bbe(file, QH, freq_cutoff, temperature, conc, freq_scale_factor, solv, spc)
            if hasattr(bbe, 'scf_energy'): self._pybel_mol.data['scf_energy'] = bbe.scf_energy
            if hasattr(bbe, 'enthalpy'): self._pybel_mol.data['enthalpy'] = bbe.enthalpy 
            if hasattr(bbe, 'im_freq'): self._pybel_mol.data['im_freq'] = len(bbe.im_freq)
            if hasattr(self, 'CPU'):
                cpu = self.CPU[0]*3600*24 + self.CPU[1]*3600 + self.CPU[2]*60 + self.CPU[3]
                self._pybel_mol.data['CPU'] = '{}s'.format(cpu)
            
        self.get_rdkit_mol()
Beispiel #5
0
def test_scaling_factor_search(filename, freq_scale_factor, zpe):
    temp = 298.15
    conc = GV.atmos / (GV.GAS_CONSTANT * temp)
    QH, freq_cutoff, solv, spc = 'grimme', 100.0, 'none', False
    precision = 6

    bbe = GV.calc_bbe(datapath('ethane.out'), QH, freq_cutoff, temp, conc, freq_scale_factor, solv, spc)
    assert zpe == round(bbe.zpe, precision)
Beispiel #6
0
def test_scaling_factor_search(filename, freq_scale_factor, zpe):
    temp = 298.15
    conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    QS, QH, s_freq_cutoff, h_freq_cutoff, solv, spc, invert = 'grimme', True, 100.0, 100.0, 'none', False, False
    precision = 6
    bbe = GV.calc_bbe(datapath('ethane.out'), QS, QH, s_freq_cutoff,
                      h_freq_cutoff, temp, conc, freq_scale_factor, solv, spc,
                      invert)
    assert zpe == round(bbe.zpe, precision)
Beispiel #7
0
def test_pes(E, ZPE, H, TS, TqhS, GT, qhGT):
    temp = 298.15
    conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    QS, QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, invert, d3 = 'grimme', False, 100.0, 100.0, 1.0, 'none', False, 0
    invert, spc, gconf = False, False, True
    precision = 2
    files = [
        'pes/Int-III_Oax_cis_a.log', 'pes/Int-II_Oax_cis_a.log',
        'pes/Int-I_Oax.log', 'pes/TolS.log', 'pes/TolSH.log'
    ]
    files = [datapath(file) for file in files]
    log = GV.Logger("GoodVibes", 'test', False)

    bbe_vals = []
    for file in files:  # loop over all specified output files and compute thermochemistry
        bbe = GV.calc_bbe(file, QS, QH, s_freq_cutoff, h_freq_cutoff, temp,
                          conc, freq_scale_factor, solv, spc, invert, d3)
        bbe_vals.append(bbe)
    fileList = [file for file in files]
    thermo_data = dict(zip(
        fileList, bbe_vals))  # the collected thermochemical data for all files

    pes = GV.get_pes(datapath('pes/Cis_complete_pathway.yaml'), thermo_data,
                     log, temp, gconf, QH)

    zero_vals = [
        pes.e_zero[0][0], pes.zpe_zero[0][0], pes.h_zero[0][0],
        temp * pes.ts_zero[0][0], temp * pes.qhts_zero[0][0], pes.g_zero[0][0],
        pes.qhg_zero[0][0]
    ]

    for i, path in enumerate(pes.path):
        for j, e_abs in enumerate(pes.e_abs[i]):
            species = [
                pes.e_abs[i][j], pes.zpe_abs[i][j], pes.h_abs[i][j],
                temp * pes.s_abs[i][j], temp * pes.qs_abs[i][j],
                pes.g_abs[i][j], pes.qhg_abs[i][j]
            ]
            relative = [
                species[x] - zero_vals[x] for x in range(len(zero_vals))
            ]
            formatted_list = [GV.KCAL_TO_AU * x for x in relative]
            assert E[j] == round(formatted_list[0], precision)
            assert ZPE[j] == round(formatted_list[1], precision)
            assert H[j] == round(formatted_list[2], precision)
            assert TS[j] == round(formatted_list[3], precision)
            assert TqhS[j] == round(formatted_list[4], precision)
            assert GT[j] == round(formatted_list[5], precision)
            assert qhGT[j] == round(formatted_list[6], precision)
    log.finalize()
Beispiel #8
0
def test_all(path, QH, temp, E, ZPE, H, TS, TqhS, G, qhG):
    # Defaults, no temp interval, no conc interval
    path = datapath(path)
    conc = GV.atmos / (GV.GAS_CONSTANT * temp)
    freq_cutoff, freq_scale_factor, solv, spc = 100.0, 1.0, 'none', False
    bbe = GV.calc_bbe(path, QH, freq_cutoff, temp, conc, freq_scale_factor, solv, spc)
    precision = 6 # if temp == 298.15 else 4e-4
    assert E == round(bbe.scf_energy, precision)
    if hasattr(bbe, "gibbs_free_energy"):
        assert ZPE == round(bbe.zpe, precision)
        assert H == round(bbe.enthalpy, precision)
        assert TS == round(temp * bbe.entropy, precision)
        assert TqhS == round(temp * bbe.qh_entropy, precision)
        assert G == round(bbe.gibbs_free_energy, precision)
        assert qhG == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #9
0
def test_concentration_correction(path, conc, QS, E, ZPE, H, TS, TqhS, G, qhG):
    path = datapath(path)
    QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, temp, solv, spc, invert = False, 100.0, 100.0, 1.0, 298.15, 'none', False, False
    if conc == False:
        conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    bbe = GV.calc_bbe(path, QS, QH, s_freq_cutoff, h_freq_cutoff, temp, conc,
                      freq_scale_factor, solv, spc, invert)
    precision = 6
    assert E == round(bbe.scf_energy, precision)
    if hasattr(bbe, "gibbs_free_energy"):
        assert ZPE == round(bbe.zpe, precision)
        assert H == round(bbe.enthalpy, precision)
        assert TS == round(temp * bbe.entropy, precision)
        assert TqhS == round(temp * bbe.qh_entropy, precision)
        assert G == round(bbe.gibbs_free_energy, precision)
        assert qhG == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #10
0
def test_QS(path, QS, temp, E, ZPE, H, TS, TqhS, G, qhG):
    # Defaults, no temp interval, no conc interval
    path = datapath(path)
    conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, spc, invert = False, 100.0, 100.0, 1.0, 'none', False, False
    bbe = GV.calc_bbe(path, QS, QH, s_freq_cutoff, h_freq_cutoff, temp, conc,
                      freq_scale_factor, solv, spc, invert)
    precision = 6  # if temp == 298.15 else 4e-4
    assert E == round(bbe.scf_energy, precision)
    if hasattr(bbe, "gibbs_free_energy"):
        assert ZPE == round(bbe.zpe, precision)
        assert H == round(bbe.enthalpy, precision)
        assert TS == round(temp * bbe.entropy, precision)
        assert TqhS == round(temp * bbe.qh_entropy, precision)
        assert G == round(bbe.gibbs_free_energy, precision)
        assert qhG == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #11
0
def test_single_point_correction(spc, E_spc, E, ZPE, H, TS, TqhS, GT, qhGT):
    temp = 298.15
    conc = GV.atmos / (GV.GAS_CONSTANT * temp)
    QH, freq_cutoff, freq_scale_factor, solv = 'grimme', 100.0, 1.0, 'none'
    precision = 6

    bbe = GV.calc_bbe(datapath('ethane.out'), QH, freq_cutoff, temp, conc, freq_scale_factor, solv, spc)
    if E_spc:
        assert E_spc == round(bbe.sp_energy, precision)
    assert E == round(bbe.scf_energy, precision)
    assert ZPE == round(bbe.zpe, precision)
    assert H == round(bbe.enthalpy, precision)
    assert TS == round(temp * bbe.entropy, precision)
    assert TqhS == round(temp * bbe.qh_entropy, precision)
    assert GT == round(bbe.gibbs_free_energy, precision)
    assert qhGT == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #12
0
def test_single_point_correction(spc, E_spc, E, ZPE, H, TS, TqhS, GT, qhGT):
    temp = 298.15
    conc = GV.atmos / (GV.GAS_CONSTANT * temp)
    QH, freq_cutoff, freq_scale_factor, solv = 'grimme', 100.0, 1.0, 'none'
    precision = 6

    bbe = GV.calc_bbe(datapath('ethane.out'), QH, freq_cutoff, temp, conc,
                      freq_scale_factor, solv, spc)
    if E_spc:
        assert E_spc == round(bbe.sp_energy, precision)
    assert E == round(bbe.scf_energy, precision)
    assert ZPE == round(bbe.zpe, precision)
    assert H == round(bbe.enthalpy, precision)
    assert TS == round(temp * bbe.entropy, precision)
    assert TqhS == round(temp * bbe.qh_entropy, precision)
    assert GT == round(bbe.gibbs_free_energy, precision)
    assert qhGT == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #13
0
def test_temperature_interval(path, ti, H, TS, TqhS, GT, qhGT):

    QS, QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, spc, invert, d3 = 'grimme', False, 100.0, 100.0, 1.0, 'none', False, False, 0
    precision = 6
    temperature_interval = [float(temp) for temp in ti.split(',')]
    interval = range(int(temperature_interval[0]),
                     int(temperature_interval[1] + 1),
                     int(temperature_interval[2]))
    for i in range(len(interval)):
        temp = float(interval[i])
        conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
        bbe = GV.calc_bbe(datapath(path), QS, QH, s_freq_cutoff, h_freq_cutoff,
                          temp, conc, freq_scale_factor, solv, spc, invert, d3)

        assert H[i] == round(bbe.enthalpy, precision)
        assert TS[i] == round(temp * bbe.entropy, precision)
        assert TqhS[i] == round(temp * bbe.qh_entropy, precision)
        assert GT[i] == round(bbe.gibbs_free_energy, precision)
        assert qhGT[i] == round(bbe.qh_gibbs_free_energy, precision)
Beispiel #14
0
def test_pes(E, ZPE, H, TS, TqhS, GT, qhGT):
    temp = 298.15
    conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
    QS, QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, invert = 'grimme', False, 100.0, 100.0, 1.0, 'none', False
    invert, spc, gconf = False, False, True
    precision = 6
    files = [
        'pes/Int-III_Oax_cis_a.log', 'pes/Int-II_Oax_cis_a.log',
        'pes/Int-I_Oax.log', 'pes/TolS.log', 'pes/TolSH.log'
    ]
    files = [datapath(file) for file in files]
    log = GV.Logger("GoodVibes", 'test', False)

    bbe_vals = []
    for file in files:  # loop over all specified output files and compute thermochemistry
        bbe = GV.calc_bbe(file, QS, QH, s_freq_cutoff, h_freq_cutoff, temp,
                          conc, freq_scale_factor, solv, spc, invert)
        bbe_vals.append(bbe)
    fileList = [file for file in files]
    thermo_data = dict(zip(
        fileList, bbe_vals))  # the collected thermochemical data for all files

    pes = GV.get_pes(datapath('pes/Cis_complete_pathway.yaml'), thermo_data,
                     log, temp, gconf, QH)

    zero_vals = [
        pes.e_zero[0][0], pes.zpe_zero[0][0], pes.h_zero[0][0],
        temp * pes.ts_zero[0][0], temp * pes.qhts_zero[0][0], pes.g_zero[0][0],
        pes.qhg_zero[0][0]
    ]

    for i, path in enumerate(pes.path):
        for j, e_abs in enumerate(pes.e_abs[i]):
            species = [
                pes.e_abs[i][j], pes.zpe_abs[i][j], pes.h_abs[i][j],
                temp * pes.s_abs[i][j], temp * pes.qs_abs[i][j],
                pes.g_abs[i][j], pes.qhg_abs[i][j]
            ]
            relative = [
                species[x] - zero_vals[x] for x in range(len(zero_vals))
            ]
            formatted_list = [GV.KCAL_TO_AU * x for x in relative]
            assert E[j] == round(formatted_list[0], precision)
            assert ZPE[j] == round(formatted_list[1], precision)
            assert H[j] == round(formatted_list[2], precision)
            assert TS[j] == round(formatted_list[3], precision)
            assert TqhS[j] == round(formatted_list[4], precision)
            assert GT[j] == round(formatted_list[5], precision)
            assert qhGT[j] == round(formatted_list[6], precision)
    log.Finalize()


# @pytest.mark.parametrize("yaml, gconf, E, ZPE, H, TS, TqhS, GT, qhGT", [
#     #test cat conformers
#     ('gconf_ee_boltz/gconf_TS.yaml', True, [0.0,5.053763],[0.0,-0.497994],[0.0,3.936414],[0.0,-14.426341],[0.0,-15.107289],[0.0,18.362755],[0.0,19.043703]),
#     ('gconf_ee_boltz/gconf_TS.yaml', False, [0.0,5.053763],[0.0,-0.497994],[0.0,3.936414],[0.0,-14.823888],[0.0,-15.504836],[0.0,18.760302],[0.0,19.44125]),
#     #test TS conformers
#     ('gconf_ee_boltz/gconf_aminox_cat.yaml', True, [0.0,4.716292],[0.0,-0.460919],[0.0,3.534549],[0.0,-15.852617],[0.0,-16.367881],[0.0,19.387166],[0.0,19.90243]),
#     ('gconf_ee_boltz/gconf_aminox_cat.yaml', False, [0.0,4.716292],[0.0,-0.460919],[0.0,3.534549],[0.0,-15.245404],[0.0,-15.760668],[0.0,18.779954],[0.0,19.295218])
#
# ])
# def test_gconf(yaml, gconf, E, ZPE, H, TS, TqhS, GT, qhGT):
#     temp = 298.15
#     conc = GV.ATMOS / (GV.GAS_CONSTANT * temp)
#     QS, QH, s_freq_cutoff, h_freq_cutoff, freq_scale_factor, solv, invert = 'grimme', False, 100.0, 100.0, 1.0, 'none', False
#     invert, spc = False, False
#     files = ['gconf_ee_boltz/Aminoxylation_TS1_R.log', 'gconf_ee_boltz/Aminoxylation_TS2_S.log', 'gconf_ee_boltz/aminox_cat_conf212_S.log', 'gconf_ee_boltz/aminox_cat_conf280_R.log', 'gconf_ee_boltz/aminox_cat_conf65_S.log','gconf_ee_boltz/aminox_subs_conf713.log']
#     files = [datapath(file) for file in files]
#     log = GV.Logger("GoodVibes",'test',False)
#     yaml = datapath(yaml)
#
#     bbe_vals = []
#     for file in files: # loop over all specified output files and compute thermochemistry
#         bbe = GV.calc_bbe(file, QS, QH, s_freq_cutoff, h_freq_cutoff, temp,
#                         conc, freq_scale_factor, solv, spc, invert)
#         bbe_vals.append(bbe)
#     fileList = [file for file in files]
#     thermo_data = dict(zip(fileList, bbe_vals)) # the collected thermochemical data for all files
#
#     pes = GV.get_pes(yaml,thermo_data,log,temp,gconf,QH)
#
#     zero_vals = [pes.e_zero[0][0], pes.zpe_zero[0][0], pes.h_zero[0][0], temp * pes.ts_zero[0][0], temp * pes.qhts_zero[0][0], pes.g_zero[0][0], pes.qhg_zero[0][0]]
#
#     for i, path in enumerate(pes.path):
#         for j, e_abs in enumerate(pes.e_abs[i]):
#             species = [pes.e_abs[i][j], pes.zpe_abs[i][j], pes.h_abs[i][j], temp * pes.s_abs[i][j], temp * pes.qs_abs[i][j], pes.g_abs[i][j], pes.qhg_abs[i][j]]
#             relative = [species[x]-zero_vals[x] for x in range(len(zero_vals))]
#             formatted_list = [GV.KCAL_TO_AU * x for x in relative]
#             assert  '{:13.2f}'.format(E[j]) == '{:13.2f}'.format(formatted_list[0])
#             assert  '{:13.2f}'.format(ZPE[j]) == '{:13.2f}'.format(formatted_list[1])
#             assert  '{:13.2f}'.format(H[j]) == '{:13.2f}'.format(formatted_list[2])
#             assert  '{:13.2f}'.format(TS[j]) == '{:13.2f}'.format(formatted_list[3])
#             assert  '{:13.2f}'.format(TqhS[j]) == '{:13.2f}'.format(formatted_list[4])
#             assert  '{:13.2f}'.format(GT[j]) == '{:13.2f}'.format(formatted_list[5])
#             assert  '{:13.2f}'.format(qhGT[j]) == '{:13.2f}'.format(formatted_list[6])
#     log.Finalize()