Beispiel #1
0
def thermo(vib_path, temp):
    """Calculate vibrational contributions to U, ZPE, Cv, and S

    vib_path (str): path to vibrational frequency data file (cm^-1 units)
    """
    # Read in vibrational frequencies (assumes cm^-1 units)
    vib = np.loadtxt(vib_path)

    # convert from cm-1 to eV
    vib_energies = vib * ase.units.invcm

    # initialize Harmonic-oscillator-approximated thermochemistry object
    thermo = HarmonicThermo(vib_energies)

    # Calculate U, ZPE, Cv, S, and ST.
    # Note that when E_pot = 0, U = ZPE + Cv
    u = thermo.get_internal_energy(temp, verbose=False)
    zpe = thermo.get_ZPE_correction()
    cv = u - zpe
    s = thermo.get_entropy(temp, verbose=False)
    ts = s * temp

    # calculate the G correction term
    g_correction = zpe + cv - ts

    # convert the results into a dictionary
    results = {
        'E_ZPE': zpe,
        'Cv_harm (0->T)': cv,
        'U': u,
        'S_harm': s,
        'T*S': ts,
        f'G_correction @ {temp} K': g_correction
    }

    # print the results in a nice format
    center = 50
    line = '=' * center
    print(line)
    print(f'Harmonic Thermochem Results at T = {temp} K'.center(center))
    print(line)

    # iteratively print each result in table format
    for name in results:
        lbl = 'eV/K' if name == 'S_harm' else 'eV'
        space = center - len(name) - 5
        val = results[name]
        print(f'{name}{val:>{space}.9f} {lbl}')
    print(line)
Beispiel #2
0
    ediff=1e-8,
    ediffg=-0.01,
    algo="Fast",
    gga="RP",
    xc="PBE",
    kpts=(4, 4, 1),
    #		isif = 0,
    #		ibrion = 5,
    #		nsw = 0,
    #		nfree = 2
)

adsorbedH.set_calculator(calc)
electronicenergy = adsorbedH.get_potential_energy()

print("electronic energy is %.5f" % electronicenergy)

vib = Vibrations(adsorbedH, indices=[23], delta=0.01, nfree=2)
vib.run()
print(vib.get_frequencies())
vib.summary()
print(vib.get_mode(-1))
vib.write_mode(-1)
vib_energies = vib.get_energies()

thermo = HarmonicThermo(vib_energies=vib_energies,
                        electronicenergy=electronicenergy)
thermo.get_entropy(temperature=298.15)
thermo.get_internal_energy(temperature=298.15)
thermo.get_free_energy(temperature=298.15)
Beispiel #3
0
		            'nmix':10,
                'maxsteps': maxsteps,
                'diag': 'david'},
              #mode = 'scf',
              output = {'avoidio':False,
                        'removewf':True,
                        'wf_collect':False},
	             outdirprefix='vibdir'
             )

atoms.set_calculator(calc)

vib = Vibrations(atoms, delta=0.04, indices=vib_atoms)
vib.run()
vib.summary(log='vibrations.txt')
vib.write_jmol()

#dyn = QuasiNewton(atoms, logfile='qn.log', trajectory='qn.traj')
#dyn.run(fmax=0.05)

energy = atoms.get_potential_energy()

vibs = vib.get_energies()

with open('vibrations.txt','r') as f: ZPE = f.readlines()[-1]
gibbs   = HarmonicThermo(vib_energies=vibs)
entropy = gibbs.get_entropy(temperature)

with open('converged.log', 'w') as f: f.write("Energy: %f eV\nEntropy: %f eV/K \n%s"%(energy,entropy,ZPE))